Chao Yan
2015-Mar-12 15:16 UTC
[LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)
2015-03-11 16:22 GMT-05:00 Richard Gorton < rcgorton at cognitive-electronics.com>:> I can confirm that musl builds and works correctly with clang/llvm. We > are using musl as a libc for our architecture. > It has a much smaller code footprint than newlib or glibc. >I successfully cross-compile the must-libc using clang, with the configuration: C=clang CFLAGS=--target=arm-none-linux-gnueabi\ --sysroot=/usr/local/arm-2009q\ -I\ /usr/local/arm-2009q3/arm-none-linux-gnueabi/libc/usr/include/ LIBCC./configure --target=arm But how to force clang to use musl-libc rather than its default one? I tried clang --target arm-none-linux-gnueabi -nostdlib -static hello.c ~/research/musl-1.1.6/lib/crt1.o ~/research/musl-1.1.6/lib/crti.o ~/research/musl-1.1.6/lib/crtn.o -I ~/research/musl-1.1.6/include/ -L ~/research/musl-1.1.6/lib/ -L /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1/ -lc -lgcc -lgcc_eh clang complaint: /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library search path "/lib/../lib" is unsafe for cross-compilation /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library search path "/usr/lib/../lib" is unsafe for cross-compilation /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library search path "/lib" is unsafe for cross-compilation /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library search path "/usr/lib" is unsafe for cross-compilation /home/yanchao/research/musl-1.1.6/lib//libc.a(__libc_start_main.o): In function `__libc_start_main': src/env/__libc_start_main.c:(.text+0x30): undefined reference to `__aeabi_memset' /home/yanchao/research/musl-1.1.6/lib//libc.a(vfprintf.o): In function `vfprintf': src/stdio/vfprintf.c:(.text+0x28): undefined reference to `__aeabi_memset' /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc.a(_dvmd_lnx.o): In function `__aeabi_ldiv0': (.text+0x8): undefined reference to `raise' /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(unwind-arm.o): In function `unwind_phase2': unwind-arm.c:(.text+0xae4): undefined reference to `abort' /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(unwind-arm.o): In function `__gnu_Unwind_Resume': unwind-arm.c:(.text+0xbe8): undefined reference to `abort' unwind-arm.c:(.text+0xc10): undefined reference to `abort' /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(pr-support.o): In function `_Unwind_GetTextRelBase': pr-support.c:(.text+0x4): undefined reference to `abort' /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(pr-support.o): In function `_Unwind_GetDataRelBase': pr-support.c:(.text+0xc): undefined reference to `abort' Regards, Chao -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150312/270e8420/attachment.html>
Jonathan Roelofs
2015-Mar-12 15:49 UTC
[LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)
On 3/12/15 9:16 AM, Chao Yan wrote:> > 2015-03-11 16:22 GMT-05:00 Richard Gorton > <rcgorton at cognitive-electronics.com > <mailto:rcgorton at cognitive-electronics.com>>: > > I can confirm that musl builds and works correctly with clang/llvm. > We are using musl as a libc for our architecture. > It has a much smaller code footprint than newlib or glibc. > > > > I successfully cross-compile the must-libc using clang, with the > configuration: > > C=clang CFLAGS=--target=arm-none-linux-gnueabi\ > --sysroot=/usr/local/arm-2009q\ -I\ > /usr/local/arm-2009q3/arm-none-linux-gnueabi/libc/usr/include/ LIBCC> ./configure --target=arm > > But how to force clang to use musl-libc rather than its default one? I > tried > > clang --target arm-none-linux-gnueabi -nostdlib -static hello.c > ~/research/musl-1.1.6/lib/crt1.o ~/research/musl-1.1.6/lib/crti.o > ~/research/musl-1.1.6/lib/crtn.o -I ~/research/musl-1.1.6/include/ -L > ~/research/musl-1.1.6/lib/ -L > /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1/ -lc -lgcc > -lgcc_eh > > clang complaint: > > /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library > search path "/lib/../lib" is unsafe for cross-compilation > /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library > search path "/usr/lib/../lib" is unsafe for cross-compilation > /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library > search path "/lib" is unsafe for cross-compilation > /usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-ld: warning: library > search path "/usr/lib" is unsafe for cross-compilationYou need to build a sysroot from the lib and include directories in ~/research/musl-1.1.6 combined with the same folders from /usr/local/arm-2009q, then use `--sysroot` instead of the `-I`s and `-L's.> /home/yanchao/research/musl-1.1.6/lib//libc.a(__libc_start_main.o): In > function `__libc_start_main': > src/env/__libc_start_main.c:(.text+0x30): undefined reference to > `__aeabi_memset' > /home/yanchao/research/musl-1.1.6/lib//libc.a(vfprintf.o): In function > `vfprintf': > src/stdio/vfprintf.c:(.text+0x28): undefined reference to `__aeabi_memset' > /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc.a(_dvmd_lnx.o): > In function `__aeabi_ldiv0': > (.text+0x8): undefined reference to `raise' > /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(unwind-arm.o): > In function `unwind_phase2': > unwind-arm.c:(.text+0xae4): undefined reference to `abort' > /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(unwind-arm.o): > In function `__gnu_Unwind_Resume': > unwind-arm.c:(.text+0xbe8): undefined reference to `abort' > unwind-arm.c:(.text+0xc10): undefined reference to `abort' > /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(pr-support.o): > In function `_Unwind_GetTextRelBase': > pr-support.c:(.text+0x4): undefined reference to `abort' > /usr/local/arm-2009q3/lib/gcc/arm-none-linux-gnueabi/4.4.1//libgcc_eh.a(pr-support.o): > In function `_Unwind_GetDataRelBase': > pr-support.c:(.text+0xc): undefined reference to `abort' > > Regards, > Chao > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded
Chao Yan
2015-Mar-12 19:59 UTC
[LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)
2015-03-12 10:49 GMT-05:00 Jonathan Roelofs <jonathan at codesourcery.com>:> You need to build a sysroot from the lib and include directories in > ~/research/musl-1.1.6 combined with the same folders from > /usr/local/arm-2009q, then use `--sysroot` instead of the `-I`s and `-L's.I copied everything from the lib in musl-1.1.6 to arm-2009q3/arm-none-linux-gnueabi/libc/usr/lib but there is still an error message: src/env/__libc_start_main.c:(.text+0x40): undefined reference to `__aeabi_memset' collect2: ld returned 1 exit status it seems that I need an arm-none-linux-gcc-4.9 (current version from arm-2009q3 is gcc-4.4) to support the `__aeabi_memset' function? Regards, Chao -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150312/3e8ba780/attachment.html>
Possibly Parallel Threads
- [LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)
- [LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)
- [LLVMdev] How to Cross Compile libcompiler_rt Static Library?
- [LLVMdev] How to Cross Compile libcompiler_rt Static Library?
- libcompiler_rt.so and libcompiler_rt.a are not being built