Hello,
I’m using cmake (3.16.5) to build the LLVM (v8) environment from source. However, the command
cmake -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;libcxx;libunwind;lldb;compiler-rt;lld” -G “Unix Makefiles” -DCMAKE_BUILD_TYPE=Release …
is returning the error message:>
Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WTHREAD_SAFETY failed with the following output:
Change Dir: /home/odyhpc/llvm-8.0.0.src/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_cbe17/fast && /usr/bin/make -f CMakeFiles/cmTC_cbe17.dir/build.make CMakeFiles/cmTC_cbe17.dir/build
make[1]: Entering directory ‘/home/odyhpc/llvm-8.0.0.src/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_cbe17.dir/src.cxx.o
/usr/bin/c++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -std=c++11 -Wall -Wextra -Wshadow -pedantic -pedantic-errors -Wfloat-equal -fstrict-aliasing -fno-exceptions -Wstrict-aliasing -DHAVE_CXX_FLAG_WTHREAD_SAFETY -Wthread-safety -Wthread-safety -o CMakeFiles/cmTC_cbe17.dir/src.cxx.o -c /home/odyhpc/llvm-8.0.0.src/build/CMakeFiles/CMakeTmp/src.cxx
c++: error: unrecognized command line option ‘-Wthread-safety’; did you mean ‘-fthread-jumps’?
c++: error: unrecognized command line option ‘-Wthread-safety’; did you mean ‘-fthread-jumps’?
CMakeFiles/cmTC_cbe17.dir/build.make:65: recipe for target ‘CMakeFiles/cmTC_cbe17.dir/src.cxx.o’ failed
make[1]: *** [CMakeFiles/cmTC_cbe17.dir/src.cxx.o] Error 1
make[1]: Leaving directory ‘/home/odyhpc/llvm-8.0.0.src/build/CMakeFiles/CMakeTmp’
Makefile:121: recipe for target ‘cmTC_cbe17/fast’ failed
make: *** [cmTC_cbe17/fast] Error 2
I don’t understand why of the error or how to fix it. Thank you.
I don’t expect this to be a fatal error, also is this what you get when running CMake or did you look into CMakeFiles/CMakeError.log
? Errors like this are expected in this file.
I am facing this error too, but during execution of make instead of cmake.
c++: error: unrecognized command line option ‘-Wimplicit-fallthrough’; did you mean ‘-Wno-fallthrough’?
tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/build.make:82: recipe for target ‘tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/call.cpp.o’ failed
make[2]: *** [tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/call.cpp.o] Error 1
CMakeFiles/Makefile2:155906: recipe for target ‘tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/all’ failed
make[1]: *** [tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/all] Error 2
My environment is WSL(Windows Subsystem For Linux, with a debian inside it). I was able to build and install from source, but then I realized that though some tools like lli and so got installed, clang itself was not. Now in my second attempt I am using the following command to configure my build, only to run into this error again and again:-
cmake -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;compiler-rt;flang;lld;lldb;mlir” -G “Unix Makefiles” …/llvm
Please let me know if I can help with more info. Since I am a beginner I may not be producing al the info that is needed.
The build is terminating, which makes me assume that its fatal.
This is an issue with flang which is setting up flags explicitly:
flang/CMakeLists.txt:set(CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions -pedantic -Wall -Wextra -Werror -Wcast-qual -Wimplicit-fallthrough -Wdelete-non-virtual-dtor ${CMAKE_CXX_FLAGS}")
(so disabling flang will fix it)
Thanks a lot, and sure it did. Now I tried the following command to cmake my build.
cmake -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;compiler-rt;lld;lldb;mlir” -G “Unix Makefiles” …/llvm
When I ran make -j8, after 91% completion and after ~4 hours on my laptop, it gives following:-
[ 91%] Linking CXX executable …/…/bin/dsymutil
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
tools/bugpoint/CMakeFiles/bugpoint.dir/build.make:347: recipe for target ‘bin/bugpoint’ failed
make[2]: *** [bin/bugpoint] Error 1
make[2]: *** Deleting file ‘bin/bugpoint’
tools/dsymutil/CMakeFiles/dsymutil.dir/build.make:315: recipe for target ‘bin/dsymutil’ failed
make[2]: *** [bin/dsymutil] Error 1
make[2]: *** Deleting file ‘bin/dsymutil’
CMakeFiles/Makefile2:155048: recipe for target ‘tools/bugpoint/CMakeFiles/bugpoint.dir/all’ failed
make[1]: *** [tools/bugpoint/CMakeFiles/bugpoint.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
CMakeFiles/Makefile2:155254: recipe for target ‘tools/dsymutil/CMakeFiles/dsymutil.dir/all’ failed
make[1]: *** [tools/dsymutil/CMakeFiles/dsymutil.dir/all] Error 2
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.28 internal error, aborting at …/…/bfd/merge.c:904 in _bfd_merged_section_offset
/usr/bin/ld: Please report this bug.
collect2: error: ld returned 1 exit status
tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/build.make:427: recipe for target ‘bin/llvm-c-test’ failed
make[2]: *** [bin/llvm-c-test] Error 1
make[2]: *** Deleting file ‘bin/llvm-c-test’
CMakeFiles/Makefile2:156076: recipe for target ‘tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/all’ failed
make[1]: *** [tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/all] Error 2
[ 91%] Built target clang-cpp
[ 91%] Built target llc
[ 91%] Built target clang-check
[ 91%] Built target clang
collect2: error: ld returned 1 exit status
tools/clang/tools/libclang/CMakeFiles/libclang.dir/build.make:607: recipe for target ‘lib/libclang.so.11’ failed
make[2]: *** [lib/libclang.so.11] Error 1
CMakeFiles/Makefile2:69464: recipe for target ‘tools/clang/tools/libclang/CMakeFiles/libclang.dir/all’ failed
make[1]: *** [tools/clang/tools/libclang/CMakeFiles/libclang.dir/all] Error 2
Makefile:171: recipe for target ‘all’ failed
make: *** [all] Error 2
Can you please guide me here as to what should I do, which may be helpful as its asking to report the bug .
I will try and stick to building llvm only with clang enabled, as I am an absolute beginner, and would like to get past installation of llvm tools also with clang, so that I can start exploring the documentation and follow along.
Usually the link stage may fail because you ran out of memory on the system, but I’m not sure it is the case here as it failed with a segmentation fault instead of being killed by the kernel.
How much memory do you have?
Also you’re building in Debug mode which can create pretty large object file, you may want to try: cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;compiler-rt;lld;lldb;mlir” -G “Unix Makefiles” …/llvm
Also, if possible install lld
(or gold
) as a linker, and ninja as a build system (apt-get install ninja-build lld
on Ubuntu I think) and then configure with: cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;compiler-rt;lld;lldb;mlir” -GNinja -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_ENABLE_LLD=ON …/llvm
and build with running ninja
.
@mehdi_amini Thanks a lot.
I dropped the plan for now to build enabling all projects, and just went ahead with clang and clang-tools-extra, and at least it built successfully and installed as well. About other projects, may be I will try and run again when I gain some understanding around things. Being unaware I think I should not have gone after building everything upfront. Compiler , the area itself, is not that familiar to me. I am aiming at discovering and training myself with the help of llvm. Just out of curiosity, I had created a “build” folder and I built stuff in that, and now when I look at it after building and installing, it seems 87G is the size occupied by this build folder, and having to try and build all projects at once not sure would have craved for how much more space. Something which left me puzzled, and then I realized that I should do it with patience and guidance. Going after everything at once anyways is not advisable.
By the way, I have a Windows and running WSL with a Debian in it, ~200GB of hard disk and 16GB of RAM. Should be sufficient to take up things , or would you like to suggest some other configuration to try out and build llvm knowledge upon. Like more hard disk, RAM etc?