llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.25k stars 12.07k forks source link

clang's -nodefaultlibs breaks XRay instrumentation #39925

Open LebedevRI opened 5 years ago

LebedevRI commented 5 years ago
Bugzilla Link 40579
Version unspecified
OS Linux
CC @dwblaikie

Extended Description

I have just tried to build LLVM with xray instrumentation, and it fails with

CMake Warning at /build/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake:52 (message): Host compiler appears to require libatomic, but cannot find it. Call Stack (most recent call first): /build/libcxx/cmake/config-ix.cmake:63 (include) /build/libcxx/CMakeLists.txt:471 (include)

CMake Error at /build/libcxx/CMakeLists.txt:526 (message): C++11 or greater is required but the compiler does not support c++11

Configuring incomplete, errors occurred!

I have digged, and:

$ cat /tmp/test.cpp int main(int argc, char* argv[]) { return 0; } $ clang++ -fxray-instrument -fxray-instruction-threshold=0 -nodefaultlibs /tmp/test.cpp ld: error: undefined symbol: __libc_csu_fini

referenced by /usr/lib64/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o:(_start)

ld: error: undefined symbol: __libc_csu_init

referenced by /usr/lib64/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o:(_start)

ld: error: undefined symbol: __libc_start_main

referenced by /usr/lib64/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o:(_start)

ld: error: undefined symbol: __errno_location

referenced by sanitizer_allocator_checks.cc.o:(__sanitizer::SetErrnoToENOMEM()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: sigaction

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::internal_sigaction(int, void const, void)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: getrlimit

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long, unsigned long)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: pthread_attr_init

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long, unsigned long)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: pthread_self

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long, unsigned long)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: pthread_getattr_np

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long, unsigned long)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: pthread_attr_destroy

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long, unsigned long)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: dlsym

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::SetEnv(char const, char const)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: dlsym

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::InitTlsSize()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: confstr

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::ThreadDescriptorSize()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: dl_iterate_phdr

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::ListOfModules::init()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: getrusage

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetRSS()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: sched_getaffinity

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetNumberOfCPUs()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: __sched_cpucount

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetNumberOfCPUs()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: syslog

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::WriteOneLineToSyslog(char const*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: clock_gettime

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::MonotonicNanoTime()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: undefined symbol: getauxval

referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::ReExec()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors) clang: error: linker command failed with exit code 1 (use -v to see invocation) $ clang++ -fxray-instrument -fxray-instruction-threshold=0 /tmp/test.cpp $ # so it is -nodefaultlibs that is the culprit.

llvmbot commented 5 years ago

I'm not sure what -nodefault is supposed to do, but the XRay runtime does depend on pthreads on Unix/Linux/POSIX systems. Maybe adding just the pthreads dependency to the XRay parts should work?

LebedevRI commented 5 years ago

Maybe disabling BUILD_SHARED_LIBS will help..

And it did, weird.

LebedevRI commented 5 years ago

Removing libcxx from the list of projects to build helped. (left llvm itself only) But even then, the build fails:

[1/932] Linking CXX shared library lib/libLLVMSupport.so.9svn FAILED: lib/libLLVMSupport.so.9svn : && /usr/local/bin/clang++ -fPIC -pipe -O3 -g0 -UNDEBUG -gline-tables-only -fxray-instrument -fxray-instruction-threshold=0 -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -pipe -O3 -g0 -UNDEBUG -gline-tables-only -fxray-instrument -fxray-instruction-threshold=0 -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libLLVMSupport.so.9svn -o lib/libLLVMSupport.so.9svn lib/Support/CMakeFiles/LLVMSupport.dir/AArch64TargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMTargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/AMDGPUMetadata.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APInt.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APSInt.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMBuildAttrs.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMAttributeParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Allocator.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamError.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamReader.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamRef.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamWriter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BlockFrequency.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BranchProbability.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BuryPointer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CachePruning.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/circular_raw_ostream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Chrono.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/COM.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CodeGenCoverage.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Compression.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTFWrapper.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CrashRecoveryContext.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DataExtractor.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Debug.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DebugCounter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DeltaAlgorithm.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DAGDeltaAlgorithm.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DJB.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Error.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ErrorHandling.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FileCheck.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FileUtilities.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FileOutputBuffer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FoldingSet.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FormattedStream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FormatVariadic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/GlobPattern.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/GraphWriter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Hashing.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/InitLLVM.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/IntEqClasses.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ItaniumManglingCanonicalizer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/JamCRC.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/JSON.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/KnownBits.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LEB128.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LineIterator.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Locale.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LockFileManager.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LowLevelType.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ManagedStatic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MathExtras.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MemoryBuffer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MD5.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/NativeFormatting.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Optional.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Options.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Parallel.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/PrettyStackTrace.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/RandomNumberGenerator.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Regex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ScaledNumber.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ScopedPrinter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SHA1.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SmallPtrSet.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SmallVector.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SpecialCaseList.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Statistic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringExtras.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringMap.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringPool.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringSaver.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringRef.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SymbolRemappingReader.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SystemUtils.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TarWriter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ToolOutputFile.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TrigramIndex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Twine.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Unicode.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/UnicodeCaseFold.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/VersionTuple.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/VirtualFileSystem.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/WithColor.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/YAMLParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/raw_os_ostream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/raw_ostream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regerror.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regexec.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regfree.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regstrlcpy.c.o lib/Support/CMakeFiles/LLVMSupport.dir/xxhash.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Atomic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Errno.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Host.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Memory.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Mutex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Path.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TargetRegistry.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ThreadLocal.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Threading.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Valgrind.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Watchdog.cpp.o -Wl,-rpath,"\$ORIGIN/../lib" -lz -lrt -ldl -ltinfo -lm lib/libLLVMDemangle.so.9svn && : ld.lld: error: undefined symbol: pthread_once

