Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fd2e323
Update llvm versions for tests to at least 17.0.0.
helly25 Oct 26, 2025
3bf3c6c
Update llvm version used for tests.
helly25 Oct 26, 2025
ddfcaec
Further bump LLVM versions for tests.
helly25 Oct 26, 2025
3d08691
Make some tests explicitly use llvm 16, as they do not yet work with …
helly25 Oct 26, 2025
4e40475
Provide omp dependency via toolchain _name argument in run_tests.sh.
helly25 Oct 27, 2025
02bb7ad
Must use two args to provide the define as on the intended machine (u…
helly25 Oct 27, 2025
8bbaf8f
Merge branch 'bazel-contrib:master' into master
helly25 Oct 28, 2025
b8c2c25
Merge branch 'bazel-contrib:master' into master
helly25 Oct 29, 2025
8bdb190
Ubuntu 20.04 does not have newer glibc as required by newer LLVM 16+.…
helly25 Oct 31, 2025
2abd595
Merge branch 'master' into update/test_llvm
helly25 Oct 31, 2025
01c66d1
Must be one newer...
helly25 Oct 31, 2025
e7b145b
Missing version piece
helly25 Oct 31, 2025
9508749
Merge remote-tracking branch 'origin' into pr/helly25/586
helly25 Oct 31, 2025
e382ab4
Allow to override the LLVM_VERSION via an environment variable for te…
helly25 Oct 31, 2025
b4f8824
Make omp targets manual and cc back to 2.8
helly25 Oct 31, 2025
6c54cdb
Downgrade.
helly25 Oct 31, 2025
8e45e0a
Sync sys version back to 16.0.0
helly25 Oct 31, 2025
093df5f
Oops, versions require a dict. This was not a version attribute.
helly25 Oct 31, 2025
54ed33b
Address comments.
helly25 Nov 1, 2025
3cfd97f
Conditionally run omp_targets
helly25 Nov 1, 2025
0f9ce9d
Oversight: Missed adding the O flag in the last commit
helly25 Nov 1, 2025
2c1cba4
Another manual tag is needed
helly25 Nov 1, 2025
5c8dd69
Manual disabling omp tests and version handling improvements.
helly25 Nov 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 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
Expand All @@ -143,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
8 changes: 4 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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.8")
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")
Expand Down
13 changes: 12 additions & 1 deletion tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -101,6 +101,7 @@ cc_test(
srcs = ["omp_test.c"],
copts = ["-fopenmp"],
linkopts = ["-fopenmp"],
tags = ["manual"],
deps = ["@llvm_toolchain//:omp"],
)

Expand All @@ -114,9 +115,19 @@ cc_test(
srcs = ["omp_test.cc"],
copts = ["-fopenmp"],
linkopts = ["-fopenmp"],
tags = ["manual"],
deps = ["@llvm_toolchain//:omp"],
)

test_suite(
name = "omp_tests",
tags = ["manual"],
tests = [
":omp_test",
":omp_test_cc",
],
)

sh_test(
name = "file_dependency_test",
srcs = ["file_dependency_test.sh"],
Expand Down
14 changes: 9 additions & 5 deletions tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -63,10 +63,13 @@ 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 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 = {
"": "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(
Expand Down Expand Up @@ -147,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.
Expand Down
12 changes: 8 additions & 4 deletions tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ 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.
# 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 = {
"": "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(
Expand Down Expand Up @@ -134,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_version = "getenv(LLVM_VERSION)",
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
toolchain_roots = {"": "/opt/llvm-16"},
)
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/archlinux_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/scripts/debian_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/scripts/fedora_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion tests/scripts/linux_sysroot_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
33 changes: 27 additions & 6 deletions tests/scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,28 @@
set -euo pipefail

toolchain_name=""
disable_wasm_tests=""
enable_omp_targets="1"
enable_wasm_tests="1"
LLVM_VERSION=""

while getopts "t:hW" opt; do
while getopts "hOt: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
;;
"O")
enable_omp_targets=""
;;
"t")
toolchain_name="${OPTARG}"
;;
"v")
LLVM_VERSION="${OPTARG}"
;;
"W")
disable_wasm_tests="yes"
enable_wasm_tests=""
;;
*)
echo "invalid option: -${OPTARG}"
Expand Down Expand Up @@ -56,10 +66,21 @@ 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 [[ -n "${enable_omp_targets}" ]]; then
targets+=("//:omp_tests")
fi

if [[ -n "${LLVM_VERSION}" ]]; then
echo "LLVM_VERSION=${LLVM_VERSION}"
common_test_args+=(
"--repo_env=LLVM_VERSION=${LLVM_VERSION}"
)
fi

"${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \
"${common_test_args[@]}" "${test_args[@]}" "${targets[@]}"

Expand All @@ -72,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
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/suse_leap_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/scripts/suse_tumbleweed_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion tests/scripts/ubuntu_20_04_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ images=(
"ubuntu:20.04"
)

LLVM_VERSION="first:>=15.0.0,<17"

git_root=$(git rev-parse --show-toplevel)
readonly git_root

Expand All @@ -40,6 +42,6 @@ disable_wasm_tests='-W'

# Run tests
cd /src
tests/scripts/run_tests.sh \${disable_wasm_tests}
tests/scripts/run_tests.sh -v '${LLVM_VERSION}' \${disable_wasm_tests}
"""
done
2 changes: 1 addition & 1 deletion tests/scripts/ubuntu_22_04_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 5 additions & 11 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading