Skip to content

Commit e7244d8

Browse files
authored
[BOLT][CMake] Don't export bolt libraries in LLVMExports.cmake (#121936)
Bolt makes use of add_llvm_library and as such ends up exporting its libraries from LLVMExports.cmake, which is not correct. Bolt doesn't have its own exports file, and I assume that there is no desire to have one either -- Bolt libraries are not intended to be consumed as a cmake module, right? As such, this PR adds a NO_EXPORT option to simplify exclude these libraries from the exports file.
1 parent 49668d5 commit e7244d8

File tree

10 files changed

+19
-3
lines changed

10 files changed

+19
-3
lines changed

bolt/lib/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ add_llvm_library(LLVMBOLTCore
3535
ParallelUtilities.cpp
3636
Relocation.cpp
3737

38+
NO_EXPORT
3839
DISABLE_LLVM_LINK_LLVM_DYLIB
3940
LINK_LIBS
4041
${LLVM_PTHREAD_LIB}

bolt/lib/Passes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ add_llvm_library(LLVMBOLTPasses
4646
VeneerElimination.cpp
4747
RetpolineInsertion.cpp
4848

49+
NO_EXPORT
4950
DISABLE_LLVM_LINK_LLVM_DYLIB
5051

5152
LINK_LIBS

bolt/lib/Profile/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_llvm_library(LLVMBOLTProfile
77
YAMLProfileReader.cpp
88
YAMLProfileWriter.cpp
99

10+
NO_EXPORT
1011
DISABLE_LLVM_LINK_LLVM_DYLIB
1112

1213
LINK_COMPONENTS

bolt/lib/Rewrite/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ add_llvm_library(LLVMBOLTRewrite
2525
RewriteInstance.cpp
2626
SDTRewriter.cpp
2727

28+
NO_EXPORT
2829
DISABLE_LLVM_LINK_LLVM_DYLIB
2930

3031
LINK_LIBS

bolt/lib/RuntimeLibs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ add_llvm_library(LLVMBOLTRuntimeLibs
1111
HugifyRuntimeLibrary.cpp
1212
InstrumentationRuntimeLibrary.cpp
1313

14+
NO_EXPORT
1415
DISABLE_LLVM_LINK_LLVM_DYLIB
1516
)
1617

bolt/lib/Target/AArch64/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ endif()
1919
add_llvm_library(LLVMBOLTTargetAArch64
2020
AArch64MCPlusBuilder.cpp
2121

22+
NO_EXPORT
2223
DISABLE_LLVM_LINK_LLVM_DYLIB
2324

2425
DEPENDS

bolt/lib/Target/RISCV/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ endif()
2020
add_llvm_library(LLVMBOLTTargetRISCV
2121
RISCVMCPlusBuilder.cpp
2222

23+
NO_EXPORT
2324
DISABLE_LLVM_LINK_LLVM_DYLIB
2425

2526
DEPENDS

bolt/lib/Target/X86/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ add_llvm_library(LLVMBOLTTargetX86
2121
X86MCPlusBuilder.cpp
2222
X86MCSymbolizer.cpp
2323

24+
NO_EXPORT
2425
DISABLE_LLVM_LINK_LLVM_DYLIB
2526

2627
DEPENDS

bolt/lib/Utils/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ add_llvm_library(LLVMBOLTUtils
2929
CommandLineOpts.cpp
3030
Utils.cpp
3131
${version_inc}
32+
33+
NO_EXPORT
3234
DISABLE_LLVM_LINK_LLVM_DYLIB
3335

3436
LINK_LIBS

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ endfunction()
932932

933933
macro(add_llvm_library name)
934934
cmake_parse_arguments(ARG
935-
"SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN"
935+
"SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN;NO_EXPORT"
936936
""
937937
""
938938
${ARGN})
@@ -967,7 +967,11 @@ macro(add_llvm_library name)
967967
set(umbrella)
968968
endif()
969969

970-
get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella})
970+
if(ARG_NO_EXPORT)
971+
set(export_to_llvmexports)
972+
else()
973+
get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella})
974+
endif()
971975
install(TARGETS ${name}
972976
${export_to_llvmexports}
973977
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
@@ -980,7 +984,9 @@ macro(add_llvm_library name)
980984
COMPONENT ${name})
981985
endif()
982986
endif()
983-
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
987+
if(NOT ARG_NO_EXPORT)
988+
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
989+
endif()
984990
endif()
985991

986992
get_subproject_title(subproject_title)

0 commit comments

Comments
 (0)