There is also a similar problem when using clang's compiler-rt for
builtins. In that case, the internal library is
/usr/lib64/clang/5.0.0/lib/linux/libclang_rt.builtins-x86_64.a.

Mesa graphics library links some libraries with -nostdlib option and relies
on libtool to supply the internal libraries on the command line. Since
libtool didn't find the compiler-rt builtin libarry, linking fails :(

clang++ -rtlib=compiler-rt main.cpp -v

Linker command line:

 "/usr/bin/x86_64-pc-linux-gnu-ld" --build-id --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/crt1.o
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/crti.o
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o
-L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x
-L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64
-L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64
-L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../x86_64-pc-linux-gnu/lib
-L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../..
-L/usr/bin/../lib -L/lib -L/usr/lib /tmp/dtoul-6b0bb5.o -lc++ -lm
/usr/lib64/clang/5.0.0/lib/linux/libclang_rt.builtins-x86_64.a -lgcc_eh -lc
/usr/lib64/clang/5.0.0/lib/linux/libclang_rt.builtins-x86_64.a -lgcc_eh
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtend.o
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/crtn.o

Thanks,
Manoj

On Wed, Jul 26, 2017 at 7:41 PM, Manoj Gupta <manojgu...@chromium.org>
wrote:

> Hi,
>
> We are trying to use clang with address sanitizer in one of the projects.
> However, there are build issues because libtool's internal compiler library
> detection part does not work with static libraries.
>
> e.g. clang++ main.cpp -fsanitize=address -v shows the use of static
> library /usr/lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a
>
> Looking at the source code at http://git.savannah.gnu.
> org/cgit/libtool.git/tree/m4/libtool.m4#n7556 , libtool does not handle
> use of static libraries.
>
>
> dnl Parse the compiler output and extract the necessary
> dnl objects, libraries and library flags.
> if AC_TRY_EVAL(ac_compile); then
>   # Parse the compiler output and extract the necessary
>   # objects, libraries and library flags.
>
>   # Sentinel used to keep track of whether or not we are before
>   # the conftest object file.
>   pre_test_object_deps_done=no
>
>   for p in `eval "$output_verbose_link_cmd"`; do
>     case $prev$p in
>
>   for p in `eval "$output_verbose_link_cmd"`; do
>     case $prev$p in
>
>     -L* | -R* | -l*) // Adding *.a here should handle static library
>
>
> Is it possible for libtool to handle this case?
>
> Linker command line (from the above clang invocation):
>
> /usr/bin/x86_64-pc-linux-gnu-ld" --build-id --eh-frame-hdr -m elf_x86_64
> -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
> /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/crt1.o
> /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/crti.o
> /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o
> -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x
> -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64
> -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64
> -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../x86_64-pc-linux-gnu/lib
> -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../..
> -L/usr/bin/../lib -L/lib -L/usr/lib -whole-archive
> /usr/lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a
> -no-whole-archive 
> --dynamic-list=/usr/lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a.syms
> -whole-archive /usr/lib64/clang/5.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
> -no-whole-archive --dynamic-list=/usr/lib64/clang/5.0.0/lib/linux/
> libclang_rt.asan_cxx-x86_64.a.syms /tmp/main-0d221f.o -lc++ -lm
> --no-as-needed -lpthread -lrt -lm -ldl -lgcc_s -lgcc -lc -lgcc_s -lgcc
> /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtend.o
> /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/../../../../lib64/crtn.o
>
> Thanks,
> Manoj
>
>
_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool

Reply via email to