set(BOLT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_STANDARD 17)
+# Add path for custom modules.
+list(INSERT CMAKE_MODULE_PATH 0 "${BOLT_SOURCE_DIR}/cmake/modules")
+
# Determine default set of targets to build -- the intersection of
# those BOLT supports and those LLVM is targeting.
set(BOLT_TARGETS_TO_BUILD_all "AArch64;X86")
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
+include(AddBOLT)
+
+option(BOLT_BUILD_TOOLS
+ "Build the BOLT tools. If OFF, just generate build targets." ON)
+
+add_custom_target(bolt)
+set_target_properties(bolt PROPERTIES FOLDER "BOLT")
+add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
+
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
--- /dev/null
+include(GNUInstallDirs)
+include(LLVMDistributionSupport)
+
+macro(add_bolt_executable name)
+ add_llvm_executable(${name} ${ARGN})
+ set_target_properties(${name} PROPERTIES FOLDER "BOLT")
+endmacro()
+
+macro(add_bolt_tool name)
+ if (NOT BOLT_BUILD_TOOLS)
+ set(EXCLUDE_FROM_ALL ON)
+ endif()
+
+ add_bolt_executable(${name} ${ARGN})
+
+ if (BOLT_BUILD_TOOLS)
+ get_target_export_arg(${name} BOLT export_to_bolttargets)
+ install(TARGETS ${name}
+ ${export_to_bolttargets}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ COMPONENT bolt)
+
+ if(NOT LLVM_ENABLE_IDE)
+ add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT bolt)
+ endif()
+ set_property(GLOBAL APPEND PROPERTY BOLT_EXPORTS ${name})
+ endif()
+endmacro()
+
+macro(add_bolt_tool_symlink name dest)
+ llvm_add_tool_symlink(BOLT ${name} ${dest} ALWAYS_GENERATE)
+ # Always generate install targets
+ llvm_install_symlink(BOLT ${name} ${dest} ALWAYS_GENERATE COMPONENT bolt)
+endmacro()
lld
llvm-config
llvm-bolt
- llvm-boltdiff
llvm-bolt-heatmap
llvm-bat-dump
llvm-dwarfdump
llvm-objcopy
merge-fdata
not
- perf2bolt
split-file
yaml2obj
)
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
mark_as_advanced(BOLT_TOOLS_INSTALL_DIR)
-# Move these macros to AddBolt if such a CMake module is ever created.
-
-macro(add_bolt_tool name)
- llvm_add_tool(BOLT ${ARGV})
-endmacro()
-
-macro(add_bolt_tool_symlink name)
- llvm_add_tool_symlink(BOLT ${ARGV})
-endmacro()
-
add_subdirectory(driver)
add_subdirectory(llvm-bolt-fuzzer)
add_subdirectory(bat-dump)
Support
)
-add_llvm_tool(llvm-bat-dump
+add_bolt_executable(llvm-bat-dump
bat-dump.cpp
DISABLE_LLVM_LINK_LLVM_DYLIB
PRIVATE
LLVMBOLTProfile
)
-
-set_target_properties(llvm-bat-dump PROPERTIES FOLDER "BOLT")
add_bolt_tool_symlink(perf2bolt llvm-bolt)
add_bolt_tool_symlink(llvm-boltdiff llvm-bolt)
-set(BOLT_DEPENDS
- llvm-bolt
- perf2bolt
- llvm-boltdiff
- )
-
-add_custom_target(bolt DEPENDS ${BOLT_DEPENDS})
-install(PROGRAMS
- ${CMAKE_BINARY_DIR}/bin/llvm-bolt
- ${CMAKE_BINARY_DIR}/bin/perf2bolt
- ${CMAKE_BINARY_DIR}/bin/llvm-boltdiff
- DESTINATION ${CMAKE_INSTALL_BINDIR}
- COMPONENT bolt
- )
-add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
-set_target_properties(bolt PROPERTIES FOLDER "BOLT")
-set_target_properties(install-bolt PROPERTIES FOLDER "BOLT")
+add_dependencies(bolt llvm-bolt)
-include_directories( ${BOLT_SOURCE_DIR}/lib )
+include_directories(${BOLT_SOURCE_DIR}/lib)
LLVMBOLTUtils
)
-set_target_properties(llvm-bolt-heatmap PROPERTIES FOLDER "BOLT")
+add_dependencies(bolt llvm-bolt-heatmap)
DEPENDS
intrinsics_gen
)
-set_target_properties(merge-fdata PROPERTIES FOLDER "BOLT")
add_dependencies(bolt merge-fdata)
-install(PROGRAMS
- ${CMAKE_BINARY_DIR}/bin/merge-fdata
- DESTINATION ${CMAKE_INSTALL_BINDIR}
- COMPONENT bolt
- )
# Emit relocations for BOLT meta test (bolt/test/runtime/meta-merge-fdata.test)
if (BOLT_INCLUDE_TESTS AND UNIX AND NOT APPLE)
set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
-set(_FUCHSIA_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
CACHE STRING "")
set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+ bolt
clang
lld
clang-apply-replacements
if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
add_llvm_install_targets(install-${name}
DEPENDS ${name} ${dest}
- COMPONENT ${name}
+ COMPONENT ${component}
SYMLINK ${dest})
endif()
endfunction()