[cfe-users] Clang without shared gcc libraries
Arne Redlich
arne.redlich at googlemail.com
Mon Nov 11 02:09:09 PST 2013
Hi list,
I'm running into a problem when trying to build binaries with a clang
compiler (svn trunk, rev 194249) built with a gcc 4.8.1 without shared
libraries on Linux x86_64 (Ubuntu 12.04.3):
cat << EOF > /tmp/test.c
> int main()
> {
> return 0;
> }
> EOF
~/Projects/buildtools/3.0/debug/bin/clang /tmp/test.c
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Clang obviously adds -lgcc_s to the linker command line (see below),
whereas with the aforementioned gcc things work as expected.
Asking clang not to use the shared gcc libs results in this:
~/Projects/buildtools/3.0/debug/bin/clang -static-libgcc /tmp/test.c
/usr/bin/ld: cannot find -lgcc_eh
Am I missing something in my clang configuration / invocation or is
this a (known?) issue?
Thanks,
Arne
More details:
gcc configuration:
CXXFLAGS="-fPIC" CFLAGS="-fPIC" ./configure \
--program-prefix=vd- \
--prefix=$PREFIX \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-multiarch \
--enable-threads \
--enable-__cxa_atexit \
--enable-languages=c,c++ \
--with-mpfr-include=$(pwd)/../$GCC_DIR/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs \
llvm/clang configuration:
CFLAGS='-fPIC -ggdb3 -O0 -gdwarf-3 -D_GLIBCXX_DEBUG
-DGLIBCXX_DEBUG_PEDANTIC -DBOOST_SPIRIT_THREADSAFE
-D_FILE_OFFSET_BITS=64 -I/usr/include/python2.7'
CC=/home/arne/Projects/buildtools/3.0/debug/bin/vd-gcc
CXXFLAGS='-std=gnu++0x -fPIC -ggdb3 -O0 -gdwarf-3 -D_GLIBCXX_DEBUG
-DGLIBCXX_DEBUG_PEDANTIC -DBOOST_SPIRIT_THREADSAFE
-D_FILE_OFFSET_BITS=64 -I/usr/include/python2.7'
CXX=/home/arne/Projects/buildtools/3.0/debug/bin/vd-g++
/home/arne/Projects/buildtools/3.0/sources/llvm/configure
--prefix=/home/arne/Projects/buildtools/3.0/debug
--with-gcc-toolchain=/home/arne/Projects/buildtools/3.0/debug
--enable-cxx11 --enable-target=x86_64 --enable-optimized
LANG=C ~/Projects/buildtools/3.0/debug/bin/clang -v /tmp/test.c
clang version 3.4 (trunk 194249)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1
Selected GCC installation:
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1
"/home/arne/Projects/buildtools/3.0/debug/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name test.c -mrelocation-model static -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.22 -v
-resource-dir /home/arne/Projects/buildtools/3.0/debug/bin/../lib/clang/3.4
-internal-isystem /usr/local/include -internal-isystem
/home/arne/Projects/buildtools/3.0/debug/bin/../lib/clang/3.4/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdebug-compilation-dir
/home/arne/Projects/buildtools/3.0/sources -ferror-limit 19
-fmessage-length 127 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o
/tmp/test-ea7b30.o -x c /tmp/test.c
clang -cc1 version 3.4 based upon LLVM 3.4svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/arne/Projects/buildtools/3.0/debug/bin/../lib/clang/3.4/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
/usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtbegin.o
-L/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1
-L/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/../lib64
-L/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../..
-L/lib -L/usr/lib /tmp/test-ea7b30.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtend.o
/usr/lib/x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
~/Projects/buildtools/3.0/debug/bin/clang -v -static-libgcc /tmp/test.c
clang version 3.4 (trunk 194249)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1
Selected GCC installation:
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1
"/home/arne/Projects/buildtools/3.0/debug/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name test.c -mrelocation-model static -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.22 -v
-resource-dir /home/arne/Projects/buildtools/3.0/debug/bin/../lib/clang/3.4
-internal-isystem /usr/local/include -internal-isystem
/home/arne/buildtools/3.0/debug/bin/../lib/clang/3.4/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdebug-compilation-dir
/home/arne/Projects/buildtools/3.0/sources -ferror-limit 19
-fmessage-length 127 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o
/tmp/test-371964.o -x c /tmp/test.c
clang -cc1 version 3.4 based upon LLVM 3.4svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/arne/Projects/buildtools/3.0/debug/bin/../lib/clang/3.4/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
/usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtbegin.o
-L/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1
-L/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/../lib64
-L/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../..
-L/lib -L/usr/lib /tmp/test-371964.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
/home/arne/Projects/buildtools/3.0/debug/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtend.o
/usr/lib/x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lgcc_eh
clang: error: linker command failed with exit code 1 (use -v to see invocation)
More information about the cfe-users
mailing list