Skip to content

Commit 121f5a9

Browse files
wenju-heCopilot
andauthored
[libclc] Enable LLVM_RUNTIME_TARGETS in build system (llvm#189892)
libclc target is now passed in from LLVM_RUNTIME_TARGETS. The old configure flow based on `-DLLVM_ENABLE_RUNTIMES=libclc` is deprecated because libclc no longer has a default target. `-DLLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="<target-triple>"` still works but it is considered legacy. The new standard build requires: Each target must now be selected explicitly on the CMake command line through the runtimes target-specific cache entry and LLVM_RUNTIME_TARGETS. For example: -DRUNTIMES_amdgcn-amd-amdhsa-llvm_LLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="amdgcn-amd-amdhsa-llvm" -DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="nvptx64-nvidia-cuda" -DRUNTIMES_clspv--_LLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="clspv--" -DRUNTIMES_clspv64--_LLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="clspv64--" -DRUNTIMES_spirv-mesa3d-_LLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="spirv-mesa3d-" -DRUNTIMES_spirv64-mesa3d-_LLVM_ENABLE_RUNTIMES=libclc -DLLVM_RUNTIME_TARGETS="spirv64-mesa3d-" To build multiple targets, pass them as a semicolon-separated list in `LLVM_RUNTIME_TARGETS` and provide a matching `RUNTIMES_<target-triple>_LLVM_ENABLE_RUNTIMES=libclc` entry for each target. Updated README.md to document the new build flow. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 507d823 commit 121f5a9

8 files changed

Lines changed: 289 additions & 211 deletions

File tree

.ci/compute_projects.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@
9898
"openmp", # https://github.com/google/llvm-premerge-checks/issues/410
9999
}
100100

