[cmake] Explicitly mark libraries defined in lib/ as "Component Libraries"
Summary:
Most libraries are defined in the lib/ directory but there are also a
few libraries defined in tools/ e.g. libLLVM, libLTO. I'm defining
"Component Libraries" as libraries defined in lib/ that may be included in
libLLVM.so. Explicitly marking the libraries in lib/ as component
libraries allows us to remove some fragile checks that attempt to
differentiate between lib/ libraries and tools/ libraires:
1. In tools/llvm-shlib, because
llvm_map_components_to_libnames(LIB_NAMES "all") returned a list of
all libraries defined in the whole project, there was custom code
needed to filter out libraries defined in tools/, none of which should
be included in libLLVM.so. This code assumed that any library
defined as static was from lib/ and everything else should be
excluded.
With this change, llvm_map_components_to_libnames(LIB_NAMES, "all")
only returns libraries that have been added to the LLVM_COMPONENT_LIBS
global cmake property, so this custom filtering logic can be removed.
Doing this also fixes the build with BUILD_SHARED_LIBS=ON
and LLVM_BUILD_LLVM_DYLIB=ON.
2. There was some code in llvm_add_library that assumed that
libraries defined in lib/ would not have LLVM_LINK_COMPONENTS or
ARG_LINK_COMPONENTS set. This is only true because libraries
defined lib lib/ use LLVMBuild.txt and don't set these values.
This code has been fixed now to check if the library has been
explicitly marked as a component library, which should now make it
easier to remove LLVMBuild at some point in the future.
I have tested this patch on Windows, MacOS and Linux with release builds
and the following combinations of CMake options:
- "" (No options)
- -DLLVM_BUILD_LLVM_DYLIB=ON
- -DLLVM_LINK_LLVM_DYLIB=ON
- -DBUILD_SHARED_LIBS=ON
- -DBUILD_SHARED_LIBS=ON -DLLVM_BUILD_LLVM_DYLIB=ON
- -DBUILD_SHARED_LIBS=ON -DLLVM_LINK_LLVM_DYLIB=ON
Reviewers: beanz, smeenai, compnerd, phosek
Reviewed By: beanz
Subscribers: wuzish, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, mgorny, mehdi_amini, sbc100, jgravelle-google, hiraditya, aheejin, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, steven_wu, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, PkmX, jocewei, jsji, dang, Jim, lenary, s.egerton, pzheng, sameer.abuasal, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70179
2019-11-14 13:39:58 +08:00
|
|
|
add_llvm_component_library(LLVMMC
|
2014-06-19 02:17:25 +08:00
|
|
|
ConstantPools.cpp
|
2010-08-17 02:35:43 +08:00
|
|
|
ELFObjectWriter.cpp
|
2011-09-25 06:06:35 +08:00
|
|
|
MCAsmBackend.cpp
|
2009-08-23 06:07:08 +08:00
|
|
|
MCAsmInfo.cpp
|
|
|
|
MCAsmInfoCOFF.cpp
|
|
|
|
MCAsmInfoDarwin.cpp
|
2013-10-16 09:34:32 +08:00
|
|
|
MCAsmInfoELF.cpp
|
2017-02-22 09:23:18 +08:00
|
|
|
MCAsmInfoWasm.cpp
|
2019-07-10 03:21:01 +08:00
|
|
|
MCAsmInfoXCOFF.cpp
|
2018-03-06 22:07:01 +08:00
|
|
|
MCAsmMacro.cpp
|
2009-06-24 18:03:44 +08:00
|
|
|
MCAsmStreamer.cpp
|
2009-08-21 19:28:56 +08:00
|
|
|
MCAssembler.cpp
|
2009-08-27 10:08:37 +08:00
|
|
|
MCCodeEmitter.cpp
|
2016-01-29 08:49:42 +08:00
|
|
|
MCCodeView.cpp
|
2009-06-24 06:01:43 +08:00
|
|
|
MCContext.cpp
|
2011-09-25 06:06:35 +08:00
|
|
|
MCDwarf.cpp
|
2010-12-18 01:45:22 +08:00
|
|
|
MCELFObjectTargetWriter.cpp
|
2010-08-17 02:35:43 +08:00
|
|
|
MCELFStreamer.cpp
|
2009-08-31 16:06:59 +08:00
|
|
|
MCExpr.cpp
|
2015-12-29 17:06:16 +08:00
|
|
|
MCFragment.cpp
|
2009-08-27 15:57:12 +08:00
|
|
|
MCInst.cpp
|
2009-09-14 13:22:47 +08:00
|
|
|
MCInstPrinter.cpp
|
2011-08-09 03:09:02 +08:00
|
|
|
MCInstrAnalysis.cpp
|
2015-05-16 05:29:43 +08:00
|
|
|
MCInstrDesc.cpp
|
2020-03-30 03:09:07 +08:00
|
|
|
MCInstrInfo.cpp
|
2010-05-18 07:08:19 +08:00
|
|
|
MCLabel.cpp
|
2014-03-29 15:34:53 +08:00
|
|
|
MCLinkerOptimizationHint.cpp
|
2009-08-21 19:28:56 +08:00
|
|
|
MCMachOStreamer.cpp
|
2010-12-17 00:09:19 +08:00
|
|
|
MCMachObjectTargetWriter.cpp
|
2009-08-21 19:28:56 +08:00
|
|
|
MCNullStreamer.cpp
|
2011-07-20 14:35:24 +08:00
|
|
|
MCObjectFileInfo.cpp
|
2010-06-17 04:04:22 +08:00
|
|
|
MCObjectStreamer.cpp
|
2010-03-19 17:28:59 +08:00
|
|
|
MCObjectWriter.cpp
|
2012-07-28 00:25:20 +08:00
|
|
|
MCRegisterInfo.cpp
|
2015-07-11 06:13:43 +08:00
|
|
|
MCSchedule.cpp
|
2009-08-01 01:02:00 +08:00
|
|
|
MCSection.cpp
|
2010-05-08 01:29:48 +08:00
|
|
|
MCSectionCOFF.cpp
|
2009-08-13 13:07:35 +08:00
|
|
|
MCSectionELF.cpp
|
2009-08-11 02:15:01 +08:00
|
|
|
MCSectionMachO.cpp
|
2017-02-22 09:23:18 +08:00
|
|
|
MCSectionWasm.cpp
|
2019-07-10 03:21:01 +08:00
|
|
|
MCSectionXCOFF.cpp
|
2009-06-24 18:03:44 +08:00
|
|
|
MCStreamer.cpp
|
2011-07-02 04:45:01 +08:00
|
|
|
MCSubtargetInfo.cpp
|
2009-08-14 12:14:45 +08:00
|
|
|
MCSymbol.cpp
|
2015-06-03 04:38:46 +08:00
|
|
|
MCSymbolELF.cpp
|
2020-04-03 21:13:13 +08:00
|
|
|
MCSymbolXCOFF.cpp
|
2014-04-23 19:16:03 +08:00
|
|
|
MCTargetOptions.cpp
|
2020-03-04 07:47:43 +08:00
|
|
|
MCTargetOptionsCommandFlags.cpp
|
2009-08-14 12:14:45 +08:00
|
|
|
MCValue.cpp
|
2017-02-22 09:23:18 +08:00
|
|
|
MCWasmObjectTargetWriter.cpp
|
|
|
|
MCWasmStreamer.cpp
|
2011-05-22 11:01:05 +08:00
|
|
|
MCWin64EH.cpp
|
2017-06-22 04:58:17 +08:00
|
|
|
MCWinCOFFStreamer.cpp
|
2016-10-11 06:49:37 +08:00
|
|
|
MCWinEH.cpp
|
2019-07-10 03:21:01 +08:00
|
|
|
MCXCOFFObjectTargetWriter.cpp
|
|
|
|
MCXCOFFStreamer.cpp
|
2010-03-19 18:43:15 +08:00
|
|
|
MachObjectWriter.cpp
|
2014-07-03 10:01:39 +08:00
|
|
|
StringTableBuilder.cpp
|
2011-06-29 11:26:17 +08:00
|
|
|
SubtargetFeature.cpp
|
2017-02-22 09:23:18 +08:00
|
|
|
WasmObjectWriter.cpp
|
2011-09-25 06:06:35 +08:00
|
|
|
WinCOFFObjectWriter.cpp
|
2019-07-10 03:21:01 +08:00
|
|
|
XCOFFObjectWriter.cpp
|
2015-02-11 11:28:02 +08:00
|
|
|
|
|
|
|
ADDITIONAL_HEADER_DIRS
|
|
|
|
${LLVM_MAIN_INCLUDE_DIR}/llvm/MC
|
2009-06-24 06:01:43 +08:00
|
|
|
)
|
2011-02-19 06:06:14 +08:00
|
|
|
|
|
|
|
add_subdirectory(MCParser)
|
|
|
|
add_subdirectory(MCDisassembler)
|