[PATCH] D117061: [BOLT][CMAKE] Accept BOLT_CLANG_EXE and BOLT_LLD_EXE
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 11 15:50:30 PST 2022
Amir created this revision.
Herald added subscribers: pengfei, sunfish, mgorny.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117061
Files:
bolt/CMakeLists.txt
bolt/test/CMakeLists.txt
bolt/test/lit.cfg.py
bolt/test/lit.site.cfg.py.in
Index: bolt/test/lit.site.cfg.py.in
===================================================================
--- bolt/test/lit.site.cfg.py.in
+++ bolt/test/lit.site.cfg.py.in
@@ -19,6 +19,8 @@
config.host_arch = "@HOST_ARCH@"
config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
config.python_executable = "@PYTHON_EXECUTABLE@"
+config.bolt_clang = "@BOLT_CLANG_EXE@"
+config.bolt_lld = "@BOLT_LLD_EXE@"
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
Index: bolt/test/lit.cfg.py
===================================================================
--- bolt/test/lit.cfg.py
+++ bolt/test/lit.cfg.py
@@ -55,8 +55,8 @@
llvm_config.use_default_substitutions()
-llvm_config.use_clang()
-llvm_config.use_lld()
+llvm_config.use_clang(additional_tool_dirs=[os.path.dirname(config.bolt_clang)])
+llvm_config.use_lld(additional_tool_dirs=[os.path.dirname(config.bolt_lld)])
config.substitutions.append(('%cflags', '-no-pie'))
config.substitutions.append(('%cxxflags', '-no-pie'))
Index: bolt/test/CMakeLists.txt
===================================================================
--- bolt/test/CMakeLists.txt
+++ bolt/test/CMakeLists.txt
@@ -13,6 +13,16 @@
bolt_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)
+if (BOLT_CLANG_EXE)
+ add_executable(clang IMPORTED GLOBAL)
+ set_property(TARGET clang PROPERTY IMPORTED_LOCATION "${BOLT_CLANG_EXE}")
+endif()
+
+if (BOLT_LLD_EXE)
+ add_executable(lld IMPORTED GLOBAL)
+ set_property(TARGET lld PROPERTY IMPORTED_LOCATION "${BOLT_LLD_EXE}")
+endif()
+
list(APPEND BOLT_TEST_DEPS
clang
count
Index: bolt/CMakeLists.txt
===================================================================
--- bolt/CMakeLists.txt
+++ bolt/CMakeLists.txt
@@ -9,18 +9,27 @@
set(BOLT_ENABLE_RUNTIME ON)
endif()
+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)
string(FIND "${LLVM_ENABLE_PROJECTS}" "clang" POSITION)
- if (NOT ${POSITION} EQUAL -1)
+ if (NOT ${POSITION} EQUAL -1 OR BOLT_CLANG_EXE)
string(FIND "${LLVM_ENABLE_PROJECTS}" "lld" POSITION)
- if (NOT ${POSITION} EQUAL -1)
+ if (NOT ${POSITION} EQUAL -1 OR BOLT_LLD_EXE)
set(BOLT_INCLUDE_TESTS ON)
else()
- message(WARNING "Not including BOLT tests since lld is disabled")
+ 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()
- message(WARNING "Not including BOLT tests since clang is disabled")
+ 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()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117061.399104.patch
Type: text/x-patch
Size: 3078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220111/82f37554/attachment.bin>
More information about the llvm-commits
mailing list