bug-libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27866: Handle clang's internal libraries when finding compiler's int


From: Manoj Gupta
Subject: bug#27866: Handle clang's internal libraries when finding compiler's internal libraries
Date: Fri, 28 Jul 2017 13:36:43 -0700

Hi,

This is Manoj working on ChromeOS. I am facing a problem trying to build it with clang with its own internal library (compiler-rt) since some packages like mesa fail to build. The root cause is clang uses an absolute path to link its internal libraries which libtool does not recognize.

e.g. clang++ -rtlib=compiler-rt main.cpp -v shows use of /usr/lib64/clang/5.0.0/lib/linux/libclang_rt.builtins-x86_64.a 

Libtool currently relies on "-lname" pattern to find the internal libraries. And this does not work if some code is compiled using + compiler-rt.
The issue was discovered in building mesa graphics library which uses -nostdlib flag  and relies on libtool to pass the additionally required compiler internal libraries.

I have a sample fix below for fixing this for clang.

+--- a/m4/libtool.m4
++++ b/m4/libtool.m4
+@@ -7531,7 +7544,7 @@
+   for p in `eval "$output_verbose_link_cmd"`; do
+     case $prev$p in
+
+-    -L* | -R* | -l*)
++    -L* | -R* | -l* | *clang_rt*.a)
+        # Some compilers place space between "-{L,R}" and the path.
+        # Remove the space.
+        if test x-L = "$p" ||
+

Please let me know if this is an appropriate fix.

Thanks,
Manoj

Sample linker command line when called by clang with compiler-rt:

 "/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/main-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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]