Hi folks! I'm trying to build LLVM with LLVM on Ubuntu using the commands below. Building it with the GNU stuff (cpp, gcc, g++ and binutils packages) works, but after removing it, moving LLVM to /usr/local and symlinking /usr/bin/ld to ld.lld, I'm getting the following: === snip ==-- The C compiler identification is Clang 8.0.1 -- The CXX compiler identification is Clang 8.0.1 -- The ASM compiler identification is Clang -- Found assembler: /usr/local/bin/clang -- Check for working C compiler: /usr/local/bin/clang -- Check for working C compiler: /usr/local/bin/clang -- broken CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message): The C compiler "/usr/local/bin/clang" is not able to compile a simple test program. It fails with the following output: Change Dir: /home/elux/build/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/make" "cmTC_a9eab/fast" /usr/bin/make -f CMakeFiles/cmTC_a9eab.dir/build.make CMakeFiles/cmTC_a9eab.dir/build make[1]: Entering directory '/home/elux/build/CMakeFiles/CMakeTmp' Building C object CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o /usr/local/bin/clang -o CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -c /home/elux/build/CMakeFiles/CMakeTmp/testCCompiler.c Linking C executable cmTC_a9eab /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9eab.dir/link.txt --verbose=1 /usr/local/bin/clang CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -o cmTC_a9eab ld: error: cannot open crt1.o: No such file or directory ld: error: cannot open crti.o: No such file or directory ld: error: cannot open crtbegin.o: No such file or directory ld: error: unable to find library -lgcc ld: error: unable to find library -lgcc_s ld: error: unable to find library -lc ld: error: unable to find library -lgcc ld: error: unable to find library -lgcc_s ld: error: cannot open crtend.o: No such file or directory ld: error: cannot open crtn.o: No such file or directory clang-8: error: linker command failed with exit code 1 (use -v to see invocation) CMakeFiles/cmTC_a9eab.dir/build.make:97: recipe for target 'cmTC_a9eab' failed make[1]: *** [cmTC_a9eab] Error 1 make[1]: Leaving directory '/home/elux/build/CMakeFiles/CMakeTmp' Makefile:126: recipe for target 'cmTC_a9eab/fast' failed make: *** [cmTC_a9eab/fast] Error 2 CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:39 (project) -- Configuring incomplete, errors occurred! See also "/home/elux/build/CMakeFiles/CMakeOutput.log". See also "/home/elux/build/CMakeFiles/CMakeError.log". === snap == Commands used: === snip ==VERSION=8.0.1 DESTDIR=/tmp/llvm PREFIX=/usr/local #wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/llvm-${VERSION}.src.tar.xz #wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/cfe-${VERSION}.src.tar.xz #wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxx-${VERSION}.src.tar.xz #wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxxabi-${VERSION}.src.tar.xz #wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/lld-${VERSION}.src.tar.xz #wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/compiler-rt-${VERSION}.src.tar.xz tar xf llvm-${VERSION}.src.tar.xz tar xf cfe-${VERSION}.src.tar.xz tar xf libcxx-${VERSION}.src.tar.xz tar xf libcxxabi-${VERSION}.src.tar.xz tar xf lld-${VERSION}.src.tar.xz tar xf compiler-rt-${VERSION}.src.tar.xz mv cfe-${VERSION}.src llvm-${VERSION}.src/projects/clang mv libcxx-${VERSION}.src llvm-${VERSION}.src/projects/libcxx mv libcxxabi-${VERSION}.src llvm-${VERSION}.src/projects/libcxxabi mv lld-${VERSION}.src llvm-${VERSION}.src/projects/lld mv compiler-rt-${VERSION}.src llvm-${VERSION}.src/projects/compiler-rt mkdir build cd build cmake \ -DLLVM_ENABLE_FFI=ON \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_TARGETS_TO_BUILD="host" \ -DBUILD_SHARED_LIBS=ON \ ../llvm-${VERSION}.src cmake --build . cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}${PREFIX} -P cmake_install.cmake === snap == Any hints? Greetings, Fabiano
If you removed your entire GCC installation (including the runtime libraries and standard library), yeah, I'm not sure that'll work out of the box with Clang - clang does have implementations of some pieces (libc++, for instance - though clang doesn't default to using it (not sure if it'll use it in favor if libstdc++ is missing, or if it'll fail)) I'm not sure all the pieces are there. (I don't know the nuance of the various libgcc_s, compiler-rt, etc, etc) Long story short - keep your GCC installation, install clang, use the CMAKE_C_COMPILER, CMAKE_CXX_COMPILER, etc, flags to specify that you want to use clang instead of gcc as your compiler. On Thu, Sep 5, 2019 at 3:16 AM Fabiano Sidler via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi folks! > > I'm trying to build LLVM with LLVM on Ubuntu using the commands below. > Building it with the GNU stuff (cpp, gcc, g++ and binutils packages) works, > but after removing it, moving LLVM to /usr/local and symlinking /usr/bin/ld > to ld.lld, I'm getting the following: > === snip ==> -- The C compiler identification is Clang 8.0.1 > -- The CXX compiler identification is Clang 8.0.1 > -- The ASM compiler identification is Clang > -- Found assembler: /usr/local/bin/clang > -- Check for working C compiler: /usr/local/bin/clang > -- Check for working C compiler: /usr/local/bin/clang -- broken > CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 > (message): > The C compiler "/usr/local/bin/clang" is not able to compile a simple > test > program. > > It fails with the following output: > > Change Dir: /home/elux/build/CMakeFiles/CMakeTmp > > > > Run Build Command:"/usr/bin/make" "cmTC_a9eab/fast" > > /usr/bin/make -f CMakeFiles/cmTC_a9eab.dir/build.make > CMakeFiles/cmTC_a9eab.dir/build > > make[1]: Entering directory '/home/elux/build/CMakeFiles/CMakeTmp' > > Building C object CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o > > /usr/local/bin/clang -o CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -c > /home/elux/build/CMakeFiles/CMakeTmp/testCCompiler.c > > Linking C executable cmTC_a9eab > > /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9eab.dir/link.txt > --verbose=1 > > /usr/local/bin/clang CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -o > cmTC_a9eab > > ld: error: cannot open crt1.o: No such file or directory > > ld: error: cannot open crti.o: No such file or directory > > ld: error: cannot open crtbegin.o: No such file or directory > > ld: error: unable to find library -lgcc > > ld: error: unable to find library -lgcc_s > > ld: error: unable to find library -lc > > ld: error: unable to find library -lgcc > > ld: error: unable to find library -lgcc_s > > ld: error: cannot open crtend.o: No such file or directory > > ld: error: cannot open crtn.o: No such file or directory > > clang-8: error: linker command failed with exit code 1 (use -v to see > invocation) > > CMakeFiles/cmTC_a9eab.dir/build.make:97: recipe for target 'cmTC_a9eab' > failed > > make[1]: *** [cmTC_a9eab] Error 1 > > make[1]: Leaving directory '/home/elux/build/CMakeFiles/CMakeTmp' > > Makefile:126: recipe for target 'cmTC_a9eab/fast' failed > > make: *** [cmTC_a9eab/fast] Error 2 > > > > > > CMake will not be able to correctly generate this project. > Call Stack (most recent call first): > CMakeLists.txt:39 (project) > > > -- Configuring incomplete, errors occurred! > See also "/home/elux/build/CMakeFiles/CMakeOutput.log". > See also "/home/elux/build/CMakeFiles/CMakeError.log". > === snap ==> > Commands used: > === snip ==> VERSION=8.0.1 > DESTDIR=/tmp/llvm > PREFIX=/usr/local > > #wget > https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/llvm-${VERSION}.src.tar.xz > #wget > <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/llvm-$%7BVERSION%7D.src.tar.xz#wget> > https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/cfe-${VERSION}.src.tar.xz > #wget > <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/cfe-$%7BVERSION%7D.src.tar.xz#wget> > https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxx-${VERSION}.src.tar.xz > #wget > <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/libcxx-$%7BVERSION%7D.src.tar.xz#wget> > https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxxabi-${VERSION}.src.tar.xz > #wget > <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/libcxxabi-$%7BVERSION%7D.src.tar.xz#wget> > https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/lld-${VERSION}.src.tar.xz > #wget > <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/lld-$%7BVERSION%7D.src.tar.xz#wget> > https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/compiler-rt-${VERSION}.src.tar.xz > tar xf llvm-${VERSION}.src.tar.xz > tar xf cfe-${VERSION}.src.tar.xz > tar xf libcxx-${VERSION}.src.tar.xz > tar xf libcxxabi-${VERSION}.src.tar.xz > tar xf lld-${VERSION}.src.tar.xz > tar xf compiler-rt-${VERSION}.src.tar.xz > mv cfe-${VERSION}.src llvm-${VERSION}.src/projects/clang > mv libcxx-${VERSION}.src llvm-${VERSION}.src/projects/libcxx > mv libcxxabi-${VERSION}.src llvm-${VERSION}.src/projects/libcxxabi > mv lld-${VERSION}.src llvm-${VERSION}.src/projects/lld > mv compiler-rt-${VERSION}.src llvm-${VERSION}.src/projects/compiler-rt > mkdir build > cd build > cmake \ > -DLLVM_ENABLE_FFI=ON \ > -DCMAKE_BUILD_TYPE=Release \ > -DLLVM_ENABLE_RTTI=ON \ > -DLLVM_TARGETS_TO_BUILD="host" \ > -DBUILD_SHARED_LIBS=ON \ > ../llvm-${VERSION}.src > cmake --build . > cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}${PREFIX} -P cmake_install.cmake > === snap ==> > Any hints? > > Greetings, > Fabiano > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190905/a381a5be/attachment.html>
On Thu, Sep 5, 2019 at 12:27 PM David Blaikie via llvm-dev < llvm-dev at lists.llvm.org> wrote:> If you removed your entire GCC installation (including the runtime > libraries and standard library), yeah, I'm not sure that'll work out of the > box with Clang - clang does have implementations of some pieces (libc++, > for instance - though clang doesn't default to using it (not sure if it'll > use it in favor if libstdc++ is missing, or if it'll fail)) I'm not sure > all the pieces are there. (I don't know the nuance of the various libgcc_s, > compiler-rt, etc, etc) >Specifically the llvm-project does not yet have a libc, so it doesn't provide crt1.o and friends. To use clang without any gnu facilities you'll need a libc (musl is pretty good) and you'll need to change the driver to use compiler-rt. I think you can look at the freebsd driver for a platform that uses as much llvm as possible. - Michael Spencer> > Long story short - keep your GCC installation, install clang, use the > CMAKE_C_COMPILER, CMAKE_CXX_COMPILER, etc, flags to specify that you want > to use clang instead of gcc as your compiler. > > On Thu, Sep 5, 2019 at 3:16 AM Fabiano Sidler via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi folks! >> >> I'm trying to build LLVM with LLVM on Ubuntu using the commands below. >> Building it with the GNU stuff (cpp, gcc, g++ and binutils packages) >> works, >> but after removing it, moving LLVM to /usr/local and symlinking >> /usr/bin/ld >> to ld.lld, I'm getting the following: >> === snip ==>> -- The C compiler identification is Clang 8.0.1 >> -- The CXX compiler identification is Clang 8.0.1 >> -- The ASM compiler identification is Clang >> -- Found assembler: /usr/local/bin/clang >> -- Check for working C compiler: /usr/local/bin/clang >> -- Check for working C compiler: /usr/local/bin/clang -- broken >> CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 >> (message): >> The C compiler "/usr/local/bin/clang" is not able to compile a simple >> test >> program. >> >> It fails with the following output: >> >> Change Dir: /home/elux/build/CMakeFiles/CMakeTmp >> >> >> >> Run Build Command:"/usr/bin/make" "cmTC_a9eab/fast" >> >> /usr/bin/make -f CMakeFiles/cmTC_a9eab.dir/build.make >> CMakeFiles/cmTC_a9eab.dir/build >> >> make[1]: Entering directory '/home/elux/build/CMakeFiles/CMakeTmp' >> >> Building C object CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o >> >> /usr/local/bin/clang -o CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -c >> /home/elux/build/CMakeFiles/CMakeTmp/testCCompiler.c >> >> Linking C executable cmTC_a9eab >> >> /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9eab.dir/link.txt >> --verbose=1 >> >> /usr/local/bin/clang CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -o >> cmTC_a9eab >> >> ld: error: cannot open crt1.o: No such file or directory >> >> ld: error: cannot open crti.o: No such file or directory >> >> ld: error: cannot open crtbegin.o: No such file or directory >> >> ld: error: unable to find library -lgcc >> >> ld: error: unable to find library -lgcc_s >> >> ld: error: unable to find library -lc >> >> ld: error: unable to find library -lgcc >> >> ld: error: unable to find library -lgcc_s >> >> ld: error: cannot open crtend.o: No such file or directory >> >> ld: error: cannot open crtn.o: No such file or directory >> >> clang-8: error: linker command failed with exit code 1 (use -v to see >> invocation) >> >> CMakeFiles/cmTC_a9eab.dir/build.make:97: recipe for target 'cmTC_a9eab' >> failed >> >> make[1]: *** [cmTC_a9eab] Error 1 >> >> make[1]: Leaving directory '/home/elux/build/CMakeFiles/CMakeTmp' >> >> Makefile:126: recipe for target 'cmTC_a9eab/fast' failed >> >> make: *** [cmTC_a9eab/fast] Error 2 >> >> >> >> >> >> CMake will not be able to correctly generate this project. >> Call Stack (most recent call first): >> CMakeLists.txt:39 (project) >> >> >> -- Configuring incomplete, errors occurred! >> See also "/home/elux/build/CMakeFiles/CMakeOutput.log". >> See also "/home/elux/build/CMakeFiles/CMakeError.log". >> === snap ==>> >> Commands used: >> === snip ==>> VERSION=8.0.1 >> DESTDIR=/tmp/llvm >> PREFIX=/usr/local >> >> #wget >> https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/llvm-${VERSION}.src.tar.xz >> #wget >> <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/llvm-$%7BVERSION%7D.src.tar.xz#wget> >> https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/cfe-${VERSION}.src.tar.xz >> #wget >> <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/cfe-$%7BVERSION%7D.src.tar.xz#wget> >> https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxx-${VERSION}.src.tar.xz >> #wget >> <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/libcxx-$%7BVERSION%7D.src.tar.xz#wget> >> https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxxabi-${VERSION}.src.tar.xz >> #wget >> <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/libcxxabi-$%7BVERSION%7D.src.tar.xz#wget> >> https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/lld-${VERSION}.src.tar.xz >> #wget >> <https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/lld-$%7BVERSION%7D.src.tar.xz#wget> >> https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/compiler-rt-${VERSION}.src.tar.xz >> tar xf llvm-${VERSION}.src.tar.xz >> tar xf cfe-${VERSION}.src.tar.xz >> tar xf libcxx-${VERSION}.src.tar.xz >> tar xf libcxxabi-${VERSION}.src.tar.xz >> tar xf lld-${VERSION}.src.tar.xz >> tar xf compiler-rt-${VERSION}.src.tar.xz >> mv cfe-${VERSION}.src llvm-${VERSION}.src/projects/clang >> mv libcxx-${VERSION}.src llvm-${VERSION}.src/projects/libcxx >> mv libcxxabi-${VERSION}.src llvm-${VERSION}.src/projects/libcxxabi >> mv lld-${VERSION}.src llvm-${VERSION}.src/projects/lld >> mv compiler-rt-${VERSION}.src llvm-${VERSION}.src/projects/compiler-rt >> mkdir build >> cd build >> cmake \ >> -DLLVM_ENABLE_FFI=ON \ >> -DCMAKE_BUILD_TYPE=Release \ >> -DLLVM_ENABLE_RTTI=ON \ >> -DLLVM_TARGETS_TO_BUILD="host" \ >> -DBUILD_SHARED_LIBS=ON \ >> ../llvm-${VERSION}.src >> cmake --build . >> cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}${PREFIX} -P cmake_install.cmake >> === snap ==>> >> Any hints? >> >> Greetings, >> Fabiano >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190905/0fc8e73f/attachment.html>
Thus wrote David Blaikie:> If you removed your entire GCC installation (including the runtime > libraries and standard library), yeah, I'm not sure that'll work out of the > box with Clang - clang does have implementations of some pieces (libc++, > for instance - though clang doesn't default to using it (not sure if it'll > use it in favor if libstdc++ is missing, or if it'll fail)) I'm not sure > all the pieces are there. (I don't know the nuance of the various libgcc_s, > compiler-rt, etc, etc)I'm at that point now. I'v successfully built LLVM9 (including compiler-rt and libcxx{,abi}, but I still can't build LLVM9 without GNU's libstdc++ because configuring without it fails with: ld: error: unable to find library -lstdc++ Anyone knows how to enforce the use of LLVM's libcxx? Greetings Fabiano