[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 05:39:58 +00:00
|
|
|
add_llvm_component_library(LLVMProfileData
|
2017-11-03 20:57:10 +00:00
|
|
|
GCOV.cpp
|
2014-03-21 17:24:48 +00:00
|
|
|
InstrProf.cpp
|
2021-12-16 14:45:54 -08:00
|
|
|
InstrProfCorrelator.cpp
|
2014-03-21 17:24:48 +00:00
|
|
|
InstrProfReader.cpp
|
2014-03-21 17:46:22 +00:00
|
|
|
InstrProfWriter.cpp
|
2023-02-06 20:55:24 +00:00
|
|
|
ItaniumManglingCanonicalizer.cpp
|
2022-02-17 16:01:31 -08:00
|
|
|
MemProf.cpp
|
2024-04-10 22:03:20 -07:00
|
|
|
MemProfReader.cpp
|
2024-05-15 12:45:50 -07:00
|
|
|
PGOCtxProfReader.cpp
|
|
|
|
PGOCtxProfWriter.cpp
|
2016-05-19 21:07:12 +00:00
|
|
|
ProfileSummaryBuilder.cpp
|
2014-10-30 18:00:06 +00:00
|
|
|
SampleProf.cpp
|
2014-09-09 12:40:50 +00:00
|
|
|
SampleProfReader.cpp
|
2014-10-30 18:00:06 +00:00
|
|
|
SampleProfWriter.cpp
|
2023-02-06 20:55:24 +00:00
|
|
|
SymbolRemappingReader.cpp
|
2015-02-11 03:28:02 +00:00
|
|
|
|
|
|
|
ADDITIONAL_HEADER_DIRS
|
|
|
|
${LLVM_MAIN_INCLUDE_DIR}/llvm/ProfileData
|
2015-06-16 00:44:12 +00:00
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
intrinsics_gen
|
2020-10-09 18:41:21 +02:00
|
|
|
|
|
|
|
LINK_COMPONENTS
|
2024-05-15 12:45:50 -07:00
|
|
|
BitstreamReader
|
2020-10-09 18:41:21 +02:00
|
|
|
Core
|
2022-02-04 11:11:47 -08:00
|
|
|
Object
|
2022-02-03 15:32:32 -08:00
|
|
|
Support
|
2022-02-03 15:41:24 -08:00
|
|
|
Demangle
|
2022-02-04 11:11:47 -08:00
|
|
|
Symbolize
|
2022-02-03 15:41:24 -08:00
|
|
|
DebugInfoDWARF
|
[Support] Move TargetParsers to new component
This is a fairly large changeset, but it can be broken into a few
pieces:
- `llvm/Support/*TargetParser*` are all moved from the LLVM Support
component into a new LLVM Component called "TargetParser". This
potentially enables using tablegen to maintain this information, as
is shown in https://reviews.llvm.org/D137517. This cannot currently
be done, as llvm-tblgen relies on LLVM's Support component.
- This also moves two files from Support which use and depend on
information in the TargetParser:
- `llvm/Support/Host.{h,cpp}` which contains functions for inspecting
the current Host machine for info about it, primarily to support
getting the host triple, but also for `-mcpu=native` support in e.g.
Clang. This is fairly tightly intertwined with the information in
`X86TargetParser.h`, so keeping them in the same component makes
sense.
- `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains
the target triple parser and representation. This is very intertwined
with the Arm target parser, because the arm architecture version
appears in canonical triples on arm platforms.
- I moved the relevant unittests to their own directory.
And so, we end up with a single component that has all the information
about the following, which to me seems like a unified component:
- Triples that LLVM Knows about
- Architecture names and CPUs that LLVM knows about
- CPU detection logic for LLVM
Given this, I have also moved `RISCVISAInfo.h` into this component, as
it seems to me to be part of that same set of functionality.
If you get link errors in your components after this patch, you likely
need to add TargetParser into LLVM_LINK_COMPONENTS in CMake.
Differential Revision: https://reviews.llvm.org/D137838
2022-12-20 10:24:02 +00:00
|
|
|
TargetParser
|
2014-03-23 01:23:36 +00:00
|
|
|
)
|
2016-04-29 18:53:05 +00:00
|
|
|
|
|
|
|
add_subdirectory(Coverage)
|