101+
# Runtimes configured for cross-compilation using LLVM_RUNTIME_TARGETS.
102+
# The same build may also use LLVM_ENABLE_RUNTIMES for other runtimes.
103+
CROSS_COMPILATION_RUNTIMES = {
104+
"libclc",
105+
}
106+
101107
EXCLUDE_WINDOWS = {
102108
"cross-project-tests", # TODO(issues/132797): Tests are failing.
103109
"openmp", # TODO(issues/132799): Does not detect perl installation.
@@ -147,7 +153,7 @@
147153
"flang": "check-flang",
148154
"flang-rt": "check-flang-rt",
149155
"libc": "check-libc",
150-
"libclc": "check-libclc",
156+
"libclc": "check-libclc-amdgcn-amd-amdhsa-llvm",
151157
"lld": "check-lld",
152158
"lldb": "check-lldb",
153159
"mlir": "check-mlir",
@@ -276,7 +282,9 @@ def _compute_runtimes_to_build(
276282
for modified_project in modified_projects:
277283
if modified_project in DEPENDENT_RUNTIMES_TO_BUILD:
278284
runtimes_to_build.update(DEPENDENT_RUNTIMES_TO_BUILD[modified_project])
279-
return _exclude_projects(runtimes_to_build, platform)
285+
runtimes_to_build = _exclude_projects(runtimes_to_build, platform)
286+
runtimes_to_build -= CROSS_COMPILATION_RUNTIMES
287+
return runtimes_to_build
280288

281289

282290
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
@@ -320,7 +328,10 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
320328
runtimes_to_build = _compute_runtimes_to_build(
321329
runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, platform
322330
)
323-
projects_to_build = _compute_projects_to_build(projects_to_test, runtimes_to_build)
331+
cross_runtimes_to_test = runtimes_to_test & CROSS_COMPILATION_RUNTIMES
332+
projects_to_build = _compute_projects_to_build(
333+
projects_to_test, runtimes_to_build | cross_runtimes_to_test
334+
)
324335
projects_check_targets = _compute_project_check_targets(projects_to_test)
325336
runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
326337
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(

.ci/compute_projects_test.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ def test_include_libclc_in_runtimes(self):
265265
)
266266
self.assertEqual(env_variables["projects_to_build"], "clang;llvm")
267267
self.assertEqual(env_variables["project_check_targets"], "")
268-
self.assertEqual(env_variables["runtimes_to_build"], "libclc")
269-
self.assertEqual(env_variables["runtimes_check_targets"], "check-libclc")
268+
self.assertEqual(env_variables["runtimes_to_build"], "")
269+
self.assertEqual(
270+
env_variables["runtimes_check_targets"],
271+
"check-libclc-amdgcn-amd-amdhsa-llvm",
272+
)
270273
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
271274

272275
def test_exclude_docs(self):
@@ -303,11 +306,11 @@ def test_ci(self):
303306
)
304307
self.assertEqual(
305308
env_variables["runtimes_to_build"],
306-
"compiler-rt;flang-rt;libc;libclc;libcxx;libcxxabi;libunwind",
309+
"compiler-rt;flang-rt;libc;libcxx;libcxxabi;libunwind",
307310
)
308311
self.assertEqual(
309312
env_variables["runtimes_check_targets"],
310-
"check-compiler-rt check-flang-rt check-libc check-libclc",
313+
"check-compiler-rt check-flang-rt check-libc check-libclc-amdgcn-amd-amdhsa-llvm",
311314
)
312315
self.assertEqual(
313316
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -328,11 +331,11 @@ def test_windows_ci(self):
328331
)
329332
self.assertEqual(
330333
env_variables["runtimes_to_build"],
331-
"compiler-rt;libclc",
334+
"compiler-rt",
332335
)
333336
self.assertEqual(
334337
env_variables["runtimes_check_targets"],
335-
"check-compiler-rt check-libclc",
338+
"check-compiler-rt check-libclc-amdgcn-amd-amdhsa-llvm",
336339
)
337340
self.assertEqual(
338341
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -377,11 +380,11 @@ def test_premerge_workflow(self):
377380
)
378381
self.assertEqual(
379382
env_variables["runtimes_to_build"],
380-
"compiler-rt;flang-rt;libc;libclc;libcxx;libcxxabi;libunwind",
383+
"compiler-rt;flang-rt;libc;libcxx;libcxxabi;libunwind",
381384
)
382385
self.assertEqual(
383386
env_variables["runtimes_check_targets"],
384-
"check-compiler-rt check-flang-rt check-libc check-libclc",
387+
"check-compiler-rt check-flang-rt check-libc check-libclc-amdgcn-amd-amdhsa-llvm",
385388
)
386389
self.assertEqual(
387390
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -412,11 +415,11 @@ def test_third_party_benchmark(self):
412415
)
413416
self.assertEqual(
414417
env_variables["runtimes_to_build"],
415-
"compiler-rt;flang-rt;libc;libclc;libcxx;libcxxabi;libunwind",
418+
"compiler-rt;flang-rt;libc;libcxx;libcxxabi;libunwind",
416419
)
417420
self.assertEqual(
418421
env_variables["runtimes_check_targets"],
419-
"check-compiler-rt check-flang-rt check-libc check-libclc",
422+
"check-compiler-rt check-flang-rt check-libc check-libclc-amdgcn-amd-amdhsa-llvm",
420423
)
421424
self.assertEqual(
422425
env_variables["runtimes_check_targets_needs_reconfig"],

.ci/monolithic-linux.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ enable_cir="${6}"
3131

3232
lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests --succinct"
3333

34+
runtime_cmake_args=()
35+
if [[ " ${runtime_targets} " == *" check-libclc-amdgcn-amd-amdhsa-llvm "* ]]; then
36+
runtime_cmake_args+=(
37+
-D RUNTIMES_amdgcn-amd-amdhsa-llvm_LLVM_ENABLE_RUNTIMES=libclc
38+
-D LLVM_RUNTIME_TARGETS="default;amdgcn-amd-amdhsa-llvm"
39+
)
40+
fi
41+
3442
start-group "CMake"
3543

3644
# Set the system llvm-symbolizer as preferred.
@@ -56,14 +64,14 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
5664
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
5765
-D CMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
5866
-D LIBCXX_CXX_ABI=libcxxabi \
59-
-D LIBCLC_TARGETS_TO_BUILD="amdgcn-amd-amdhsa-llvm" \
6067
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
6168
-D LLDB_ENABLE_PYTHON=ON \
6269
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
6370
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
6471
-D CMAKE_EXE_LINKER_FLAGS="-no-pie" \
6572
-D LLVM_ENABLE_WERROR=ON \
66-
-D LLVM_BINUTILS_INCDIR=/usr
73+
-D LLVM_BINUTILS_INCDIR=/usr \
74+
"${runtime_cmake_args[@]}"
6775

6876
start-group "ninja"
6977

.ci/monolithic-windows.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ targets="${2}"
2020
runtimes="${3}"
2121
runtimes_targets="${4}"
2222

23+
runtime_cmake_args=()
24+
if [[ " ${runtimes_targets} " == *" check-libclc-amdgcn-amd-amdhsa-llvm "* ]]; then
25+
runtime_cmake_args+=(
26+
-D RUNTIMES_amdgcn-amd-amdhsa-llvm_LLVM_ENABLE_RUNTIMES=libclc
27+
-D LLVM_RUNTIME_TARGETS="default;amdgcn-amd-amdhsa-llvm"
28+
)
29+
fi
30+
2331
start-group "CMake"
2432
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
2533

@@ -45,11 +53,11 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4553
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
4654
-D CMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
4755
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
48-
-D LIBCLC_TARGETS_TO_BUILD="amdgcn-amd-amdhsa-llvm" \
4956
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
5057
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
5158
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \
52-
-D LLVM_ENABLE_RUNTIMES="${runtimes}"
59+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
60+
"${runtime_cmake_args[@]}"
5361

5462
start-group "ninja"
5563

0 commit comments

Comments
 (0)