llvm-project/bolt/tools/driver/CMakeLists.txt
Nikita Popov e235fcb582
[BOLT] Only link and initialize supported targets (#127509)
Bolt currently links and initializes all LLVM targets. This
substantially increases the binary size, and link time if LTO is used.

Instead, only link the targets specified by BOLT_TARGETS_TO_BUILD. We
also have to only initialize those targets, so generate a
TargetConfig.def file with the necessary information. The way the
initialization is done mirrors what llvm-exegesis does.

This reduces llvm-bolt size from 137MB to 78MB for me.
2025-02-18 09:17:51 +01:00

36 lines
561 B
CMake

set(LLVM_LINK_COMPONENTS
${BOLT_TARGETS_TO_BUILD}
MC
Object
Support
)
if (BOLT_ENABLE_RUNTIME)
set(BOLT_DRIVER_DEPS "bolt_rt")
else()
set(BOLT_DRIVER_DEPS "")
endif()
add_bolt_tool(llvm-bolt
llvm-bolt.cpp
DISABLE_LLVM_LINK_LLVM_DYLIB
DEPENDS
${BOLT_DRIVER_DEPS}
)
target_link_libraries(llvm-bolt
PRIVATE
LLVMBOLTProfile
LLVMBOLTRewrite
LLVMBOLTUtils
)
add_bolt_tool_symlink(perf2bolt llvm-bolt)
add_bolt_tool_symlink(llvm-boltdiff llvm-bolt)
add_dependencies(bolt llvm-bolt)
include_directories(${BOLT_SOURCE_DIR}/lib)