Skip to content

Commit 4532273

Browse files
authored
Update llvm version used for tests. (#586)
Allow attribute llvm_versions to specify version requirements. Update some (main and test) dependencies. Mark omp targets as manual (likely to be normal in a follow up). Allow llvm_version to be taken from environment (or bazel command line). This does for newer bazel versions respect hermeticity. Simplify version handling and log the resolution only in one place. Update default llvm target version to "latest:>=17.0.0,<20" (e.g. 19) but allow environment overrides.
1 parent 81082c7 commit 4532273

17 files changed

+146
-57
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
env:
4242
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
4343
USE_BZLMOD: ${{ matrix.bzlmod }}
44-
run: tests/scripts/run_tests.sh
44+
run: tests/scripts/run_tests.sh -O
4545
toolchain_test:
4646
strategy:
4747
fail-fast: false
@@ -123,7 +123,7 @@ jobs:
123123
- name: Test
124124
env:
125125
USE_BZLMOD: ${{ matrix.bzlmod }}
126-
run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_absolute_paths//:cc-toolchain-x86_64-linux
126+
run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_absolute_paths//:cc-toolchain-x86_64-linux -O
127127
sys_paths_test:
128128
strategy:
129129
fail-fast: false
@@ -134,6 +134,7 @@ jobs:
134134
- uses: actions/checkout@v5
135135
- run: tests/scripts/ubuntu_install_libtinfo.sh
136136
- name: Download and Extract LLVM distribution
137+
# The downloaded version here must match version specified as '-v' arg to run_tests.sh below.
137138
env:
138139
release: llvmorg-16.0.0
139140
archive: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04
@@ -143,4 +144,4 @@ jobs:
143144
- name: Test
144145
env:
145146
USE_BZLMOD: ${{ matrix.bzlmod }}
146-
run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_system_llvm//:cc-toolchain-x86_64-linux
147+
run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_system_llvm//:cc-toolchain-x86_64-linux -v 16.0.0

MODULE.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ module(
2020
)
2121

2222
bazel_dep(name = "bazel_features", version = "1.38.0")
23-
bazel_dep(name = "bazel_skylib", version = "1.5.0")
24-
bazel_dep(name = "aspect_bazel_lib", version = "2.0.0")
25-
bazel_dep(name = "rules_cc", version = "0.2.2")
26-
bazel_dep(name = "platforms", version = "0.0.8")
23+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
24+
bazel_dep(name = "aspect_bazel_lib", version = "2.19.3")
25+
bazel_dep(name = "rules_cc", version = "0.2.8")
26+
bazel_dep(name = "platforms", version = "1.0.0")
2727
bazel_dep(name = "helly25_bzl", version = "0.3.1")
2828

2929
bazel_dep(name = "tar.bzl", version = "0.6.0")

tests/BUILD.bazel

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ build_test(
8181
dwp_file(
8282
name = "stdlib.dwp",
8383
src = ":stdlib_bin",
84-
# NOTE: we should eventually we able to drop this; see #109.
84+
# NOTE: we should eventually be able to drop this; see #109.
8585
override_compilation_mode = "dbg",
8686
target_compatible_with = [
8787
"@platforms//os:linux",
@@ -101,6 +101,7 @@ cc_test(
101101
srcs = ["omp_test.c"],
102102
copts = ["-fopenmp"],
103103
linkopts = ["-fopenmp"],
104+
tags = ["manual"],
104105
deps = ["@llvm_toolchain//:omp"],
105106
)
106107

@@ -114,9 +115,19 @@ cc_test(
114115
srcs = ["omp_test.cc"],
115116
copts = ["-fopenmp"],
116117
linkopts = ["-fopenmp"],
118+
tags = ["manual"],
117119
deps = ["@llvm_toolchain//:omp"],
118120
)
119121

122+
test_suite(
123+
name = "omp_tests",
124+
tags = ["manual"],
125+
tests = [
126+
":omp_test",
127+
":omp_test_cc",
128+
],
129+
)
130+
120131
sh_test(
121132
name = "file_dependency_test",
122133
srcs = ["file_dependency_test.sh"],

tests/MODULE.bazel

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ local_path_override(
2222

2323
bazel_dep(name = "bazel_skylib", version = "1.8.2")
2424
bazel_dep(name = "platforms", version = "1.0.0")
25-
bazel_dep(name = "rules_cc", version = "0.0.9")
25+
bazel_dep(name = "rules_cc", version = "0.2.8")
2626
bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go")
2727
bazel_dep(name = "rules_rust", version = "0.67.0")
2828
bazel_dep(name = "rules_foreign_cc", version = "0.15.0")
@@ -63,10 +63,13 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
6363
# When updating this version, also update the versions associated with
6464
# llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test
6565
# through the `llvm_toolchain_with_sysroot` toolchain.
66+
# We use C++17 and the first LLVM version with full support is 16.0.0.
67+
# We also use C++20 which has reasonable wide support starting with LLVM 17.0.0.
68+
# MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well.
69+
# We also allow to override this with a environment LLVM_VERSION for testing.
6670
LLVM_VERSIONS = {
67-
"": "16.0.0",
68-
"darwin-aarch64": "16.0.5",
69-
"darwin-x86_64": "15.0.7",
71+
"": "getenv(LLVM_VERSION,latest:>=17.0.0,<20)",
72+
"darwin-x86_64": "15.0.7", # Verify this works as opposed to using one version.
7073
}
7174

7275
llvm.toolchain(
@@ -147,9 +150,10 @@ llvm.toolchain_root(
147150
use_repo(llvm, "llvm_toolchain_with_absolute_paths")
148151

149152
# Toolchain example with system LLVM; tested in GitHub CI.
153+
# The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test
150154
llvm.toolchain(
151155
name = "llvm_toolchain_with_system_llvm",
152-
llvm_versions = LLVM_VERSIONS,
156+
llvm_versions = {"": "16.0.0"},
153157
)
154158

155159
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.

tests/WORKSPACE

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
5959
# When updating this version, also update the versions associated with
6060
# llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test
6161
# through the `llvm_toolchain_with_sysroot` toolchain.
62+
# We use C++17 and the first LLVM version with full suppor is 16.0.0.
63+
# We also use C++20 which has reasonable wide support starting with LLVM 17.0.0.
64+
# MacOS X86 does not exist for LLVM 17 or 18, so we allow 19 as well.
65+
# We also allow to override this with a environment LLVM_VERSION for testing.
6266
LLVM_VERSIONS = {
63-
"": "16.0.0",
64-
"darwin-aarch64": "16.0.5",
65-
"darwin-x86_64": "15.0.7",
67+
"": "getenv(LLVM_VERSION,latest:>=17.0.0,<20)",
68+
"darwin-x86_64": "15.0.7", # Verify this works as opposed to using one version.
6669
}
6770

6871
llvm_toolchain(
@@ -134,9 +137,10 @@ llvm_toolchain(
134137
)
135138

136139
## Toolchain example with system LLVM; tested in GitHub CI.
140+
# The llvm_version must match the version specified in .github/workflows/tests.yml: sys_paths_test
137141
llvm_toolchain(
138142
name = "llvm_toolchain_with_system_llvm",
139-
llvm_versions = LLVM_VERSIONS,
143+
llvm_version = "getenv(LLVM_VERSION)",
140144
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
141145
toolchain_roots = {"": "/opt/llvm-16"},
142146
)

tests/scripts/archlinux_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ set -exuo pipefail
3232
3333
# Run tests
3434
cd /src
35-
tests/scripts/run_tests.sh -t ${toolchain}
35+
tests/scripts/run_tests.sh -O -t ${toolchain}
3636
"""
3737
done

tests/scripts/debian_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ apt-get -qq -y install curl libtinfo5 libxml2 zlib1g-dev >/dev/null
3636
3737
# Run tests
3838
cd /src
39-
tests/scripts/run_tests.sh
39+
tests/scripts/run_tests.sh -O
4040
"""
4141
done

tests/scripts/fedora_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ dnf install -qy glibc-headers ncurses-compat-libs
3232
3333
# Run tests
3434
cd /src
35-
tests/scripts/run_tests.sh
35+
tests/scripts/run_tests.sh -O
3636
"""
3737
done

tests/scripts/linux_sysroot_test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ images=(
1919
"ubuntu:22.04"
2020
)
2121

22+
LLVM_VERSION="first:>=15.0.0,<17"
23+
2224
git_root=$(git rev-parse --show-toplevel)
2325
readonly git_root
2426

@@ -36,6 +38,6 @@ apt-get -qq -y install curl libtinfo5 libxml2 zlib1g-dev >/dev/null
3638
3739
# Run tests
3840
cd /src
39-
tests/scripts/run_tests.sh -t '@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux'
41+
tests/scripts/run_tests.sh -t '@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux' -v '${LLVM_VERSION}'
4042
"""
4143
done

tests/scripts/run_tests.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,28 @@
1616
set -euo pipefail
1717

1818
toolchain_name=""
19-
disable_wasm_tests=""
19+
enable_omp_targets="1"
20+
enable_wasm_tests="1"
21+
LLVM_VERSION=""
2022

21-
while getopts "t:hW" opt; do
23+
while getopts "hOt:v:W" opt; do
2224
case "${opt}" in
23-
"t") toolchain_name="${OPTARG}" ;;
2425
"h")
2526
echo "Usage:"
2627
echo "-t - Toolchain name to use for testing; default is llvm_toolchain"
2728
exit 2
2829
;;
30+
"O")
31+
enable_omp_targets=""
32+
;;
33+
"t")
34+
toolchain_name="${OPTARG}"
35+
;;
36+
"v")
37+
LLVM_VERSION="${OPTARG}"
38+
;;
2939
"W")
30-
disable_wasm_tests="yes"
40+
enable_wasm_tests=""
3141
;;
3242
*)
3343
echo "invalid option: -${OPTARG}"
@@ -56,10 +66,21 @@ targets=(
5666
# :test_cxx_standard_is_20 builds with a version of the default toolchain, if
5767
# we're trying to build with a different toolchain then it's likely the default
5868
# toolchain won't work so :test_cxx_standard_is_20 won't build.
59-
if [[ -z ${toolchain_name} ]]; then
69+
if [[ -z "${toolchain_name}" ]]; then
6070
targets+=("//:test_cxx_standard_is_20")
6171
fi
6272

73+
if [[ -n "${enable_omp_targets}" ]]; then
74+
targets+=("//:omp_tests")
75+
fi
76+
77+
if [[ -n "${LLVM_VERSION}" ]]; then
78+
echo "LLVM_VERSION=${LLVM_VERSION}"
79+
common_test_args+=(
80+
"--repo_env=LLVM_VERSION=${LLVM_VERSION}"
81+
)
82+
fi
83+
6384
"${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \
6485
"${common_test_args[@]}" "${test_args[@]}" "${targets[@]}"
6586

@@ -72,7 +93,7 @@ fi
7293
# to run out of disk space.
7394
#
7495
# Mitigate this by expunging the workspace before trying to build Wasm targets.
75-
if [[ -z ${toolchain_name} && -z ${disable_wasm_tests} ]]; then
96+
if [[ -z "${toolchain_name}" ]] && [[ -n "${enable_wasm_tests}" ]]; then
7697
# Redefine `test_args` without `--linkopt=-Wl,-v`, which breaks `wasm-ld`.
7798
#
7899
# https://github.com/llvm/llvm-project/issues/112836

0 commit comments

Comments
 (0)