diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt index ee112bd19df14ec..9f5875dd212847c 100644 --- a/bolt/CMakeLists.txt +++ b/bolt/CMakeLists.txt @@ -153,6 +153,7 @@ if (BOLT_ENABLE_RUNTIME) -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR} + -DBOLT_BUILT_STANDALONE=${BOLT_BUILT_STANDALONE} ${extra_args} INSTALL_COMMAND "" BUILD_ALWAYS True @@ -162,6 +163,8 @@ if (BOLT_ENABLE_RUNTIME) add_llvm_install_targets(install-bolt_rt DEPENDS bolt_rt bolt COMPONENT bolt) + set(LIBBOLT_RT_INSTR "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib/libbolt_rt_instr.a") + set(LIBBOLT_RT_HUGIFY "${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/lib/libbolt_rt_hugify.a") endif() find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld") diff --git a/bolt/runtime/CMakeLists.txt b/bolt/runtime/CMakeLists.txt index 872e55861f72ff2..948825ddc27eb2b 100644 --- a/bolt/runtime/CMakeLists.txt +++ b/bolt/runtime/CMakeLists.txt @@ -23,6 +23,13 @@ add_library(bolt_rt_hugify STATIC ) set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") +if(NOT BOLT_BUILT_STANDALONE) + add_custom_command(TARGET bolt_rt_instr POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_instr.a" "${LLVM_LIBRARY_DIR}") + add_custom_command(TARGET bolt_rt_hugify POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_hugify.a" "${LLVM_LIBRARY_DIR}") +endif() + set(BOLT_RT_FLAGS -ffreestanding -fno-exceptions @@ -60,4 +67,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" AND CMAKE_SYSTEM_NAME STREQUAL "Da -target x86_64-apple-darwin19.6.0 ${BOLT_RT_FLAGS}) install(TARGETS bolt_rt_instr_osx DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") + + if(NOT BOLT_BUILT_STANDALONE) + add_custom_command(TARGET bolt_rt_instr_osx POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_instr_osx.a" "${LLVM_LIBRARY_DIR}") + endif() endif() diff --git a/bolt/test/lit.cfg.py b/bolt/test/lit.cfg.py index 3a6da210e01f080..da3ae34ba3bddb9 100644 --- a/bolt/test/lit.cfg.py +++ b/bolt/test/lit.cfg.py @@ -92,10 +92,22 @@ tool_dirs = [config.llvm_tools_dir, config.test_source_root] +llvm_bolt_args = [] + +if config.libbolt_rt_instr: + llvm_bolt_args.append(f"--runtime-instrumentation-lib={config.libbolt_rt_instr}") + +if config.libbolt_rt_hugify: + llvm_bolt_args.append(f"--runtime-hugify-lib={config.libbolt_rt_hugify}") + tools = [ ToolSubst("llc", unresolved="fatal"), ToolSubst("llvm-dwarfdump", unresolved="fatal"), - ToolSubst("llvm-bolt", unresolved="fatal"), + ToolSubst( + "llvm-bolt", + unresolved="fatal", + extra_args=llvm_bolt_args, + ), ToolSubst("llvm-boltdiff", unresolved="fatal"), ToolSubst("llvm-bolt-heatmap", unresolved="fatal"), ToolSubst("llvm-bat-dump", unresolved="fatal"), diff --git a/bolt/test/lit.site.cfg.py.in b/bolt/test/lit.site.cfg.py.in index 46cb326dfbae18b..457908fc7c44620 100644 --- a/bolt/test/lit.site.cfg.py.in +++ b/bolt/test/lit.site.cfg.py.in @@ -19,6 +19,8 @@ config.bolt_clang = "@BOLT_CLANG_EXE@" config.bolt_lld = "@BOLT_LLD_EXE@" config.targets_to_build = "@BOLT_TARGETS_TO_BUILD@" config.gnu_ld = "@GNU_LD_EXECUTABLE@" +config.libbolt_rt_instr = "@LIBBOLT_RT_INSTR@" +config.libbolt_rt_hugify = "@LIBBOLT_RT_HUGIFY@" import lit.llvm lit.llvm.initialize(lit_config, config)