[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

Brian Rzycki via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 09:11:56 PDT 2019


brzycki added a comment.

Hello @smeenai , this commit causes LLVM to fail to build when set set `-D BUILD_SHARED_LIBS=ON`. Here is the failing CMake and Ninja invocation:

  /tools/build/cmake-3.14.5/bin/cmake \
      -G Ninja  \
      -D CMAKE_MAKE_PROGRAM=/tools/build/ninja-1.9.0/ninja \
      -D CMAKE_C_COMPILER=/usr/lib/llvm-7/bin/clang \
      -D CMAKE_CXX_COMPILER=/usr/lib/llvm-7/bin/clang++ \
      -D CMAKE_BUILD_TYPE=Release \
      -D CMAKE_INSTALL_PREFIX=/work/upstream/install \
      -D LLVM_TOOL_CLANG_BUILD=ON \
      -D LIBCXX_INCLUDE_BENCHMARKS=ON \
      -D BUILD_SHARED_LIBS=ON \
      -D LLVM_ENABLE_ASSERTIONS=ON \
      -D LLVM_TARGETS_TO_BUILD=X86 \
      /work/upstream/llvm-project/llvm
  
  /tools/build/ninja-1.9.0/ninja -v install

I am able to successfully build LLVM when I change to `-D BUILD_SHARED_LIBS=OFF`.

The outputted errors happen during link time of `lib/libclang_shared.so.9svn`:

  FAILED: lib/libclang_shared.so.9svn
  
  ...
  
  tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenModule.cpp.o: In function `llvm::cl::opt<bool, false, llvm::cl::parser<bool> >::~opt()':
  CodeGenModule.cpp:(.text._ZN4llvm2cl3optIbLb0ENS0_6parserIbEEED2Ev[_ZN4llvm2cl3optIbLb0ENS0_6parserIbEEED2Ev]+0x7): undefined reference to `vtable for llvm::cl::Option'
  tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenModule.cpp.o: In function `clang::CodeGen::CodeGenModule::CodeGenModule(clang::ASTContext&, clang::HeaderSearchOptions const&, clang::PreprocessorOptions const&, clang::CodeGenOptions const&, llvm::Module&, clang::DiagnosticsEngine&, clang::CoverageSourceInfo*)':
  CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x57a): undefined reference to `llvm::FoldingSetBase::FoldingSetBase(unsigned int)'
  CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x5cc): undefined reference to `llvm::Type::getVoidTy(llvm::LLVMContext&)'
  CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x5d7): undefined reference to `llvm::Type::getInt8Ty(llvm::LLVMContext&)'
  CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x5e3): undefined reference to `llvm::Type::getInt16Ty(llvm::LLVMContext&)'
  
  ... (clipped thousands of similar errors)
  
  WhitespaceManager.cpp:(.text._ZN5clang6formatL18AlignTokenSequenceIRZNS0_17WhitespaceManager28alignConsecutiveDeclarationsEvE3$_2EEvjjjOT_RN4llvm11SmallVectorINS2_6ChangeELj16EEE+0x129): undefined reference to `llvm::SmallVectorBase::grow_pod(void*, unsigned long, unsigned long)'
  tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o: In function `clang_fuzzer::HandleCXX(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<char const*, std::allocator<char const*> > const&)':
  handle_cxx.cpp:(.text._ZN12clang_fuzzer9HandleCXXERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIPKcSaISA_EE+0x67): undefined reference to `llvm::SmallVectorBase::grow_pod(void*, unsigned long, unsigned long)'
  handle_cxx.cpp:(.text._ZN12clang_fuzzer9HandleCXXERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIPKcSaISA_EE+0x32b): undefined reference to `llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, llvm::StringRef, bool)'
  handle_cxx.cpp:(.text._ZN12clang_fuzzer9HandleCXXERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIPKcSaISA_EE+0x669): undefined reference to `llvm::SmallVectorBase::grow_pod(void*, unsigned long, unsigned long)'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579





More information about the cfe-commits mailing list