|
| 1 | +From ee0f56cff40b324bb06e034e247ec85ae9a846bf Mon Sep 17 00:00:00 2001 |
| 2 | +From: Nikita Popov < [email protected]> |
| 3 | +Date: Wed, 8 Jan 2025 08:28:18 +0100 |
| 4 | +Subject: [PATCH] [PATCH] [Bolt][CMake] Don't export bolt libraries in |
| 5 | + LLVMExports.cmake |
| 6 | + |
| 7 | +Bolt makes use of add_llvm_library and as such ends up exporting |
| 8 | +its libraries from LLVMExports.cmake, which is not correct. |
| 9 | + |
| 10 | +Bolt doesn't have its own exports file, and I assume that there |
| 11 | +is no desire to have one either -- Bolt libraries are not intended |
| 12 | +to be consumed as a cmake module, right? |
| 13 | + |
| 14 | +As such, this PR adds a NO_EXPORT option to simplify exclude these |
| 15 | +libraries from the exports file. |
| 16 | + |
| 17 | +--- |
| 18 | +This patch originates from this PR: |
| 19 | + |
| 20 | +https://patch-diff.githubusercontent.com/raw/llvm/llvm-project/pull/121936. |
| 21 | + |
| 22 | +The commit was: |
| 23 | + |
| 24 | +https://github.com/nikic/llvm-project/commit/4333a4dd270b5c046c5469b97846e3dae58fb221.patch |
| 25 | + |
| 26 | +And then it was rebased onto llvmorg-19.1.6. |
| 27 | +--- |
| 28 | + bolt/lib/Core/CMakeLists.txt | 1 + |
| 29 | + bolt/lib/Passes/CMakeLists.txt | 1 + |
| 30 | + bolt/lib/Profile/CMakeLists.txt | 1 + |
| 31 | + bolt/lib/Rewrite/CMakeLists.txt | 1 + |
| 32 | + bolt/lib/RuntimeLibs/CMakeLists.txt | 1 + |
| 33 | + bolt/lib/Target/AArch64/CMakeLists.txt | 1 + |
| 34 | + bolt/lib/Target/RISCV/CMakeLists.txt | 1 + |
| 35 | + bolt/lib/Target/X86/CMakeLists.txt | 1 + |
| 36 | + bolt/lib/Utils/CMakeLists.txt | 1 + |
| 37 | + llvm/cmake/modules/AddLLVM.cmake | 12 +++++++++--- |
| 38 | + 10 files changed, 18 insertions(+), 3 deletions(-) |
| 39 | + |
| 40 | +diff --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt |
| 41 | +index bb58667066fd..8c1f5d0bb37b 100644 |
| 42 | +--- a/bolt/lib/Core/CMakeLists.txt |
| 43 | ++++ b/bolt/lib/Core/CMakeLists.txt |
| 44 | +@@ -35,6 +35,7 @@ add_llvm_library(LLVMBOLTCore |
| 45 | + ParallelUtilities.cpp |
| 46 | + Relocation.cpp |
| 47 | + |
| 48 | ++ NO_EXPORT |
| 49 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 50 | + LINK_LIBS |
| 51 | + ${LLVM_PTHREAD_LIB} |
| 52 | +diff --git a/bolt/lib/Passes/CMakeLists.txt b/bolt/lib/Passes/CMakeLists.txt |
| 53 | +index 407d8b03f739..7367b541545d 100644 |
| 54 | +--- a/bolt/lib/Passes/CMakeLists.txt |
| 55 | ++++ b/bolt/lib/Passes/CMakeLists.txt |
| 56 | +@@ -45,6 +45,7 @@ add_llvm_library(LLVMBOLTPasses |
| 57 | + VeneerElimination.cpp |
| 58 | + RetpolineInsertion.cpp |
| 59 | + |
| 60 | ++ NO_EXPORT |
| 61 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 62 | + |
| 63 | + LINK_LIBS |
| 64 | +diff --git a/bolt/lib/Profile/CMakeLists.txt b/bolt/lib/Profile/CMakeLists.txt |
| 65 | +index 9aa4ba0490b0..a2bb4aa074c7 100644 |
| 66 | +--- a/bolt/lib/Profile/CMakeLists.txt |
| 67 | ++++ b/bolt/lib/Profile/CMakeLists.txt |
| 68 | +@@ -7,6 +7,7 @@ add_llvm_library(LLVMBOLTProfile |
| 69 | + YAMLProfileReader.cpp |
| 70 | + YAMLProfileWriter.cpp |
| 71 | + |
| 72 | ++ NO_EXPORT |
| 73 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 74 | + |
| 75 | + LINK_COMPONENTS |
| 76 | +diff --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt |
| 77 | +index 34993af2623b..6737e89b8451 100644 |
| 78 | +--- a/bolt/lib/Rewrite/CMakeLists.txt |
| 79 | ++++ b/bolt/lib/Rewrite/CMakeLists.txt |
| 80 | +@@ -26,6 +26,7 @@ add_llvm_library(LLVMBOLTRewrite |
| 81 | + RewriteInstance.cpp |
| 82 | + SDTRewriter.cpp |
| 83 | + |
| 84 | ++ NO_EXPORT |
| 85 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 86 | + |
| 87 | + LINK_LIBS |
| 88 | +diff --git a/bolt/lib/RuntimeLibs/CMakeLists.txt b/bolt/lib/RuntimeLibs/CMakeLists.txt |
| 89 | +index d3ac71d3e797..b8db7e4a1553 100644 |
| 90 | +--- a/bolt/lib/RuntimeLibs/CMakeLists.txt |
| 91 | ++++ b/bolt/lib/RuntimeLibs/CMakeLists.txt |
| 92 | +@@ -11,6 +11,7 @@ add_llvm_library(LLVMBOLTRuntimeLibs |
| 93 | + HugifyRuntimeLibrary.cpp |
| 94 | + InstrumentationRuntimeLibrary.cpp |
| 95 | + |
| 96 | ++ NO_EXPORT |
| 97 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 98 | + ) |
| 99 | + |
| 100 | +diff --git a/bolt/lib/Target/AArch64/CMakeLists.txt b/bolt/lib/Target/AArch64/CMakeLists.txt |
| 101 | +index be03e247aa96..526a9645cb54 100644 |
| 102 | +--- a/bolt/lib/Target/AArch64/CMakeLists.txt |
| 103 | ++++ b/bolt/lib/Target/AArch64/CMakeLists.txt |
| 104 | +@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS |
| 105 | + add_llvm_library(LLVMBOLTTargetAArch64 |
| 106 | + AArch64MCPlusBuilder.cpp |
| 107 | + |
| 108 | ++ NO_EXPORT |
| 109 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 110 | + |
| 111 | + DEPENDS |
| 112 | +diff --git a/bolt/lib/Target/RISCV/CMakeLists.txt b/bolt/lib/Target/RISCV/CMakeLists.txt |
| 113 | +index 7f9557606320..3955cfc0f089 100644 |
| 114 | +--- a/bolt/lib/Target/RISCV/CMakeLists.txt |
| 115 | ++++ b/bolt/lib/Target/RISCV/CMakeLists.txt |
| 116 | +@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS |
| 117 | + add_llvm_library(LLVMBOLTTargetRISCV |
| 118 | + RISCVMCPlusBuilder.cpp |
| 119 | + |
| 120 | ++ NO_EXPORT |
| 121 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 122 | + |
| 123 | + DEPENDS |
| 124 | +diff --git a/bolt/lib/Target/X86/CMakeLists.txt b/bolt/lib/Target/X86/CMakeLists.txt |
| 125 | +index 2b769bc7e7f5..00100e9b84c9 100644 |
| 126 | +--- a/bolt/lib/Target/X86/CMakeLists.txt |
| 127 | ++++ b/bolt/lib/Target/X86/CMakeLists.txt |
| 128 | +@@ -9,6 +9,7 @@ add_llvm_library(LLVMBOLTTargetX86 |
| 129 | + X86MCPlusBuilder.cpp |
| 130 | + X86MCSymbolizer.cpp |
| 131 | + |
| 132 | ++ NO_EXPORT |
| 133 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 134 | + |
| 135 | + DEPENDS |
| 136 | +diff --git a/bolt/lib/Utils/CMakeLists.txt b/bolt/lib/Utils/CMakeLists.txt |
| 137 | +index d1403314274b..ceddcfc8f57a 100644 |
| 138 | +--- a/bolt/lib/Utils/CMakeLists.txt |
| 139 | ++++ b/bolt/lib/Utils/CMakeLists.txt |
| 140 | +@@ -2,6 +2,7 @@ add_llvm_library(LLVMBOLTUtils |
| 141 | + CommandLineOpts.cpp |
| 142 | + Utils.cpp |
| 143 | + |
| 144 | ++ NO_EXPORT |
| 145 | + DISABLE_LLVM_LINK_LLVM_DYLIB |
| 146 | + |
| 147 | + LINK_LIBS |
| 148 | +diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake |
| 149 | +index 03f4e1f190fd..addf083b7c71 100644 |
| 150 | +--- a/llvm/cmake/modules/AddLLVM.cmake |
| 151 | ++++ b/llvm/cmake/modules/AddLLVM.cmake |
| 152 | +@@ -897,7 +897,7 @@ endfunction() |
| 153 | + |
| 154 | + macro(add_llvm_library name) |
| 155 | + cmake_parse_arguments(ARG |
| 156 | +- "SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN" |
| 157 | ++ "SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN;NO_EXPORT" |
| 158 | + "" |
| 159 | + "" |
| 160 | + ${ARGN}) |
| 161 | +@@ -932,7 +932,11 @@ macro(add_llvm_library name) |
| 162 | + set(umbrella) |
| 163 | + endif() |
| 164 | + |
| 165 | +- get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) |
| 166 | ++ if(ARG_NO_EXPORT) |
| 167 | ++ set(export_to_llvmexports) |
| 168 | ++ else() |
| 169 | ++ get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) |
| 170 | ++ endif() |
| 171 | + install(TARGETS ${name} |
| 172 | + ${export_to_llvmexports} |
| 173 | + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} |
| 174 | +@@ -945,7 +949,9 @@ macro(add_llvm_library name) |
| 175 | + COMPONENT ${name}) |
| 176 | + endif() |
| 177 | + endif() |
| 178 | +- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) |
| 179 | ++ if(NOT ARG_NO_EXPORT) |
| 180 | ++ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) |
| 181 | ++ endif() |
| 182 | + endif() |
| 183 | + |
| 184 | + get_subproject_title(subproject_title) |
| 185 | +-- |
| 186 | +2.47.1 |
| 187 | + |
0 commit comments