From fd2e32323361f0eb65b86a863b0070a8daf97c03 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 26 Oct 2025 11:48:27 +0100 Subject: [PATCH 01/19] Update llvm versions for tests to at least 17.0.0. Allow attribute llvm_versions to accept version requirements. --- tests/MODULE.bazel | 6 +++--- tests/WORKSPACE | 6 +++--- toolchain/internal/llvm_distributions.bzl | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 711f279f..f7b6f75f 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -63,10 +63,10 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") # When updating this version, also update the versions associated with # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # through the `llvm_toolchain_with_sysroot` toolchain. +# We use C++17 and the first LLVM version with full suppor is 16.0.0. +# We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. LLVM_VERSIONS = { - "": "16.0.0", - "darwin-aarch64": "16.0.5", - "darwin-x86_64": "15.0.7", + "": "first:>=17.0.0,<18", } llvm.toolchain( diff --git a/tests/WORKSPACE b/tests/WORKSPACE index 93ea6b38..aeea1dd9 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -48,10 +48,10 @@ load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") # When updating this version, also update the versions associated with # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # through the `llvm_toolchain_with_sysroot` toolchain. +# We use C++17 and the first LLVM version with full suppor is 16.0.0. +# We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. LLVM_VERSIONS = { - "": "16.0.0", - "darwin-aarch64": "16.0.5", - "darwin-x86_64": "15.0.7", + "": "first:>=17.0.0,<18", } llvm_toolchain( diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index 2721b7ca..076d7988 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1160,10 +1160,11 @@ def _required_llvm_release_name(*, version_or_requirements, all_llvm_distributio return None, None, "ERROR: No matching distribution found." def required_llvm_release_name_rctx(rctx, llvm_version): + print("Determining required LLVM release for version/requirement: %s" % llvm_version) # buildifier: disable=print all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, - parsed_llvm_version = _parse_version(llvm_version), + parsed_llvm_version = _parse_version(llvm_version) if not is_requirement(llvm_version) else None, ) return _required_llvm_release_name( version_or_requirements = llvm_version, @@ -1192,7 +1193,7 @@ def _distribution_urls(rctx): all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, - parsed_llvm_version = _parse_version(llvm_version), + parsed_llvm_version = _parse_version(llvm_version) if not is_requirement(llvm_version) else None, ) _, sha256, strip_prefix, _ = _key_attrs(rctx) From 3bf3c6cc583f77b9677fbcf1938b25df27d19448 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 26 Oct 2025 11:50:36 +0100 Subject: [PATCH 02/19] Update llvm version used for tests. Allow attribute llvm_versions to specify version requirements. --- tests/MODULE.bazel | 6 +++--- tests/WORKSPACE | 6 +++--- toolchain/internal/llvm_distributions.bzl | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 711f279f..f7b6f75f 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -63,10 +63,10 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") # When updating this version, also update the versions associated with # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # through the `llvm_toolchain_with_sysroot` toolchain. +# We use C++17 and the first LLVM version with full suppor is 16.0.0. +# We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. LLVM_VERSIONS = { - "": "16.0.0", - "darwin-aarch64": "16.0.5", - "darwin-x86_64": "15.0.7", + "": "first:>=17.0.0,<18", } llvm.toolchain( diff --git a/tests/WORKSPACE b/tests/WORKSPACE index 93ea6b38..aeea1dd9 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -48,10 +48,10 @@ load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") # When updating this version, also update the versions associated with # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # through the `llvm_toolchain_with_sysroot` toolchain. +# We use C++17 and the first LLVM version with full suppor is 16.0.0. +# We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. LLVM_VERSIONS = { - "": "16.0.0", - "darwin-aarch64": "16.0.5", - "darwin-x86_64": "15.0.7", + "": "first:>=17.0.0,<18", } llvm_toolchain( diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index 2721b7ca..076d7988 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1160,10 +1160,11 @@ def _required_llvm_release_name(*, version_or_requirements, all_llvm_distributio return None, None, "ERROR: No matching distribution found." def required_llvm_release_name_rctx(rctx, llvm_version): + print("Determining required LLVM release for version/requirement: %s" % llvm_version) # buildifier: disable=print all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, - parsed_llvm_version = _parse_version(llvm_version), + parsed_llvm_version = _parse_version(llvm_version) if not is_requirement(llvm_version) else None, ) return _required_llvm_release_name( version_or_requirements = llvm_version, @@ -1192,7 +1193,7 @@ def _distribution_urls(rctx): all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, - parsed_llvm_version = _parse_version(llvm_version), + parsed_llvm_version = _parse_version(llvm_version) if not is_requirement(llvm_version) else None, ) _, sha256, strip_prefix, _ = _key_attrs(rctx) From ddfcaecec649c0ccd06485e33355911616a6f078 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 26 Oct 2025 12:07:44 +0100 Subject: [PATCH 03/19] Further bump LLVM versions for tests. --- tests/MODULE.bazel | 3 ++- tests/WORKSPACE | 3 ++- toolchain/internal/llvm_distributions.bzl | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index f7b6f75f..024bad57 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -65,8 +65,9 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") # through the `llvm_toolchain_with_sysroot` toolchain. # We use C++17 and the first LLVM version with full suppor is 16.0.0. # We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. +# MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well. LLVM_VERSIONS = { - "": "first:>=17.0.0,<18", + "": "first:>=17.0.0,<20", } llvm.toolchain( diff --git a/tests/WORKSPACE b/tests/WORKSPACE index aeea1dd9..0f514ec9 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -50,8 +50,9 @@ load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") # through the `llvm_toolchain_with_sysroot` toolchain. # We use C++17 and the first LLVM version with full suppor is 16.0.0. # We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. +# MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well. LLVM_VERSIONS = { - "": "first:>=17.0.0,<18", + "": "first:>=17.0.0,<20", } llvm_toolchain( diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index 076d7988..46e2bf8d 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1160,7 +1160,6 @@ def _required_llvm_release_name(*, version_or_requirements, all_llvm_distributio return None, None, "ERROR: No matching distribution found." def required_llvm_release_name_rctx(rctx, llvm_version): - print("Determining required LLVM release for version/requirement: %s" % llvm_version) # buildifier: disable=print all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, From 3d086912986bdb9dd17219c2d9315a7309166a1b Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 26 Oct 2025 15:09:22 +0100 Subject: [PATCH 04/19] Make some tests explicitly use llvm 16, as they do not yet work with llvm 17+. --- tests/MODULE.bazel | 28 +++++++++++++++++++++++++--- tests/WORKSPACE | 21 +++++++++++++++++++-- tests/scripts/ubuntu_20_04_test.sh | 2 +- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 024bad57..d33a195b 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -63,13 +63,21 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") # When updating this version, also update the versions associated with # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # through the `llvm_toolchain_with_sysroot` toolchain. -# We use C++17 and the first LLVM version with full suppor is 16.0.0. +# We use C++17 and the first LLVM version with full support is 16.0.0. # We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. # MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well. LLVM_VERSIONS = { "": "first:>=17.0.0,<20", } +# Some tests do not yet work with LLVM versions > 16, so we define a separate +# version set. +LLVM_VERSIONS_16 = { + "": "16.0.0", + "darwin-aarch64": "16.0.5", + "darwin-x86_64": "15.0.7", +} + llvm.toolchain( name = "llvm_toolchain", cxx_standard = {"": "c++17"}, @@ -83,6 +91,20 @@ use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm") register_toolchains("@llvm_toolchain//:all") +llvm.toolchain( + name = "llvm_toolchain_16", + cxx_standard = {"": "c++17"}, + llvm_versions = LLVM_VERSIONS_16, +) +llvm.extra_target_compatible_with( + name = "llvm_toolchain_16", + constraints = ["@//:cxx17"], +) +use_repo(llvm, "llvm_toolchain_16") + +register_toolchains("@llvm_toolchain_16//:all") + + llvm.toolchain( name = "llvm_toolchain_cxx20", cxx_standard = {"": "c++20"}, @@ -150,7 +172,7 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths") # Toolchain example with system LLVM; tested in GitHub CI. llvm.toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS, + llvm_versions = LLVM_VERSIONS_16, ) # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. @@ -163,7 +185,7 @@ use_repo(llvm, "llvm_toolchain_with_system_llvm") # Toolchain example with a sysroot. llvm.toolchain( name = "llvm_toolchain_with_sysroot", - llvm_versions = LLVM_VERSIONS, + llvm_versions = LLVM_VERSIONS_16, ) # We can share the downloaded LLVM distribution with the first configuration. diff --git a/tests/WORKSPACE b/tests/WORKSPACE index 0f514ec9..6bd2de0c 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -55,6 +55,14 @@ LLVM_VERSIONS = { "": "first:>=17.0.0,<20", } +# Some tests do not yet work with LLVM versions > 16, so we define a separate +# version set. +LLVM_VERSIONS_16 = { + "": "16.0.0", + "darwin-aarch64": "16.0.5", + "darwin-x86_64": "15.0.7", +} + llvm_toolchain( name = "llvm_toolchain", cxx_standard = {"": "c++17"}, @@ -64,6 +72,15 @@ llvm_toolchain( llvm_versions = LLVM_VERSIONS, ) +llvm_toolchain( + name = "llvm_toolchain_16", + cxx_standard = {"": "c++17"}, + extra_target_compatible_with = { + "": ["@//:cxx17"], + }, + llvm_versions = LLVM_VERSIONS_16, +) + llvm_toolchain( name = "llvm_toolchain_cxx20", cxx_standard = {"": "c++20"}, @@ -126,7 +143,7 @@ llvm_toolchain( ## Toolchain example with system LLVM; tested in GitHub CI. llvm_toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS, + llvm_versions = LLVM_VERSIONS_16, # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. toolchain_roots = {"": "/opt/llvm-16"}, ) @@ -144,7 +161,7 @@ sysroot( llvm_toolchain( name = "llvm_toolchain_with_sysroot", - llvm_versions = LLVM_VERSIONS, + llvm_versions = LLVM_VERSIONS_16, sysroot = { "linux-x86_64": "@org_chromium_sysroot_linux_x64//sysroot", }, diff --git a/tests/scripts/ubuntu_20_04_test.sh b/tests/scripts/ubuntu_20_04_test.sh index 38e6d20e..028b7fc6 100755 --- a/tests/scripts/ubuntu_20_04_test.sh +++ b/tests/scripts/ubuntu_20_04_test.sh @@ -40,6 +40,6 @@ disable_wasm_tests='-W' # Run tests cd /src -tests/scripts/run_tests.sh \${disable_wasm_tests} +tests/scripts/run_tests.sh -t'@llvm_toolchain_16//:cc-toolchain-x86_64-linux' \${disable_wasm_tests} """ done From 4e404751cb9e3a50ef8c40ab329cc44773d617e4 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Mon, 27 Oct 2025 12:08:06 +0100 Subject: [PATCH 05/19] Provide omp dependency via toolchain _name argument in run_tests.sh. --- tests/BUILD.bazel | 23 ++++++++++++++++++++--- tests/scripts/run_tests.sh | 20 +++++++++++++++++--- tests/scripts/ubuntu_20_04_test.sh | 4 +++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 2589ac76..4160369c 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -81,7 +81,7 @@ build_test( dwp_file( name = "stdlib.dwp", src = ":stdlib_bin", - # NOTE: we should eventually we able to drop this; see #109. + # NOTE: we should eventually be able to drop this; see #109. override_compilation_mode = "dbg", target_compatible_with = [ "@platforms//os:linux", @@ -95,13 +95,27 @@ build_test( ], ) +# Define a constraint setting and value for OpenMP testing. +# Use: bazel ... --define omp=toolchain_16 +# The value is provided automatically by the run_tests.sh script and defaults to +# the standard llvm_toolchain'. The script removes the '@' and any target. +constraint_setting(name = "omp") + +constraint_value( + name = "llvm_toolchain_16", + constraint_setting = "omp", +) + # Simple test in C that depends on libomp. cc_test( name = "omp_test", srcs = ["omp_test.c"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], - deps = ["@llvm_toolchain//:omp"], + deps = select({ + ":llvm_toolchain_16": ["@llvm_toolchain_16//:omp"], + "//conditions:default": ["@llvm_toolchain//:omp"], + }), ) # C++ variant of omp_test; needed to check that including the llvm toolchain @@ -114,7 +128,10 @@ cc_test( srcs = ["omp_test.cc"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], - deps = ["@llvm_toolchain//:omp"], + deps = select({ + ":llvm_toolchain_16": ["@llvm_toolchain_16//:omp"], + "//conditions:default": ["@llvm_toolchain//:omp"], + }), ) sh_test( diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index abca1b20..2eedf479 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -18,9 +18,11 @@ set -euo pipefail toolchain_name="" disable_wasm_tests="" -while getopts "t:hW" opt; do +while getopts "t:hOW" opt; do case "${opt}" in - "t") toolchain_name="${OPTARG}" ;; + "t") + toolchain_name="${OPTARG}" + ;; "h") echo "Usage:" echo "-t - Toolchain name to use for testing; default is llvm_toolchain" @@ -56,10 +58,22 @@ targets=( # :test_cxx_standard_is_20 builds with a version of the default toolchain, if # we're trying to build with a different toolchain then it's likely the default # toolchain won't work so :test_cxx_standard_is_20 won't build. -if [[ -z ${toolchain_name} ]]; then +if [[ -z "${toolchain_name}" ]]; then targets+=("//:test_cxx_standard_is_20") fi +# If a toolchain is specified, set up OpenMP dependency accordingly. +# We could just rewrite the BUILD files to depend on the correct omp target, but +# it is preferable to leave the BUILD file alone and instead pass the correct +# target via command line so that the BUILD files can be used in other contexts. +# We do so using a combination of 'constraint_setting' and 'constraint_value' +# whose possible values must be predefined in the BUILD file. Using the defined +# value is only possible by creating a custom rule which is overly complex here. +if [[ -n "${toolchain_name}" ]]; then + omp_target="${toolchain_name/\/\/*/}" + test_args+=("--define omp=${omp_target/#@/}") +fi + "${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \ "${common_test_args[@]}" "${test_args[@]}" "${targets[@]}" diff --git a/tests/scripts/ubuntu_20_04_test.sh b/tests/scripts/ubuntu_20_04_test.sh index 028b7fc6..9ecadbc4 100755 --- a/tests/scripts/ubuntu_20_04_test.sh +++ b/tests/scripts/ubuntu_20_04_test.sh @@ -19,6 +19,8 @@ images=( "ubuntu:20.04" ) +toolchain="@llvm_toolchain_16//:cc-toolchain-x86_64-linux" + git_root=$(git rev-parse --show-toplevel) readonly git_root @@ -40,6 +42,6 @@ disable_wasm_tests='-W' # Run tests cd /src -tests/scripts/run_tests.sh -t'@llvm_toolchain_16//:cc-toolchain-x86_64-linux' \${disable_wasm_tests} +tests/scripts/run_tests.sh -t ${toolchain} \${disable_wasm_tests} """ done From 02bb7ad9496dad9d4d6dc665d44a882ac4ad0a89 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Mon, 27 Oct 2025 12:12:25 +0100 Subject: [PATCH 06/19] Must use two args to provide the define as on the intended machine (unlike mine) we end up getting quotes. --- tests/scripts/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 2eedf479..dc0ac473 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -71,7 +71,7 @@ fi # value is only possible by creating a custom rule which is overly complex here. if [[ -n "${toolchain_name}" ]]; then omp_target="${toolchain_name/\/\/*/}" - test_args+=("--define omp=${omp_target/#@/}") + test_args+=("--define" "omp=${omp_target/#@/}") fi "${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \ From 8bdb19049f91e81600e4fe8b0e9e3ad1a53ec0ff Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 11:07:57 +0100 Subject: [PATCH 07/19] Ubuntu 20.04 does not have newer glibc as required by newer LLVM 16+. So we force version 15 for that. Possibly have to do so for some other tests as well. --- tests/BUILD.bazel | 9 ++++++--- tests/MODULE.bazel | 28 +++++++++++++++------------- tests/WORKSPACE | 10 +++++----- tests/scripts/run_tests.sh | 6 ++++++ tests/scripts/ubuntu_20_04_test.sh | 2 +- 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 4160369c..6d8e7032 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -102,8 +102,9 @@ build_test( constraint_setting(name = "omp") constraint_value( - name = "llvm_toolchain_16", + name = "llvm_toolchain_15", constraint_setting = "omp", + visibility = ["//visibility:public"], ) # Simple test in C that depends on libomp. @@ -113,7 +114,8 @@ cc_test( copts = ["-fopenmp"], linkopts = ["-fopenmp"], deps = select({ - ":llvm_toolchain_16": ["@llvm_toolchain_16//:omp"], + ":llvm_toolchain_15": ["@llvm_toolchain_15//:omp"], + #":llvm_toolchain_with_sysroot": ["@llvm_toolchain_with_sysroot//:omp"], "//conditions:default": ["@llvm_toolchain//:omp"], }), ) @@ -129,7 +131,8 @@ cc_test( copts = ["-fopenmp"], linkopts = ["-fopenmp"], deps = select({ - ":llvm_toolchain_16": ["@llvm_toolchain_16//:omp"], + ":llvm_toolchain_15": ["@llvm_toolchain_15//:omp"], + #":llvm_toolchain_with_sysroot": ["@llvm_toolchain_with_sysroot//:omp"], "//conditions:default": ["@llvm_toolchain//:omp"], }), ) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index d33a195b..3936e2b7 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -22,7 +22,7 @@ local_path_override( bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "platforms", version = "1.0.0") -bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_cc", version = "0.2.8") bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_rust", version = "0.67.0") bazel_dep(name = "rules_foreign_cc", version = "0.15.0") @@ -72,10 +72,9 @@ LLVM_VERSIONS = { # Some tests do not yet work with LLVM versions > 16, so we define a separate # version set. -LLVM_VERSIONS_16 = { - "": "16.0.0", - "darwin-aarch64": "16.0.5", - "darwin-x86_64": "15.0.7", +LLVM_VERSIONS_15 = { + "": "latest:>15.0.0,<16", + "darwin-x86_64": "15.0.7", # Verify this works as opposed to using one version. } llvm.toolchain( @@ -92,17 +91,20 @@ use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm") register_toolchains("@llvm_toolchain//:all") llvm.toolchain( - name = "llvm_toolchain_16", + name = "llvm_toolchain_15", cxx_standard = {"": "c++17"}, - llvm_versions = LLVM_VERSIONS_16, + llvm_versions = LLVM_VERSIONS_15, ) llvm.extra_target_compatible_with( - name = "llvm_toolchain_16", - constraints = ["@//:cxx17"], + name = "llvm_toolchain_15", + constraints = [ + "@//:cxx17", + "//:llvm_toolchain_15", + ], ) -use_repo(llvm, "llvm_toolchain_16") +use_repo(llvm, "llvm_toolchain_15") -register_toolchains("@llvm_toolchain_16//:all") +register_toolchains("@llvm_toolchain_15//:all") llvm.toolchain( @@ -172,7 +174,7 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths") # Toolchain example with system LLVM; tested in GitHub CI. llvm.toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS_16, + llvm_versions = LLVM_VERSIONS_15, ) # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. @@ -185,7 +187,7 @@ use_repo(llvm, "llvm_toolchain_with_system_llvm") # Toolchain example with a sysroot. llvm.toolchain( name = "llvm_toolchain_with_sysroot", - llvm_versions = LLVM_VERSIONS_16, + llvm_versions = LLVM_VERSIONS_15, ) # We can share the downloaded LLVM distribution with the first configuration. diff --git a/tests/WORKSPACE b/tests/WORKSPACE index 6bd2de0c..aee2ad14 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -57,7 +57,7 @@ LLVM_VERSIONS = { # Some tests do not yet work with LLVM versions > 16, so we define a separate # version set. -LLVM_VERSIONS_16 = { +LLVM_VERSIONS_15 = { "": "16.0.0", "darwin-aarch64": "16.0.5", "darwin-x86_64": "15.0.7", @@ -73,12 +73,12 @@ llvm_toolchain( ) llvm_toolchain( - name = "llvm_toolchain_16", + name = "llvm_toolchain_15", cxx_standard = {"": "c++17"}, extra_target_compatible_with = { "": ["@//:cxx17"], }, - llvm_versions = LLVM_VERSIONS_16, + llvm_versions = LLVM_VERSIONS_15, ) llvm_toolchain( @@ -143,7 +143,7 @@ llvm_toolchain( ## Toolchain example with system LLVM; tested in GitHub CI. llvm_toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS_16, + llvm_versions = LLVM_VERSIONS_15, # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. toolchain_roots = {"": "/opt/llvm-16"}, ) @@ -161,7 +161,7 @@ sysroot( llvm_toolchain( name = "llvm_toolchain_with_sysroot", - llvm_versions = LLVM_VERSIONS_16, + llvm_versions = LLVM_VERSIONS_15, sysroot = { "linux-x86_64": "@org_chromium_sysroot_linux_x64//sysroot", }, diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index dc0ac473..2a3021ad 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -72,11 +72,17 @@ fi if [[ -n "${toolchain_name}" ]]; then omp_target="${toolchain_name/\/\/*/}" test_args+=("--define" "omp=${omp_target/#@/}") + common_test_args+=( + "--platforms=@toolchains_llvm//platforms:linux-x86_64" + # "--extra_execution_platforms=@toolchains_llvm//platforms:linux-x86_64" + ) fi "${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \ "${common_test_args[@]}" "${test_args[@]}" "${targets[@]}" +exit + # Note that the following flags are currently known to cause issues in migration tests: # --incompatible_disallow_struct_provider_syntax # https://github.com/bazelbuild/bazel/issues/7347 # --incompatible_no_rule_outputs_param # from rules_rust diff --git a/tests/scripts/ubuntu_20_04_test.sh b/tests/scripts/ubuntu_20_04_test.sh index 9ecadbc4..1e1e380c 100755 --- a/tests/scripts/ubuntu_20_04_test.sh +++ b/tests/scripts/ubuntu_20_04_test.sh @@ -19,7 +19,7 @@ images=( "ubuntu:20.04" ) -toolchain="@llvm_toolchain_16//:cc-toolchain-x86_64-linux" +toolchain="@llvm_toolchain_15//:cc-toolchain-x86_64-linux" git_root=$(git rev-parse --show-toplevel) readonly git_root From 01c66d168f22ae6fb65040ab0e364107150c5a0f Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 11:14:01 +0100 Subject: [PATCH 08/19] Must be one newer... --- tests/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 3936e2b7..2cf2b5fb 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -73,7 +73,7 @@ LLVM_VERSIONS = { # Some tests do not yet work with LLVM versions > 16, so we define a separate # version set. LLVM_VERSIONS_15 = { - "": "latest:>15.0.0,<16", + "": "latest:>15.0.0,<17", "darwin-x86_64": "15.0.7", # Verify this works as opposed to using one version. } From e7b145bf3eca53a67ab1a7bf89d7b5bc9de8e7b3 Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 11:18:24 +0100 Subject: [PATCH 09/19] Missing version piece --- toolchain/internal/repo.bzl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/toolchain/internal/repo.bzl b/toolchain/internal/repo.bzl index 934b5373..3d226e77 100644 --- a/toolchain/internal/repo.bzl +++ b/toolchain/internal/repo.bzl @@ -21,6 +21,8 @@ load( load( "//toolchain/internal:llvm_distributions.bzl", _download_llvm = "download_llvm", + _is_requirement = "is_requirement", + _required_llvm_release_name_rctx = "required_llvm_release_name_rctx", ) _target_pairs = ", ".join(_supported_os_arch_keys()) @@ -425,6 +427,16 @@ def llvm_repo_impl(rctx): _, llvm_version = _exec_os_arch_dict_value(rctx, "llvm_versions") + if _is_requirement(llvm_version): + llvm_version, distribution, error = _required_llvm_release_name_rctx(rctx, llvm_version) + if error: + fail(error) + if llvm_version: + print("\nINFO: Resolved latest LLVM version to {llvm_version}: {distribution}".format( + distribution = distribution, + llvm_version = llvm_version, + )) # buildifier: disable=print + major_llvm_version = int(llvm_version.split(".")[0]) rctx.file( From e382ab4a4a01cba3f08a367c97b659af523d84c0 Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 16:27:20 +0100 Subject: [PATCH 10/19] Allow to override the LLVM_VERSION via an environment variable for testing. --- MODULE.bazel | 8 +-- tests/BUILD.bazel | 24 +------- tests/MODULE.bazel | 32 ++--------- tests/WORKSPACE | 25 ++------- tests/scripts/linux_sysroot_test.sh | 4 +- tests/scripts/run_tests.sh | 27 +++++---- tests/scripts/ubuntu_20_04_test.sh | 4 +- toolchain/internal/configure.bzl | 16 ++---- toolchain/internal/llvm_distributions.bzl | 68 ++++++++++++++++++----- toolchain/internal/repo.bzl | 17 +----- 10 files changed, 99 insertions(+), 126 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index fa99a1da..0dc95afb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -20,10 +20,10 @@ module( ) bazel_dep(name = "bazel_features", version = "1.38.0") -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "aspect_bazel_lib", version = "2.0.0") -bazel_dep(name = "rules_cc", version = "0.2.2") -bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "bazel_skylib", version = "1.8.2") +bazel_dep(name = "aspect_bazel_lib", version = "2.19.3") +bazel_dep(name = "rules_cc", version = "0.2.13") +bazel_dep(name = "platforms", version = "1.0.0") bazel_dep(name = "helly25_bzl", version = "0.3.1") bazel_dep(name = "tar.bzl", version = "0.6.0") diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 6d8e7032..a7b02659 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -95,29 +95,13 @@ build_test( ], ) -# Define a constraint setting and value for OpenMP testing. -# Use: bazel ... --define omp=toolchain_16 -# The value is provided automatically by the run_tests.sh script and defaults to -# the standard llvm_toolchain'. The script removes the '@' and any target. -constraint_setting(name = "omp") - -constraint_value( - name = "llvm_toolchain_15", - constraint_setting = "omp", - visibility = ["//visibility:public"], -) - # Simple test in C that depends on libomp. cc_test( name = "omp_test", srcs = ["omp_test.c"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], - deps = select({ - ":llvm_toolchain_15": ["@llvm_toolchain_15//:omp"], - #":llvm_toolchain_with_sysroot": ["@llvm_toolchain_with_sysroot//:omp"], - "//conditions:default": ["@llvm_toolchain//:omp"], - }), + deps = ["@llvm_toolchain//:omp"], ) # C++ variant of omp_test; needed to check that including the llvm toolchain @@ -130,11 +114,7 @@ cc_test( srcs = ["omp_test.cc"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], - deps = select({ - ":llvm_toolchain_15": ["@llvm_toolchain_15//:omp"], - #":llvm_toolchain_with_sysroot": ["@llvm_toolchain_with_sysroot//:omp"], - "//conditions:default": ["@llvm_toolchain//:omp"], - }), + deps = ["@llvm_toolchain//:omp"], ) sh_test( diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 2cf2b5fb..69b20807 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -22,7 +22,7 @@ local_path_override( bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "platforms", version = "1.0.0") -bazel_dep(name = "rules_cc", version = "0.2.8") +bazel_dep(name = "rules_cc", version = "0.2.13") bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_rust", version = "0.67.0") bazel_dep(name = "rules_foreign_cc", version = "0.15.0") @@ -66,14 +66,9 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") # We use C++17 and the first LLVM version with full support is 16.0.0. # We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. # MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well. +# We also allow to override this with a environment LLVM_VERSION for testing. LLVM_VERSIONS = { - "": "first:>=17.0.0,<20", -} - -# Some tests do not yet work with LLVM versions > 16, so we define a separate -# version set. -LLVM_VERSIONS_15 = { - "": "latest:>15.0.0,<17", + "": "getenv(LLVM_VERSION,latest:>=17.0.0,<20)", "darwin-x86_64": "15.0.7", # Verify this works as opposed to using one version. } @@ -90,23 +85,6 @@ use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm") register_toolchains("@llvm_toolchain//:all") -llvm.toolchain( - name = "llvm_toolchain_15", - cxx_standard = {"": "c++17"}, - llvm_versions = LLVM_VERSIONS_15, -) -llvm.extra_target_compatible_with( - name = "llvm_toolchain_15", - constraints = [ - "@//:cxx17", - "//:llvm_toolchain_15", - ], -) -use_repo(llvm, "llvm_toolchain_15") - -register_toolchains("@llvm_toolchain_15//:all") - - llvm.toolchain( name = "llvm_toolchain_cxx20", cxx_standard = {"": "c++20"}, @@ -174,7 +152,7 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths") # Toolchain example with system LLVM; tested in GitHub CI. llvm.toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS_15, + llvm_versions = LLVM_VERSIONS, ) # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. @@ -187,7 +165,7 @@ use_repo(llvm, "llvm_toolchain_with_system_llvm") # Toolchain example with a sysroot. llvm.toolchain( name = "llvm_toolchain_with_sysroot", - llvm_versions = LLVM_VERSIONS_15, + llvm_versions = LLVM_VERSIONS, ) # We can share the downloaded LLVM distribution with the first configuration. diff --git a/tests/WORKSPACE b/tests/WORKSPACE index b0414b2f..cdaa0bee 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -62,16 +62,10 @@ load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") # We use C++17 and the first LLVM version with full suppor is 16.0.0. # We also use C++20 which has reasonable wide support starting with LLVM 17.0.0. # MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well. +# We also allow to override this with a environment LLVM_VERSION for testing. LLVM_VERSIONS = { - "": "first:>=17.0.0,<20", -} - -# Some tests do not yet work with LLVM versions > 16, so we define a separate -# version set. -LLVM_VERSIONS_15 = { - "": "16.0.0", - "darwin-aarch64": "16.0.5", - "darwin-x86_64": "15.0.7", + "": "getenv(LLVM_VERSION,latest:>=17.0.0,<20)", + "darwin-x86_64": "15.0.7", # Verify this works as opposed to using one version. } llvm_toolchain( @@ -83,15 +77,6 @@ llvm_toolchain( llvm_versions = LLVM_VERSIONS, ) -llvm_toolchain( - name = "llvm_toolchain_15", - cxx_standard = {"": "c++17"}, - extra_target_compatible_with = { - "": ["@//:cxx17"], - }, - llvm_versions = LLVM_VERSIONS_15, -) - llvm_toolchain( name = "llvm_toolchain_cxx20", cxx_standard = {"": "c++20"}, @@ -154,7 +139,7 @@ llvm_toolchain( ## Toolchain example with system LLVM; tested in GitHub CI. llvm_toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS_15, + llvm_versions = LLVM_VERSIONS, # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. toolchain_roots = {"": "/opt/llvm-16"}, ) @@ -172,7 +157,7 @@ sysroot( llvm_toolchain( name = "llvm_toolchain_with_sysroot", - llvm_versions = LLVM_VERSIONS_15, + llvm_versions = LLVM_VERSIONS, sysroot = { "linux-x86_64": "@org_chromium_sysroot_linux_x64//sysroot", }, diff --git a/tests/scripts/linux_sysroot_test.sh b/tests/scripts/linux_sysroot_test.sh index a2935c24..3cbd0d6b 100755 --- a/tests/scripts/linux_sysroot_test.sh +++ b/tests/scripts/linux_sysroot_test.sh @@ -19,6 +19,8 @@ images=( "ubuntu:22.04" ) +LLVM_VERSION="first:>=15.0.0,<17" + git_root=$(git rev-parse --show-toplevel) readonly git_root @@ -36,6 +38,6 @@ apt-get -qq -y install curl libtinfo5 libxml2 zlib1g-dev >/dev/null # Run tests cd /src -tests/scripts/run_tests.sh -t '@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux' +tests/scripts/run_tests.sh -t '@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux' -v '${LLVM_VERSION}' """ done diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 2a3021ad..1fdfd9d2 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -17,17 +17,21 @@ set -euo pipefail toolchain_name="" disable_wasm_tests="" +LLVM_VERSION="" -while getopts "t:hOW" opt; do +while getopts "ht:v:W" opt; do case "${opt}" in - "t") - toolchain_name="${OPTARG}" - ;; "h") echo "Usage:" echo "-t - Toolchain name to use for testing; default is llvm_toolchain" exit 2 ;; + "t") + toolchain_name="${OPTARG}" + ;; + "v") + LLVM_VERSION="${OPTARG}" + ;; "W") disable_wasm_tests="yes" ;; @@ -69,20 +73,21 @@ fi # We do so using a combination of 'constraint_setting' and 'constraint_value' # whose possible values must be predefined in the BUILD file. Using the defined # value is only possible by creating a custom rule which is overly complex here. -if [[ -n "${toolchain_name}" ]]; then - omp_target="${toolchain_name/\/\/*/}" - test_args+=("--define" "omp=${omp_target/#@/}") +#if [[ -n "${toolchain_name}" ]]; then +# omp_target="${toolchain_name/\/\/*/}" +# common_test_args+=("--define" "omp=${omp_target/#@/}") +#fi + +if [[ -n "${LLVM_VERSION}" ]]; then + echo "LLVM_VERSION=${LLVM_VERSION}" common_test_args+=( - "--platforms=@toolchains_llvm//platforms:linux-x86_64" - # "--extra_execution_platforms=@toolchains_llvm//platforms:linux-x86_64" + "--repo_env=LLVM_VERSION=${LLVM_VERSION}" ) fi "${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \ "${common_test_args[@]}" "${test_args[@]}" "${targets[@]}" -exit - # Note that the following flags are currently known to cause issues in migration tests: # --incompatible_disallow_struct_provider_syntax # https://github.com/bazelbuild/bazel/issues/7347 # --incompatible_no_rule_outputs_param # from rules_rust diff --git a/tests/scripts/ubuntu_20_04_test.sh b/tests/scripts/ubuntu_20_04_test.sh index 1e1e380c..a8510a14 100755 --- a/tests/scripts/ubuntu_20_04_test.sh +++ b/tests/scripts/ubuntu_20_04_test.sh @@ -19,7 +19,7 @@ images=( "ubuntu:20.04" ) -toolchain="@llvm_toolchain_15//:cc-toolchain-x86_64-linux" +LLVM_VERSION="first:>=15.0.0,<17" git_root=$(git rev-parse --show-toplevel) readonly git_root @@ -42,6 +42,6 @@ disable_wasm_tests='-W' # Run tests cd /src -tests/scripts/run_tests.sh -t ${toolchain} \${disable_wasm_tests} +tests/scripts/run_tests.sh -v '${LLVM_VERSION}' \${disable_wasm_tests} """ done diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl index 279e1094..45d20556 100644 --- a/toolchain/internal/configure.bzl +++ b/toolchain/internal/configure.bzl @@ -38,7 +38,10 @@ load( _supported_targets = "SUPPORTED_TARGETS", _toolchain_tools = "toolchain_tools", ) -load("//toolchain/internal:llvm_distributions.bzl", "is_requirement", "required_llvm_release_name_rctx") +load( + "//toolchain/internal:llvm_distributions.bzl", + _required_llvm_version_rctx = "required_llvm_version_rctx", +) load( "//toolchain/internal:sysroot.bzl", _default_sysroot_path = "default_sysroot_path", @@ -81,16 +84,7 @@ def llvm_config_impl(rctx): if not toolchain_root: fail("LLVM toolchain root missing for ({}, {})".format(os, arch)) - _, llvm_version = _exec_os_arch_dict_value(rctx, "llvm_versions") - if is_requirement(llvm_version): - llvm_version, distribution, error = required_llvm_release_name_rctx(rctx, llvm_version) - if error: - fail(error) - if llvm_version: - print("\nINFO: Resolved latest LLVM version to {llvm_version}: {distribution}".format( - distribution = distribution, - llvm_version = llvm_version, - )) # buildifier: disable=print + llvm_version = _required_llvm_version_rctx(rctx) if not llvm_version: # LLVM version missing for (os, arch) _empty_repository(rctx) diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index 076d7988..141bb5c8 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1125,12 +1125,21 @@ def _find_llvm_basename_or_error(llvm_version, all_llvm_distributions, host_info return basenames[0], None +def _is_requirement(version_or_requirements): + """Return whether `version_or_requirements` is likely a requirement (True) or should be a version.""" + if version_or_requirements.startswith("getenv("): + return True + for prefix in ["first:", "latest:"]: + if version_or_requirements.startswith(prefix) or version_or_requirements == prefix[:-1]: + return True + return False + def _parse_version_or_requirements(version_or_requirements): - if version_or_requirements in ["latest", "first"]: - return None for prefix in ["latest:", "first:"]: if version_or_requirements.startswith(prefix): return versions.parse_requirements(version_or_requirements.removeprefix(prefix)) + if _is_requirement(version_or_requirements): + return None fail("ERROR: Invalid version requirements: '{version_or_requirements}'.".format( version_or_requirements = version_or_requirements, )) @@ -1159,12 +1168,37 @@ def _required_llvm_release_name(*, version_or_requirements, all_llvm_distributio return llvm_version, basenames[0], None return None, None, "ERROR: No matching distribution found." -def required_llvm_release_name_rctx(rctx, llvm_version): - print("Determining required LLVM release for version/requirement: %s" % llvm_version) # buildifier: disable=print +def _resolve_llvm_version_rctx(rctx, llvm_version): + if llvm_version.startswith("getenv(") and llvm_version.endswith(")"): + env_var = llvm_version[len("getenv("):-1] + if env_var.find(",") >= 0: + env_name, env_default = env_var.split(",", 1) + else: + env_name = env_var + env_default = None + + # We prefer 'repository_ctx.getenv' if it is available (~7.1+) and default + # to accessing the environment directly. The latter breaks "hermeticity". + if hasattr(rctx, "getenv"): + llvm_version = rctx.getenv(env_name, env_default) + elif env_name in rctx.os.environ: + llvm_version = rctx.os.environ[env_name] + else: + llvm_version = env_default + + #print("\nINFO: Read environment variable '{env_var}' = '{llvm_version}'".format( + # env_var = env_var, + # llvm_version = llvm_version, + #)) # buildifier: disable=print + + return llvm_version + +def _required_llvm_release_name_rctx(rctx, llvm_version): + llvm_version = _resolve_llvm_version_rctx(rctx, llvm_version) all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, - parsed_llvm_version = _parse_version(llvm_version) if not is_requirement(llvm_version) else None, + parsed_llvm_version = _parse_version(llvm_version) if not _is_requirement(llvm_version) else None, ) return _required_llvm_release_name( version_or_requirements = llvm_version, @@ -1172,12 +1206,19 @@ def required_llvm_release_name_rctx(rctx, llvm_version): host_info = host_info(rctx), ) -def is_requirement(version_or_requirement): - """Return whether `version_or_requirement` is likely a requirement (True) or should be a version.""" - for prefix in ["first:", "latest:"]: - if version_or_requirement.startswith(prefix) or version_or_requirement == prefix[:-1]: - return True - return False +def required_llvm_version_rctx(rctx): + _, llvm_version = exec_os_arch_dict_value(rctx, "llvm_versions") + if _is_requirement(llvm_version): + llvm_version, distribution, error = _required_llvm_release_name_rctx(rctx, llvm_version) + if error: + fail(error) + if llvm_version: + print("\nINFO: Resolved latest LLVM version for {name} to {llvm_version}: {distribution}".format( + name = rctx.attr.name, + distribution = distribution, + llvm_version = llvm_version, + )) # buildifier: disable=print + return llvm_version def _filter_llvm_distributions(*, llvm_version, all_llvm_distributions): """Return (distribution: sha) entries from `all_llvm_distributions` that match `llvm_version`.""" @@ -1193,13 +1234,14 @@ def _distribution_urls(rctx): all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, - parsed_llvm_version = _parse_version(llvm_version) if not is_requirement(llvm_version) else None, + parsed_llvm_version = _parse_version(llvm_version) if not _is_requirement(llvm_version) else None, ) _, sha256, strip_prefix, _ = _key_attrs(rctx) if rctx.attr.distribution == "auto": rctx_host_info = host_info(rctx) - if is_requirement(llvm_version): + if _is_requirement(llvm_version): + llvm_version = _resolve_llvm_version_rctx(rctx, llvm_version) llvm_version, basename, error = _required_llvm_release_name( version_or_requirements = llvm_version, all_llvm_distributions = all_llvm_distributions, diff --git a/toolchain/internal/repo.bzl b/toolchain/internal/repo.bzl index 3d226e77..99e2ee3d 100644 --- a/toolchain/internal/repo.bzl +++ b/toolchain/internal/repo.bzl @@ -14,15 +14,13 @@ load( "//toolchain/internal:common.bzl", _attr_dict = "attr_dict", - _exec_os_arch_dict_value = "exec_os_arch_dict_value", _os = "os", _supported_os_arch_keys = "supported_os_arch_keys", ) load( "//toolchain/internal:llvm_distributions.bzl", _download_llvm = "download_llvm", - _is_requirement = "is_requirement", - _required_llvm_release_name_rctx = "required_llvm_release_name_rctx", + _required_llvm_version_rctx = "required_llvm_version_rctx", ) _target_pairs = ", ".join(_supported_os_arch_keys()) @@ -425,18 +423,7 @@ def llvm_repo_impl(rctx): rctx.file("BUILD.bazel", executable = False) return None - _, llvm_version = _exec_os_arch_dict_value(rctx, "llvm_versions") - - if _is_requirement(llvm_version): - llvm_version, distribution, error = _required_llvm_release_name_rctx(rctx, llvm_version) - if error: - fail(error) - if llvm_version: - print("\nINFO: Resolved latest LLVM version to {llvm_version}: {distribution}".format( - distribution = distribution, - llvm_version = llvm_version, - )) # buildifier: disable=print - + llvm_version = _required_llvm_version_rctx(rctx) major_llvm_version = int(llvm_version.split(".")[0]) rctx.file( From b4f88242b527fc3b3ccceacf2bac517d2c52fb5c Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 16:37:38 +0100 Subject: [PATCH 11/19] Make omp targets manual and cc back to 2.8 --- tests/BUILD.bazel | 2 ++ tests/MODULE.bazel | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index a7b02659..b5c9fc23 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -101,6 +101,7 @@ cc_test( srcs = ["omp_test.c"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], + tags = ["manual"], deps = ["@llvm_toolchain//:omp"], ) @@ -114,6 +115,7 @@ cc_test( srcs = ["omp_test.cc"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], + tags = ["manual"], deps = ["@llvm_toolchain//:omp"], ) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 69b20807..5dff3113 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -22,7 +22,7 @@ local_path_override( bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "platforms", version = "1.0.0") -bazel_dep(name = "rules_cc", version = "0.2.13") +bazel_dep(name = "rules_cc", version = "0.2.8") bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_rust", version = "0.67.0") bazel_dep(name = "rules_foreign_cc", version = "0.15.0") From 6c54cdb742682031fbc6b6d4fea4300ff7509101 Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 18:44:38 +0100 Subject: [PATCH 12/19] Downgrade. --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 0dc95afb..bc2fafbe 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -22,7 +22,7 @@ module( bazel_dep(name = "bazel_features", version = "1.38.0") bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "aspect_bazel_lib", version = "2.19.3") -bazel_dep(name = "rules_cc", version = "0.2.13") +bazel_dep(name = "rules_cc", version = "0.2.8") bazel_dep(name = "platforms", version = "1.0.0") bazel_dep(name = "helly25_bzl", version = "0.3.1") From 8e45e0a07743d01395d38af1ac0da3c480ef0287 Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 19:09:13 +0100 Subject: [PATCH 13/19] Sync sys version back to 16.0.0 --- .github/workflows/tests.yml | 1 + tests/MODULE.bazel | 3 ++- tests/WORKSPACE | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bc49d9c2..dfa643ca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -134,6 +134,7 @@ jobs: - uses: actions/checkout@v5 - run: tests/scripts/ubuntu_install_libtinfo.sh - name: Download and Extract LLVM distribution + # The downloaded version here must match the llvm_version for llvm_toolchain_with_system_llvm in tests/{MODULE.bazel,WORKSPACE} env: release: llvmorg-16.0.0 archive: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04 diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 5dff3113..fcac3a78 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -150,9 +150,10 @@ llvm.toolchain_root( use_repo(llvm, "llvm_toolchain_with_absolute_paths") # Toolchain example with system LLVM; tested in GitHub CI. +# The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test llvm.toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS, + llvm_versions = "16.0.0", ) # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. diff --git a/tests/WORKSPACE b/tests/WORKSPACE index cdaa0bee..d4be18ed 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -137,9 +137,10 @@ llvm_toolchain( ) ## Toolchain example with system LLVM; tested in GitHub CI. +# The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test llvm_toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = LLVM_VERSIONS, + llvm_versions = "16.0.0", # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. toolchain_roots = {"": "/opt/llvm-16"}, ) From 093df5fa4a54800e970b7ba2112e217593f72b1f Mon Sep 17 00:00:00 2001 From: helly25 Date: Fri, 31 Oct 2025 19:15:09 +0100 Subject: [PATCH 14/19] Oops, versions require a dict. This was not a version attribute. --- tests/MODULE.bazel | 2 +- tests/WORKSPACE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index fcac3a78..ab7af41f 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -153,7 +153,7 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths") # The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test llvm.toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = "16.0.0", + llvm_versions = {"": "16.0.0"}, ) # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. diff --git a/tests/WORKSPACE b/tests/WORKSPACE index d4be18ed..d770103f 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -140,7 +140,7 @@ llvm_toolchain( # The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test llvm_toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = "16.0.0", + llvm_versions = {"": "16.0.0"}, # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. toolchain_roots = {"": "/opt/llvm-16"}, ) From 54ed33bcc6f1164cc3d4e8a1547867aeb7cef7f5 Mon Sep 17 00:00:00 2001 From: helly25 Date: Sat, 1 Nov 2025 11:48:13 +0100 Subject: [PATCH 15/19] Address comments. Check whether all targets support omp again. If that fails we have to add some flags and other tag managment and determine why that is necessary. --- .github/workflows/tests.yml | 4 ++-- tests/BUILD.bazel | 2 -- tests/WORKSPACE | 2 +- tests/scripts/run_tests.sh | 12 ------------ toolchain/internal/llvm_distributions.bzl | 14 ++++++++++---- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dfa643ca..a96ed91a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v5 - run: tests/scripts/ubuntu_install_libtinfo.sh - name: Download and Extract LLVM distribution - # The downloaded version here must match the llvm_version for llvm_toolchain_with_system_llvm in tests/{MODULE.bazel,WORKSPACE} + # The downloaded version here must match version specified as '-v' arg to run_tests.sh below. env: release: llvmorg-16.0.0 archive: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04 @@ -144,4 +144,4 @@ jobs: - name: Test env: USE_BZLMOD: ${{ matrix.bzlmod }} - run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_system_llvm//:cc-toolchain-x86_64-linux + run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_system_llvm//:cc-toolchain-x86_64-linux -v 16.0.0 diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index b5c9fc23..a7b02659 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -101,7 +101,6 @@ cc_test( srcs = ["omp_test.c"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], - tags = ["manual"], deps = ["@llvm_toolchain//:omp"], ) @@ -115,7 +114,6 @@ cc_test( srcs = ["omp_test.cc"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], - tags = ["manual"], deps = ["@llvm_toolchain//:omp"], ) diff --git a/tests/WORKSPACE b/tests/WORKSPACE index d770103f..dd2d2bdb 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -140,7 +140,7 @@ llvm_toolchain( # The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test llvm_toolchain( name = "llvm_toolchain_with_system_llvm", - llvm_versions = {"": "16.0.0"}, + llvm_version = "getenv(LLVM_VERSION)", # For this toolchain to work, the LLVM distribution archive would need to be unpacked here. toolchain_roots = {"": "/opt/llvm-16"}, ) diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 1fdfd9d2..3f51dedd 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -66,18 +66,6 @@ if [[ -z "${toolchain_name}" ]]; then targets+=("//:test_cxx_standard_is_20") fi -# If a toolchain is specified, set up OpenMP dependency accordingly. -# We could just rewrite the BUILD files to depend on the correct omp target, but -# it is preferable to leave the BUILD file alone and instead pass the correct -# target via command line so that the BUILD files can be used in other contexts. -# We do so using a combination of 'constraint_setting' and 'constraint_value' -# whose possible values must be predefined in the BUILD file. Using the defined -# value is only possible by creating a custom rule which is overly complex here. -#if [[ -n "${toolchain_name}" ]]; then -# omp_target="${toolchain_name/\/\/*/}" -# common_test_args+=("--define" "omp=${omp_target/#@/}") -#fi - if [[ -n "${LLVM_VERSION}" ]]; then echo "LLVM_VERSION=${LLVM_VERSION}" common_test_args+=( diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index 141bb5c8..d9eb5421 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1177,6 +1177,12 @@ def _resolve_llvm_version_rctx(rctx, llvm_version): env_name = env_var env_default = None + env_name = env_name.strip(" ") + if not env_var: + fail("ERROR: Bad getenv parameter '{env_var}'.".format( + env_var = env_var, + )) + # We prefer 'repository_ctx.getenv' if it is available (~7.1+) and default # to accessing the environment directly. The latter breaks "hermeticity". if hasattr(rctx, "getenv"): @@ -1186,10 +1192,10 @@ def _resolve_llvm_version_rctx(rctx, llvm_version): else: llvm_version = env_default - #print("\nINFO: Read environment variable '{env_var}' = '{llvm_version}'".format( - # env_var = env_var, - # llvm_version = llvm_version, - #)) # buildifier: disable=print + if not llvm_version: + fail("ERROR: Empty getenv lookup for '{env_var}'.".format( + env_var = env_var, + )) return llvm_version From 3cfd97fc13580bb6874f7afba91d91320c83b68b Mon Sep 17 00:00:00 2001 From: helly25 Date: Sat, 1 Nov 2025 12:18:55 +0100 Subject: [PATCH 16/19] Conditionally run omp_targets --- .github/workflows/tests.yml | 6 +++--- tests/BUILD.bazel | 10 ++++++++++ tests/scripts/run_tests.sh | 14 +++++++++++--- toolchain/internal/llvm_distributions.bzl | 6 +++--- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a96ed91a..e5f1b8a4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,7 @@ jobs: env: USE_BAZEL_VERSION: ${{ matrix.bazel_version }} USE_BZLMOD: ${{ matrix.bzlmod }} - run: tests/scripts/run_tests.sh + run: tests/scripts/run_tests.sh -O toolchain_test: strategy: fail-fast: false @@ -98,7 +98,7 @@ jobs: - name: Test env: USE_BZLMOD: ${{ matrix.bzlmod }} - run: tests/scripts/${{ matrix.script }}_test.sh + run: tests/scripts/${{ matrix.script }}_test.sh ${{ matrix.script == 'ubuntu_20_04' && '' || '-O' }} xcompile_test: strategy: fail-fast: false @@ -123,7 +123,7 @@ jobs: - name: Test env: USE_BZLMOD: ${{ matrix.bzlmod }} - run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_absolute_paths//:cc-toolchain-x86_64-linux + run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_absolute_paths//:cc-toolchain-x86_64-linux -O sys_paths_test: strategy: fail-fast: false diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index a7b02659..836b0f42 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -101,6 +101,7 @@ cc_test( srcs = ["omp_test.c"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], + tags = ["manual"], deps = ["@llvm_toolchain//:omp"], ) @@ -114,9 +115,18 @@ cc_test( srcs = ["omp_test.cc"], copts = ["-fopenmp"], linkopts = ["-fopenmp"], + tags = ["manual"], deps = ["@llvm_toolchain//:omp"], ) +test_suite( + name = "omp_tests", + tests = [ + ":omp_test", + ":omp_test_cc", + ], +) + sh_test( name = "file_dependency_test", srcs = ["file_dependency_test.sh"], diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 3f51dedd..adcd477d 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -16,7 +16,8 @@ set -euo pipefail toolchain_name="" -disable_wasm_tests="" +enable_omp_targets="1" +enable_wasm_tests="1" LLVM_VERSION="" while getopts "ht:v:W" opt; do @@ -26,6 +27,9 @@ while getopts "ht:v:W" opt; do echo "-t - Toolchain name to use for testing; default is llvm_toolchain" exit 2 ;; + "O") + enable_omp_targets="" + ;; "t") toolchain_name="${OPTARG}" ;; @@ -33,7 +37,7 @@ while getopts "ht:v:W" opt; do LLVM_VERSION="${OPTARG}" ;; "W") - disable_wasm_tests="yes" + enable_wasm_tests="" ;; *) echo "invalid option: -${OPTARG}" @@ -66,6 +70,10 @@ if [[ -z "${toolchain_name}" ]]; then targets+=("//:test_cxx_standard_is_20") fi +if [[ -n "${enable_omp_targets}" ]]; then + targets+=("//:omp_tests") +fi + if [[ -n "${LLVM_VERSION}" ]]; then echo "LLVM_VERSION=${LLVM_VERSION}" common_test_args+=( @@ -85,7 +93,7 @@ fi # to run out of disk space. # # Mitigate this by expunging the workspace before trying to build Wasm targets. -if [[ -z ${toolchain_name} && -z ${disable_wasm_tests} ]]; then +if [[ -z "${toolchain_name}" ]] && [[ -n "${enable_wasm_tests}" ]]; then # Redefine `test_args` without `--linkopt=-Wl,-v`, which breaks `wasm-ld`. # # https://github.com/llvm/llvm-project/issues/112836 diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index d9eb5421..e060459d 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1168,7 +1168,7 @@ def _required_llvm_release_name(*, version_or_requirements, all_llvm_distributio return llvm_version, basenames[0], None return None, None, "ERROR: No matching distribution found." -def _resolve_llvm_version_rctx(rctx, llvm_version): +def _resolve_llvm_version_rctx_env(rctx, llvm_version): if llvm_version.startswith("getenv(") and llvm_version.endswith(")"): env_var = llvm_version[len("getenv("):-1] if env_var.find(",") >= 0: @@ -1200,7 +1200,7 @@ def _resolve_llvm_version_rctx(rctx, llvm_version): return llvm_version def _required_llvm_release_name_rctx(rctx, llvm_version): - llvm_version = _resolve_llvm_version_rctx(rctx, llvm_version) + llvm_version = _resolve_llvm_version_rctx_env(rctx, llvm_version) all_llvm_distributions = _get_all_llvm_distributions( llvm_distributions = _llvm_distributions, extra_llvm_distributions = rctx.attr.extra_llvm_distributions, @@ -1246,8 +1246,8 @@ def _distribution_urls(rctx): if rctx.attr.distribution == "auto": rctx_host_info = host_info(rctx) + llvm_version = _resolve_llvm_version_rctx_env(rctx, llvm_version) if _is_requirement(llvm_version): - llvm_version = _resolve_llvm_version_rctx(rctx, llvm_version) llvm_version, basename, error = _required_llvm_release_name( version_or_requirements = llvm_version, all_llvm_distributions = all_llvm_distributions, From 0f9ce9d63e0a21fefd741d4cf83381bad92ffeb4 Mon Sep 17 00:00:00 2001 From: helly25 Date: Sat, 1 Nov 2025 12:22:12 +0100 Subject: [PATCH 17/19] Oversight: Missed adding the O flag in the last commit --- tests/scripts/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index adcd477d..48c50742 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -20,7 +20,7 @@ enable_omp_targets="1" enable_wasm_tests="1" LLVM_VERSION="" -while getopts "ht:v:W" opt; do +while getopts "hOt:v:W" opt; do case "${opt}" in "h") echo "Usage:" From 2c1cba4620544639c67881ef4c963d95e0f0e797 Mon Sep 17 00:00:00 2001 From: helly25 Date: Sat, 1 Nov 2025 12:29:25 +0100 Subject: [PATCH 18/19] Another manual tag is needed --- tests/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 836b0f42..d34b1308 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -121,6 +121,7 @@ cc_test( test_suite( name = "omp_tests", + tags = ["manual"], tests = [ ":omp_test", ":omp_test_cc", From 5c8dd698a7550788957811e5d506b90011739510 Mon Sep 17 00:00:00 2001 From: helly25 Date: Sat, 1 Nov 2025 12:49:22 +0100 Subject: [PATCH 19/19] Manual disabling omp tests and version handling improvements. --- .github/workflows/tests.yml | 2 +- tests/scripts/archlinux_test.sh | 2 +- tests/scripts/debian_test.sh | 2 +- tests/scripts/fedora_test.sh | 2 +- tests/scripts/suse_leap_test.sh | 2 +- tests/scripts/suse_tumbleweed_test.sh | 2 +- tests/scripts/ubuntu_22_04_test.sh | 2 +- toolchain/internal/llvm_distributions.bzl | 4 +++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e5f1b8a4..876da978 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -98,7 +98,7 @@ jobs: - name: Test env: USE_BZLMOD: ${{ matrix.bzlmod }} - run: tests/scripts/${{ matrix.script }}_test.sh ${{ matrix.script == 'ubuntu_20_04' && '' || '-O' }} + run: tests/scripts/${{ matrix.script }}_test.sh xcompile_test: strategy: fail-fast: false diff --git a/tests/scripts/archlinux_test.sh b/tests/scripts/archlinux_test.sh index dd3d4bf1..eb244f4e 100755 --- a/tests/scripts/archlinux_test.sh +++ b/tests/scripts/archlinux_test.sh @@ -32,6 +32,6 @@ set -exuo pipefail # Run tests cd /src -tests/scripts/run_tests.sh -t ${toolchain} +tests/scripts/run_tests.sh -O -t ${toolchain} """ done diff --git a/tests/scripts/debian_test.sh b/tests/scripts/debian_test.sh index c0de9666..0fb2858e 100755 --- a/tests/scripts/debian_test.sh +++ b/tests/scripts/debian_test.sh @@ -36,6 +36,6 @@ apt-get -qq -y install curl libtinfo5 libxml2 zlib1g-dev >/dev/null # Run tests cd /src -tests/scripts/run_tests.sh +tests/scripts/run_tests.sh -O """ done diff --git a/tests/scripts/fedora_test.sh b/tests/scripts/fedora_test.sh index 1cc4cce5..20e31994 100755 --- a/tests/scripts/fedora_test.sh +++ b/tests/scripts/fedora_test.sh @@ -32,6 +32,6 @@ dnf install -qy glibc-headers ncurses-compat-libs # Run tests cd /src -tests/scripts/run_tests.sh +tests/scripts/run_tests.sh -O """ done diff --git a/tests/scripts/suse_leap_test.sh b/tests/scripts/suse_leap_test.sh index 7ba31974..3e3308d5 100755 --- a/tests/scripts/suse_leap_test.sh +++ b/tests/scripts/suse_leap_test.sh @@ -38,6 +38,6 @@ zypper -n install curl gcc libc++1 # Run tests cd /src -tests/scripts/run_tests.sh -t ${toolchain} +tests/scripts/run_tests.sh -O -t ${toolchain} """ done diff --git a/tests/scripts/suse_tumbleweed_test.sh b/tests/scripts/suse_tumbleweed_test.sh index e5d6cd82..07db78a7 100755 --- a/tests/scripts/suse_tumbleweed_test.sh +++ b/tests/scripts/suse_tumbleweed_test.sh @@ -38,6 +38,6 @@ zypper -n install curl gcc libc++1 # Run tests cd /src -tests/scripts/run_tests.sh -t ${toolchain} +tests/scripts/run_tests.sh -O -t ${toolchain} """ done diff --git a/tests/scripts/ubuntu_22_04_test.sh b/tests/scripts/ubuntu_22_04_test.sh index f5341fd8..2e5ff013 100755 --- a/tests/scripts/ubuntu_22_04_test.sh +++ b/tests/scripts/ubuntu_22_04_test.sh @@ -36,6 +36,6 @@ apt-get -qq -y install curl libtinfo5 libxml2 zlib1g-dev >/dev/null # Run tests cd /src -tests/scripts/run_tests.sh +tests/scripts/run_tests.sh -O """ done diff --git a/toolchain/internal/llvm_distributions.bzl b/toolchain/internal/llvm_distributions.bzl index e060459d..6d2f6e79 100644 --- a/toolchain/internal/llvm_distributions.bzl +++ b/toolchain/internal/llvm_distributions.bzl @@ -1138,7 +1138,9 @@ def _parse_version_or_requirements(version_or_requirements): for prefix in ["latest:", "first:"]: if version_or_requirements.startswith(prefix): return versions.parse_requirements(version_or_requirements.removeprefix(prefix)) - if _is_requirement(version_or_requirements): + if version_or_requirements in ["latest", "first"]: + return None + if not _is_requirement(version_or_requirements): return None fail("ERROR: Invalid version requirements: '{version_or_requirements}'.".format( version_or_requirements = version_or_requirements,