Skip to content

Implement latest requirements #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
16 changes: 16 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ jobs:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
USE_BZLMOD: ${{ matrix.bzlmod }}
run: tests/scripts/run_tests.sh
toolchain_test:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
# TODO: Test with Bazel 8 after https://github.com/bazelbuild/bazel/pull/24154 has been released.
bazel_version: [7.x, latest] # Minimum supported Bazel version is 7.x
bzlmod: [true, false]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Test
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
USE_BZLMOD: ${{ matrix.bzlmod }}
run: tests/scripts/run_toolchain_tests.sh
external_test:
strategy:
fail-fast: false
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "helly25_bzl", version = "0.1.2")

# TODO: Remove when protobuf is released with a version of rules_python that supports 8.x
bazel_dep(name = "rules_python", version = "1.0.0", dev_dependency = True)
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@
workspace(
name = "toolchains_llvm",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "helly25_bzl",
sha256 = "404f8473bcaad2e370752e57d274d2093eb87ca94cb9a597c1a3553b76743206",
strip_prefix = "bzl-0.1.2",
url = "https://github.com/helly25/bzl/releases/download/0.1.2/bzl-0.1.2.tar.gz",
)
45 changes: 45 additions & 0 deletions tests/scripts/run_toolchain_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# Copyright 2018 The Bazel Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail

while getopts "h" opt; do
case "${opt}" in
"h")
echo "Usage: No options"
exit 2
;;
*)
echo "invalid option: -${OPTARG}"
exit 1
;;
esac
done

scripts_dir="$(dirname "${BASH_SOURCE[0]}")"
source "${scripts_dir}/bazel.sh"
"${bazel}" version

set -x
test_args=(
"--check_direct_dependencies=off"
)

targets=(
"//toolchain/..."
)

"${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \
"${common_test_args[@]}" "${test_args[@]}" "${targets[@]}"
10 changes: 9 additions & 1 deletion toolchain/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ def bazel_toolchain_dependencies():
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
)

# Skip bazel_skylib_workspace because we are not using lib/unittest.bzl
# Skip bazel_skylib_workspace because we are not using lib/unittest.bzl

if not native.existing_rule("helly25_bzl"):
http_archive(
name = "helly25_bzl",
strip_prefix = "bzl-0.1.2",
url = "https://github.com/helly25/bzl/releases/download/0.1.2/bzl-0.1.2.tar.gz",
sha256 = "404f8473bcaad2e370752e57d274d2093eb87ca94cb9a597c1a3553b76743206",
)
27 changes: 27 additions & 0 deletions toolchain/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("llvm_distributions.bzl", "distributions_test_writer", "requirements_test_writer")

exports_files(["template.modulemap"])

distributions_test_writer(
name = "llvm_distributions_test_output",
testonly = True,
visibility = ["//visibility:private"],
)

requirements_test_writer(
name = "llvm_requirements_test_output",
testonly = True,
visibility = ["//visibility:private"],
)

diff_test(
name = "llvm_distributions_test",
file1 = "llvm_distributions_test.golden.txt",
file2 = "llvm_distributions_test_output",
)

diff_test(
name = "llvm_requirements_test",
file1 = "llvm_requirements_test.golden.txt",
file2 = "llvm_requirements_test_output",
)
11 changes: 11 additions & 0 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ load(
_supported_targets = "SUPPORTED_TARGETS",
_toolchain_tools = "toolchain_tools",
)
load(
"//toolchain/internal:llvm_distributions.bzl",
_latest_llvm_release_name_or_fail = "latest_llvm_release_name_or_fail",
)
load(
"//toolchain/internal:sysroot.bzl",
_default_sysroot_path = "default_sysroot_path",
Expand Down Expand Up @@ -79,6 +83,13 @@ def llvm_config_impl(rctx):
if not toolchain_root:
fail("LLVM toolchain root missing for ({}, {})".format(os, arch))
(_key, llvm_version) = _exec_os_arch_dict_value(rctx, "llvm_versions")
if llvm_version.startswith("latest"):
(llvm_version, distribution) = _latest_llvm_release_name_or_fail(rctx, llvm_version)
if llvm_version:
print("\nINFO: Resolved latest LLVM version to {llvm_version}: {distribution}".format(
distribution = distribution,
llvm_version = llvm_version,
)) # buildifier: disable=print
if not llvm_version:
# LLVM version missing for (os, arch)
_empty_repository(rctx)
Expand Down
Loading