Skip to content

Commit

Permalink
[BOLT][CMAKE] Fix DYLIB build
Browse files Browse the repository at this point in the history
Move BOLT libraries out of `LLVM_LINK_COMPONENTS` to `target_link_libraries`.
Addresses issue #55432.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D125568
  • Loading branch information
aaupov committed May 13, 2022
1 parent f0792c7 commit bdba3d0
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 24 deletions.
6 changes: 5 additions & 1 deletion bolt/lib/Core/CMakeLists.txt
@@ -1,5 +1,4 @@
set(LLVM_LINK_COMPONENTS
BOLTUtils
DebugInfoDWARF
Demangle
MC
Expand All @@ -26,3 +25,8 @@ add_llvm_library(LLVMBOLTCore
LINK_LIBS
${LLVM_PTHREAD_LIB}
)

target_link_libraries(LLVMBOLTCore
PRIVATE
LLVMBOLTUtils
)
8 changes: 6 additions & 2 deletions bolt/lib/Passes/CMakeLists.txt
Expand Up @@ -51,8 +51,12 @@ add_llvm_library(LLVMBOLTPasses

LINK_COMPONENTS
AsmPrinter
BOLTCore
BOLTUtils
MC
Support
)

target_link_libraries(LLVMBOLTPasses
PRIVATE
LLVMBOLTCore
LLVMBOLTUtils
)
10 changes: 7 additions & 3 deletions bolt/lib/Profile/CMakeLists.txt
Expand Up @@ -8,8 +8,12 @@ add_llvm_library(LLVMBOLTProfile
YAMLProfileWriter.cpp

LINK_COMPONENTS
BOLTCore
BOLTPasses
BOLTUtils
Support
)

target_link_libraries(LLVMBOLTProfile
PRIVATE
LLVMBOLTCore
LLVMBOLTPasses
LLVMBOLTUtils
)
22 changes: 15 additions & 7 deletions bolt/lib/Rewrite/CMakeLists.txt
@@ -1,9 +1,4 @@
set(LLVM_LINK_COMPONENTS
BOLTCore
BOLTPasses
BOLTProfile
BOLTRuntimeLibs
BOLTUtils
DebugInfoDWARF
DWP
ExecutionEngine
Expand All @@ -12,13 +7,21 @@ set(LLVM_LINK_COMPONENTS
Support
)

set(TARGET_LINK_LIBRARIES
LLVMBOLTCore
LLVMBOLTPasses
LLVMBOLTProfile
LLVMBOLTRuntimeLibs
LLVMBOLTUtils
)

if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
list(APPEND LLVM_LINK_COMPONENTS BOLTTargetAArch64)
list(APPEND TARGET_LINK_LIBRARIES LLVMBOLTTargetAArch64)
set(BOLT_AArch64 On)
endif()

if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
list(APPEND LLVM_LINK_COMPONENTS BOLTTargetX86)
list(APPEND TARGET_LINK_LIBRARIES LLVMBOLTTargetX86)
set(BOLT_X64 On)
endif()

Expand All @@ -34,6 +37,11 @@ add_llvm_library(LLVMBOLTRewrite
${LLVM_PTHREAD_LIB}
)

target_link_libraries(LLVMBOLTRewrite
PRIVATE
${TARGET_LINK_LIBRARIES}
)

if (DEFINED BOLT_AArch64)
target_compile_definitions(LLVMBOLTRewrite PRIVATE AARCH64_AVAILABLE)
endif()
Expand Down
10 changes: 7 additions & 3 deletions bolt/lib/RuntimeLibs/CMakeLists.txt
@@ -1,7 +1,4 @@
set(LLVM_LINK_COMPONENTS
BOLTCore
BOLTPasses
BOLTUtils
BinaryFormat
MC
Object
Expand All @@ -14,3 +11,10 @@ add_llvm_library(LLVMBOLTRuntimeLibs
HugifyRuntimeLibrary.cpp
InstrumentationRuntimeLibrary.cpp
)

target_link_libraries(LLVMBOLTRuntimeLibs
PRIVATE
LLVMBOLTCore
LLVMBOLTPasses
LLVMBOLTUtils
)
10 changes: 7 additions & 3 deletions bolt/tools/driver/CMakeLists.txt
@@ -1,8 +1,5 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
BOLTProfile
BOLTRewrite
BOLTUtils
MC
Object
Support
Expand All @@ -21,6 +18,13 @@ add_llvm_tool(llvm-bolt
${BOLT_DRIVER_DEPS}
)

target_link_libraries(llvm-bolt
PRIVATE
LLVMBOLTProfile
LLVMBOLTRewrite
LLVMBOLTUtils
)

add_llvm_tool_symlink(perf2bolt llvm-bolt)
add_llvm_tool_symlink(llvm-boltdiff llvm-bolt)

Expand Down
10 changes: 7 additions & 3 deletions bolt/tools/heatmap/CMakeLists.txt
@@ -1,8 +1,5 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
BOLTProfile
BOLTRewrite
BOLTUtils
MC
Object
Support
Expand All @@ -12,4 +9,11 @@ add_llvm_tool(llvm-bolt-heatmap
heatmap.cpp
)

target_link_libraries(llvm-bolt-heatmap
PRIVATE
LLVMBOLTProfile
LLVMBOLTRewrite
LLVMBOLTUtils
)

set_target_properties(llvm-bolt-heatmap PROPERTIES FOLDER "BOLT")
8 changes: 6 additions & 2 deletions bolt/unittests/Core/CMakeLists.txt
@@ -1,6 +1,4 @@
set(LLVM_LINK_COMPONENTS
BOLTCore
BOLTRewrite
DebugInfoDWARF
Object
MC
Expand All @@ -12,6 +10,12 @@ add_bolt_unittest(CoreTests
MCPlusBuilder.cpp
)

target_link_libraries(CoreTests
PRIVATE
LLVMBOLTCore
LLVMBOLTRewrite
)

if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
include_directories(
${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64
Expand Down

0 comments on commit bdba3d0

Please sign in to comment.