$ /usr/bin/ninja -C build clang
ninja: Entering directory `build'
[455/4865] Linking CXX shared library lib/libLLVMRemarks.so.23.0git
FAILED: lib/libLLVMRemarks.so.23.0git
: && /usr/bin/clang++-15 -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Xclang -fno-pch-timestamp -g -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -shared -Wl,-soname,libLLVMRemarks.so.23.0git -o lib/libLLVMRemarks.so.23.0git lib/Remarks/CMakeFiles/LLVMRemarks.dir/BitstreamRemarkParser.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/BitstreamRemarkSerializer.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/Remark.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/RemarkFormat.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/RemarkLinker.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/RemarkParser.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/RemarkSerializer.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/RemarkStreamer.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/RemarkStringTable.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/YAMLRemarkParser.cpp.o lib/Remarks/CMakeFiles/LLVMRemarks.dir/YAMLRemarkSerializer.cpp.o -Wl,-rpath,"\$ORIGIN/../lib:~/swift-llvm/llvm-project/build/lib:" lib/libLLVMBitstreamReader.so.23.0git lib/libLLVMSupport.so.23.0git -Wl,-rpath-link,~/swift-llvm/llvm-project/build/lib && :
ld.lld: error: undefined symbol: llvm::MDString::getString() const
>>> referenced by ExtraOptRemarks.cpp:32 (~/swift-llvm/llvm-project/llvm/lib/Remarks/ExtraOptRemarks.cpp:32)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::isBoundsSafetyAnnotated(llvm::Instruction*))
>>> referenced by ExtraOptRemarks.cpp:35 (~/swift-llvm/llvm-project/llvm/lib/Remarks/ExtraOptRemarks.cpp:35)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::isBoundsSafetyAnnotated(llvm::Instruction*))
ld.lld: error: undefined symbol: llvm::Instruction::addAnnotationMetadata(llvm::SmallVector<llvm::StringRef, 3u>)
>>> referenced by BoundsSafetyOptRemarks.def:32 (~/swift-llvm/llvm-project/llvm/include/llvm/Remarks/BoundsSafetyOptRemarks.def:32)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::annotate(llvm::Instruction*, BoundsSafetyOptRemarkKind))
>>> referenced by BoundsSafetyOptRemarks.def:39 (~/swift-llvm/llvm-project/llvm/include/llvm/Remarks/BoundsSafetyOptRemarks.def:39)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::annotate(llvm::Instruction*, BoundsSafetyOptRemarkKind))
>>> referenced by BoundsSafetyOptRemarks.def:46 (~/swift-llvm/llvm-project/llvm/include/llvm/Remarks/BoundsSafetyOptRemarks.def:46)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::annotate(llvm::Instruction*, BoundsSafetyOptRemarkKind))
>>> referenced 1 more times
ld.lld: error: undefined symbol: llvm::Value::getMetadataImpl(unsigned int) const
>>> referenced by Value.h:579 (~/swift-llvm/llvm-project/llvm/include/llvm/IR/Value.h:579)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::Value::getMetadata(unsigned int) const)
ld.lld: error: undefined symbol: llvm::Value::assertModuleIsMaterializedImpl() const
>>> referenced by Value.h:339 (~/swift-llvm/llvm-project/llvm/include/llvm/IR/Value.h:339)
>>> lib/Remarks/CMakeFiles/LLVMRemarks.dir/ExtraOptRemarks.cpp.o:(llvm::Value::assertModuleIsMaterialized() const)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Seems like this is a diversion from the upstream repo which supports building non-static targets and link against them.
While trying to build Clang with
BUILD_SHARED_LIBS=ONit gives the following linking error withlld:Seems like this is a diversion from the upstream repo which supports building non-static targets and link against them.
Sources:
BUILD_SHARED_LIBSsection)