<div dir="ltr">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)<br><br>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.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 5, 2019 at 3:16 AM Fabiano Sidler via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi folks!<br>
<br>
I'm trying to build LLVM with LLVM on Ubuntu using the commands below.<br>
Building it with the GNU stuff (cpp, gcc, g++ and binutils packages) works,<br>
but after removing it, moving LLVM to /usr/local and symlinking /usr/bin/ld<br>
to ld.lld, I'm getting the following:<br>
=== snip ===<br>
-- The C compiler identification is Clang 8.0.1<br>
-- The CXX compiler identification is Clang 8.0.1<br>
-- The ASM compiler identification is Clang<br>
-- Found assembler: /usr/local/bin/clang<br>
-- Check for working C compiler: /usr/local/bin/clang<br>
-- Check for working C compiler: /usr/local/bin/clang -- broken<br>
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):<br>
  The C compiler "/usr/local/bin/clang" is not able to compile a simple test<br>
  program.<br>
<br>
  It fails with the following output:<br>
<br>
   Change Dir: /home/elux/build/CMakeFiles/CMakeTmp<br>
<br>
<br>
<br>
  Run Build Command:"/usr/bin/make" "cmTC_a9eab/fast"<br>
<br>
  /usr/bin/make -f CMakeFiles/cmTC_a9eab.dir/build.make<br>
  CMakeFiles/cmTC_a9eab.dir/build<br>
<br>
  make[1]: Entering directory '/home/elux/build/CMakeFiles/CMakeTmp'<br>
<br>
  Building C object CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o<br>
<br>
  /usr/local/bin/clang -o CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -c<br>
  /home/elux/build/CMakeFiles/CMakeTmp/testCCompiler.c<br>
<br>
  Linking C executable cmTC_a9eab<br>
<br>
  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9eab.dir/link.txt<br>
  --verbose=1<br>
<br>
  /usr/local/bin/clang CMakeFiles/cmTC_a9eab.dir/testCCompiler.c.o -o<br>
  cmTC_a9eab<br>
<br>
  ld: error: cannot open crt1.o: No such file or directory<br>
<br>
  ld: error: cannot open crti.o: No such file or directory<br>
<br>
  ld: error: cannot open crtbegin.o: No such file or directory<br>
<br>
  ld: error: unable to find library -lgcc<br>
<br>
  ld: error: unable to find library -lgcc_s<br>
<br>
  ld: error: unable to find library -lc<br>
<br>
  ld: error: unable to find library -lgcc<br>
<br>
  ld: error: unable to find library -lgcc_s<br>
<br>
  ld: error: cannot open crtend.o: No such file or directory<br>
<br>
  ld: error: cannot open crtn.o: No such file or directory<br>
<br>
  clang-8: error: linker command failed with exit code 1 (use -v to see<br>
  invocation)<br>
<br>
  CMakeFiles/cmTC_a9eab.dir/build.make:97: recipe for target 'cmTC_a9eab'<br>
  failed<br>
<br>
  make[1]: *** [cmTC_a9eab] Error 1<br>
<br>
  make[1]: Leaving directory '/home/elux/build/CMakeFiles/CMakeTmp'<br>
<br>
  Makefile:126: recipe for target 'cmTC_a9eab/fast' failed<br>
<br>
  make: *** [cmTC_a9eab/fast] Error 2<br>
<br>
<br>
<br>
<br>
<br>
  CMake will not be able to correctly generate this project.<br>
Call Stack (most recent call first):<br>
  CMakeLists.txt:39 (project)<br>
<br>
<br>
-- Configuring incomplete, errors occurred!<br>
See also "/home/elux/build/CMakeFiles/CMakeOutput.log".<br>
See also "/home/elux/build/CMakeFiles/CMakeError.log".<br>
=== snap ===<br>
<br>
Commands used:<br>
=== snip ===<br>
VERSION=8.0.1<br>
DESTDIR=/tmp/llvm<br>
PREFIX=/usr/local<br>
<br>
#wget <a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/llvm-$%7BVERSION%7D.src.tar.xz#wget" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/llvm-${VERSION}.src.tar.xz<br>
#wget</a> <a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/cfe-$%7BVERSION%7D.src.tar.xz#wget" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/cfe-${VERSION}.src.tar.xz<br>
#wget</a> <a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/libcxx-$%7BVERSION%7D.src.tar.xz#wget" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxx-${VERSION}.src.tar.xz<br>
#wget</a> <a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/libcxxabi-$%7BVERSION%7D.src.tar.xz#wget" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/libcxxabi-${VERSION}.src.tar.xz<br>
#wget</a> <a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/lld-$%7BVERSION%7D.src.tar.xz#wget" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/lld-${VERSION}.src.tar.xz<br>
#wget</a> <a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-$%7BVERSION%7D/compiler-rt-$%7BVERSION%7D.src.tar.xz" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/releases/download/llvmorg-${VERSION}/compiler-rt-${VERSION}.src.tar.xz</a><br>
tar xf llvm-${VERSION}.src.tar.xz<br>
tar xf cfe-${VERSION}.src.tar.xz<br>
tar xf libcxx-${VERSION}.src.tar.xz<br>
tar xf libcxxabi-${VERSION}.src.tar.xz<br>
tar xf lld-${VERSION}.src.tar.xz<br>
tar xf compiler-rt-${VERSION}.src.tar.xz<br>
mv cfe-${VERSION}.src         llvm-${VERSION}.src/projects/clang<br>
mv libcxx-${VERSION}.src      llvm-${VERSION}.src/projects/libcxx<br>
mv libcxxabi-${VERSION}.src   llvm-${VERSION}.src/projects/libcxxabi<br>
mv lld-${VERSION}.src         llvm-${VERSION}.src/projects/lld<br>
mv compiler-rt-${VERSION}.src llvm-${VERSION}.src/projects/compiler-rt<br>
mkdir build<br>
cd build<br>
cmake \<br>
  -DLLVM_ENABLE_FFI=ON \<br>
  -DCMAKE_BUILD_TYPE=Release \<br>
  -DLLVM_ENABLE_RTTI=ON \<br>
  -DLLVM_TARGETS_TO_BUILD="host" \<br>
  -DBUILD_SHARED_LIBS=ON \<br>
  ../llvm-${VERSION}.src<br>
cmake --build .<br>
cmake -DCMAKE_INSTALL_PREFIX=${DESTDIR}${PREFIX} -P cmake_install.cmake<br>
=== snap ===<br>
<br>
Any hints?<br>
<br>
Greetings,<br>
Fabiano<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>