referenced by gthr-default.h:699 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:699) lib/Support/CMakeFiles/LLVMSupport.dir/ManagedStatic.cpp.o:(llvm::ManagedStaticBase::RegisterManagedStatic(void ()(), void ()(void)) const)

ld.lld: error: undefined symbol: pthread_once

referenced by gthr-default.h:699 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:699) lib/Support/CMakeFiles/LLVMSupport.dir/ManagedStatic.cpp.o:(llvm::llvm_shutdown())

ld.lld: error: undefined symbol: pthread_create

referenced by thread:131 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/thread:131) lib/Support/CMakeFiles/LLVMSupport.dir/Parallel.cpp.o:(llvm::parallel::detail::TaskGroup::spawn(std::function<void ()>))

ld.lld: error: undefined symbol: pthread_create

referenced by Parallel.cpp:0 (/build/llvm/lib/Support/Parallel.cpp:0) lib/Support/CMakeFiles/LLVMSupport.dir/Parallel.cpp.o:(std::thread::_State_impl<std::thread::_Invoker<std::tuple<(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(unsigned int)::'lambda'()> > >::_M_run())

ld.lld: error: undefined symbol: pthread_create

referenced by thread:131 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/thread:131) lib/Support/CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o:(llvm::ThreadPool::ThreadPool(unsigned int))

ld.lld: error: undefined symbol: pthread_create

referenced by thread:131 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/thread:131) lib/Support/CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o:(llvm::ThreadPool::ThreadPool(unsigned int))

ld.lld: error: undefined symbol: pthread_once

referenced by gthr-default.h:699 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:699) lib/Support/CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o:(std::__future_base::_Task_state<std::function<void ()>, std::allocator, void ()>::_M_run())

ld.lld: error: undefined symbol: pthread_once

referenced by gthr-default.h:699 (/usr/lib64/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:699) lib/Support/CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o:(std::future_base::_State_baseV2::_M_set_delayed_result(std::function<std::unique_ptr<std::future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, std::weak_ptr))

ld.lld: error: undefined symbol: pthread_mutexattr_init

referenced by Mutex.cpp:54 (/build/llvm/lib/Support/Mutex.cpp:54) lib/Support/CMakeFiles/LLVMSupport.dir/Mutex.cpp.o:(llvm::sys::MutexImpl::MutexImpl(bool))

ld.lld: error: undefined symbol: pthread_mutexattr_settype

referenced by Mutex.cpp:60 (/build/llvm/lib/Support/Mutex.cpp:60) lib/Support/CMakeFiles/LLVMSupport.dir/Mutex.cpp.o:(llvm::sys::MutexImpl::MutexImpl(bool))

ld.lld: error: undefined symbol: pthread_mutexattr_destroy

referenced by Mutex.cpp:68 (/build/llvm/lib/Support/Mutex.cpp:68) lib/Support/CMakeFiles/LLVMSupport.dir/Mutex.cpp.o:(llvm::sys::MutexImpl::MutexImpl(bool))

ld.lld: error: undefined symbol: pthread_mutex_trylock

referenced by Mutex.cpp:110 (/build/llvm/lib/Support/Mutex.cpp:110) lib/Support/CMakeFiles/LLVMSupport.dir/Mutex.cpp.o:(llvm::sys::MutexImpl::tryacquire())

ld.lld: error: undefined symbol: pthread_sigmask

referenced by Process.inc:236 (/build/llvm/lib/Support/Unix/Process.inc:236) lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o:(llvm::sys::Process::SafelyCloseFileDescriptor(int))

ld.lld: error: undefined symbol: pthread_sigmask

referenced by Process.inc:251 (/build/llvm/lib/Support/Unix/Process.inc:251) lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o:(llvm::sys::Process::SafelyCloseFileDescriptor(int))

ld.lld: error: undefined symbol: pthread_rwlock_init

referenced by RWMutex.cpp:60 (/build/llvm/lib/Support/RWMutex.cpp:60) lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o:(llvm::sys::RWMutexImpl::RWMutexImpl())

ld.lld: error: undefined symbol: pthread_rwlock_destroy

referenced by RWMutex.cpp:73 (/build/llvm/lib/Support/RWMutex.cpp:73) lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o:(llvm::sys::RWMutexImpl::~RWMutexImpl())

ld.lld: error: undefined symbol: pthread_rwlock_rdlock

referenced by RWMutex.cpp:83 (/build/llvm/lib/Support/RWMutex.cpp:83) lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o:(llvm::sys::RWMutexImpl::reader_acquire())

ld.lld: error: undefined symbol: pthread_rwlock_unlock

referenced by RWMutex.cpp:93 (/build/llvm/lib/Support/RWMutex.cpp:93) lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o:(llvm::sys::RWMutexImpl::reader_release())

ld.lld: error: undefined symbol: pthread_rwlock_wrlock

referenced by RWMutex.cpp:103 (/build/llvm/lib/Support/RWMutex.cpp:103) lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o:(llvm::sys::RWMutexImpl::writer_acquire())

ld.lld: error: undefined symbol: pthread_rwlock_unlock

referenced by RWMutex.cpp:113 (/build/llvm/lib/Support/RWMutex.cpp:113) lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o:(llvm::sys::RWMutexImpl::writer_release())

ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors) clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.

Maybe disabling BUILD_SHARED_LIBS will help..

LebedevRI commented 5 years ago

Hmm, and all the sanitizers are also not working if -nodefaultlibs is present. Is that the expected behavior? If so, how to sanitize such code? (including LLVM, due to libcxx)