llvm-project/bolt/CMakeLists.txt

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
3.6 KiB
CMake
Raw Normal View History

include(ExternalProject)
set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(BOLT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_STANDARD 14)
set(BOLT_ENABLE_RUNTIME OFF)
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
set(BOLT_ENABLE_RUNTIME ON)
endif()
[BOLT][CMAKE] Accept BOLT_CLANG_EXE and BOLT_LLD_EXE Add CMake options to supply clang and lld binaries for use in check-bolt instead of requiring the build of clang and lld projects. Suggested by Mehdi Amini in https://lists.llvm.org/pipermail/llvm-dev/2021-December/154426.html Test Plan: ``` cmake -G Ninja ~/local/llvm-project/llvm \ -DLLVM_TARGETS_TO_BUILD="X86" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_PROJECTS="bolt" \ -DBOLT_CLANG_EXE=~/local/bin/clang \ -DBOLT_LLD_EXE=~/local/bin/lld ninja check-bolt ... llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /home/aaupov/local/bin/clang llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld.lld: /home/aaupov/local/bin/ld.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld-link: /home/aaupov/local/bin/lld-link llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld64.lld: /home/aaupov/local/bin/ld64.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using wasm-ld: /home/aaupov/local/bin/wasm-ld ... ``` Tested all configurations: - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + no BOLT_*_EXE - LLVM_ENABLE_PROJECTS="bolt;clang" + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;lld" + BOLT_CLANG_EXE - LLVM_ENABLE_PROJECTS="bolt" + BOLT_CLANG_EXE + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + BOLT_CLANG_EXE + BOLT_LLD_EXE Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D117061
2022-01-15 06:18:43 +08:00
set(BOLT_CLANG_EXE "" CACHE FILEPATH "Path to clang executable for the target \
architecture for use in BOLT tests")
set(BOLT_LLD_EXE "" CACHE FILEPATH "Path to lld executable for the target \
architecture for use in BOLT tests")
set(BOLT_INCLUDE_TESTS OFF)
if (LLVM_INCLUDE_TESTS)
[BOLT][CMAKE] Accept BOLT_CLANG_EXE and BOLT_LLD_EXE Add CMake options to supply clang and lld binaries for use in check-bolt instead of requiring the build of clang and lld projects. Suggested by Mehdi Amini in https://lists.llvm.org/pipermail/llvm-dev/2021-December/154426.html Test Plan: ``` cmake -G Ninja ~/local/llvm-project/llvm \ -DLLVM_TARGETS_TO_BUILD="X86" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_PROJECTS="bolt" \ -DBOLT_CLANG_EXE=~/local/bin/clang \ -DBOLT_LLD_EXE=~/local/bin/lld ninja check-bolt ... llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /home/aaupov/local/bin/clang llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld.lld: /home/aaupov/local/bin/ld.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld-link: /home/aaupov/local/bin/lld-link llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld64.lld: /home/aaupov/local/bin/ld64.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using wasm-ld: /home/aaupov/local/bin/wasm-ld ... ``` Tested all configurations: - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + no BOLT_*_EXE - LLVM_ENABLE_PROJECTS="bolt;clang" + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;lld" + BOLT_CLANG_EXE - LLVM_ENABLE_PROJECTS="bolt" + BOLT_CLANG_EXE + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + BOLT_CLANG_EXE + BOLT_LLD_EXE Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D117061
2022-01-15 06:18:43 +08:00
if ("clang" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_CLANG_EXE)
if ("clang" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_CLANG_EXE)
message(WARNING "BOLT_CLANG_EXE is set and clang project is enabled. \
BOLT_CLANG_EXE will be used for BOLT tests.")
endif()
if ("lld" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_LLD_EXE)
if ("lld" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_LLD_EXE)
message(WARNING "BOLT_LLD_EXE is set and lld project is enabled. \
BOLT_LLD_EXE will be used for BOLT tests.")
endif()
set(BOLT_INCLUDE_TESTS ON)
else()
[BOLT][CMAKE] Accept BOLT_CLANG_EXE and BOLT_LLD_EXE Add CMake options to supply clang and lld binaries for use in check-bolt instead of requiring the build of clang and lld projects. Suggested by Mehdi Amini in https://lists.llvm.org/pipermail/llvm-dev/2021-December/154426.html Test Plan: ``` cmake -G Ninja ~/local/llvm-project/llvm \ -DLLVM_TARGETS_TO_BUILD="X86" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_PROJECTS="bolt" \ -DBOLT_CLANG_EXE=~/local/bin/clang \ -DBOLT_LLD_EXE=~/local/bin/lld ninja check-bolt ... llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /home/aaupov/local/bin/clang llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld.lld: /home/aaupov/local/bin/ld.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld-link: /home/aaupov/local/bin/lld-link llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld64.lld: /home/aaupov/local/bin/ld64.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using wasm-ld: /home/aaupov/local/bin/wasm-ld ... ``` Tested all configurations: - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + no BOLT_*_EXE - LLVM_ENABLE_PROJECTS="bolt;clang" + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;lld" + BOLT_CLANG_EXE - LLVM_ENABLE_PROJECTS="bolt" + BOLT_CLANG_EXE + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + BOLT_CLANG_EXE + BOLT_LLD_EXE Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D117061
2022-01-15 06:18:43 +08:00
message(WARNING "Not including BOLT tests since lld is disabled. \
Enable lld in LLVM_ENABLE_PROJECTS or provide a path to lld binary \
in BOLT_LLD_EXE.")
endif()
else()
[BOLT][CMAKE] Accept BOLT_CLANG_EXE and BOLT_LLD_EXE Add CMake options to supply clang and lld binaries for use in check-bolt instead of requiring the build of clang and lld projects. Suggested by Mehdi Amini in https://lists.llvm.org/pipermail/llvm-dev/2021-December/154426.html Test Plan: ``` cmake -G Ninja ~/local/llvm-project/llvm \ -DLLVM_TARGETS_TO_BUILD="X86" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_PROJECTS="bolt" \ -DBOLT_CLANG_EXE=~/local/bin/clang \ -DBOLT_LLD_EXE=~/local/bin/lld ninja check-bolt ... llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /home/aaupov/local/bin/clang llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld.lld: /home/aaupov/local/bin/ld.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld-link: /home/aaupov/local/bin/lld-link llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using ld64.lld: /home/aaupov/local/bin/ld64.lld llvm-lit: /home/aaupov/local/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using wasm-ld: /home/aaupov/local/bin/wasm-ld ... ``` Tested all configurations: - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + no BOLT_*_EXE - LLVM_ENABLE_PROJECTS="bolt;clang" + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;lld" + BOLT_CLANG_EXE - LLVM_ENABLE_PROJECTS="bolt" + BOLT_CLANG_EXE + BOLT_LLD_EXE - LLVM_ENABLE_PROJECTS="bolt;clang;lld" + BOLT_CLANG_EXE + BOLT_LLD_EXE Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D117061
2022-01-15 06:18:43 +08:00
message(WARNING "Not including BOLT tests since clang is disabled. \
Enable clang in LLVM_ENABLE_PROJECTS or provide a path to clang \
binary in BOLT_CLANG_EXE.")
endif()
endif()
if (BOLT_ENABLE_RUNTIME)
message(STATUS "Building BOLT runtime libraries for X86")
ExternalProject_Add(bolt_rt
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
BUILD_ALWAYS True
)
install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"
COMPONENT bolt)
add_llvm_install_targets(install-bolt_rt
DEPENDS bolt_rt bolt
COMPONENT bolt)
endif()
# Get the current git revision for BOLT.
find_program(git_executable NAMES git git.exe git.cmd)
if (git_executable)
execute_process(COMMAND ${git_executable} rev-parse HEAD
WORKING_DIRECTORY ${LLVM_MAIN_SRC_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
if( git_result EQUAL 0 )
string(STRIP "${git_output}" git_ref_id)
set(BOLT_REVISION "${git_ref_id}")
endif()
endif()
# If we can't find a revision, set it to "<unknown>".
if (NOT BOLT_REVISION)
set(BOLT_REVISION "<unknown>")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/bolt/Utils/BoltRevision.inc.in
${CMAKE_CURRENT_BINARY_DIR}/include/bolt/Utils/BoltRevision.inc)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
add_subdirectory(lib)
add_subdirectory(tools)
if (BOLT_INCLUDE_TESTS)
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
add_subdirectory(unittests)
list(APPEND BOLT_TEST_DEPS BoltUnitTests)
endif()
add_subdirectory(test)
endif()
option(BOLT_INCLUDE_DOCS "Generate build targets for the BOLT docs."
${LLVM_INCLUDE_DOCS})
if (BOLT_INCLUDE_DOCS)
add_subdirectory(docs)
endif()