[X86] Fix -DBUILD_SHARED_LIBS=on builds after D69568/llvmorg-10-init-8877-g3a399c09878
authorFangrui Song <maskray@google.com>
Fri, 1 Nov 2019 16:45:27 +0000 (09:45 -0700)
committerFangrui Song <maskray@google.com>
Fri, 1 Nov 2019 16:51:17 +0000 (09:51 -0700)
In -DBUILD_SHARED_LIBS=on builds, a component must specify its direct dependencies to satisfy -Wl,-z,defs (added by llvm/modules/HandleLLVMOptions.cmake).

Core is a direct dependency via transitive header inclusion:

  ld.lld: error: undefined symbol: llvm::LLVMContext::LLVMContext()
  >>> referenced by MachineSizeOptsTest.cpp
  >>>               unittests/Target/X86/CMakeFiles/X86Tests.dir/MachineSizeOptsTest.cpp.o:(testing::internal::TestFactoryImpl<(anonymous namespace)::MachineSizeOptsTest_Test_Test>::CreateTest())

MC is a direct dependency via transitive header inclusion:

  ld.lld: error: undefined symbol: llvm::MCTargetOptions::MCTargetOptions()
  >>> referenced by MachineSizeOptsTest.cpp
  >>>               unittests/Target/X86/CMakeFiles/X86Tests.dir/MachineSizeOptsTest.cpp.o:((anonymous namespace)::MachineSizeOptsTest::SetUp())

llvm/unittests/Target/X86/CMakeLists.txt

index 4676094..5763f4f 100644 (file)
@@ -6,6 +6,8 @@ include_directories(
 set(LLVM_LINK_COMPONENTS
   Analysis
   CodeGen
+  Core
+  MC
   MIRParser
   Support
   Target