[CMake] cmake build of LLVM: HAVE_CXX_ATOMICS_WITHOUT_LIB test failure

SC Warrior bhhjkl at gmail.com
Wed Apr 10 20:08:45 EDT 2019


I watched Chris Bieneman's talk
<https://www.youtube.com/watch?v=StF77Cx7pz8> about the transition of LLVM
from autoconf to cmake and he raved about how friendly / vibrant the cmake
community is so I thought I'd ask this here.  I posted it to stack overflow
but it's fairly involved so I hope it's cool that I post (my first) in this
forum.

I'm getting this failure trying to cross compile LLVM v3.7 (linux x64 ->
Aarch64) w/ cmake:

<path to clang>/clang++  -DHAVE_CXX_ATOMICS_WITHOUT_LIB -std=c++11
-rdynamic CMakeFiles/cmTC_82a21.dir/src.cxx.o  -o cmTC_82a21  -lm -ldl
&& :
ld.lld: error: undefined symbol: pthread_once
referenced by cxa_exception_storage.cpp

this is then followed by numerous other "undefined symbol: pthread_blah"
errors in the CMakeError.log file.

I have four questions:

(1) What is this phase of operation that cmake is performing to determine
the capabilities of the build environment / platform called ? (i.e. the
configure-like phase that performs numerous small compilation tests to see
if they succeed, looks to see if it can find header files in expected
paths, etc).

(2) It looks to me that including -lpthread as part of the test compilation
line would fix this problem. (a) Is there a way to tell cmake to do that
and (b) is that a smart approach to solving this problem ? Seems like if I
could tell cmake to do this it would pass these tests.

(3) The cmake command *seems* to succeed as it finishes with "Build files
have been written to ...". What should I make of that when one of these
pre-tests has a failure condition as cited above and reports "Configuring
incomplete, errors occurred!".

(4) I'm trying to get this cmake cross compile build to work with the stock
LLVM v3.7 cmake files so I'm trying to control cmake using command line
options only. This gets a little ugly and I'm wondering if there's a simple
way to put all of these settings in a cmake file instead. One problem with
that approach is that I'm not familiar with all of the targets in LLVM so
if I were, to say, attempt to add libraries to targets to fix a linking
problem, I wouldn't know offhand what targets to add them to. I'm hoping
that in this case I can hit it with a bigger hammer and have them added
everywhere with hopes of them being ignored if not used.

I gratefully thank you for your patience and time reading all of that ^^^.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190410/f4837f2e/attachment.html>


More information about the CMake mailing list