Skip to content

Commit 8d39605

Browse files
authored
[CI] Fix for bazel 8.x (#427)
1 parent 0aa1ffd commit 8d39605

File tree

7 files changed

+71
-20
lines changed

7 files changed

+71
-20
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
matrix:
3030
os: [macos-latest, ubuntu-latest]
3131
# TODO: Test with Bazel 8 after https://github.com/bazelbuild/bazel/pull/24154 has been released.
32-
bazel_version: [7.0.0, latest] # Minimum supported Bazel version is 7.0.0.
32+
bazel_version: [7.x, latest] # Minimum supported Bazel version is 7.x
3333
bzlmod: [true, false]
3434
runs-on: ${{ matrix.os }}
3535
steps:

MODULE.bazel

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
module(
1616
name = "toolchains_llvm",
1717
version = "0.0.0",
18-
compatibility_level = 0,
1918
bazel_compatibility = [">=7.0.0"],
19+
compatibility_level = 0,
2020
)
2121

2222
bazel_dep(name = "bazel_skylib", version = "1.5.0")
23-
bazel_dep(name = "rules_cc", version = "0.0.9")
23+
bazel_dep(name = "rules_cc", version = "0.0.17")
2424
bazel_dep(name = "platforms", version = "0.0.8")
25+
26+
# TODO: Remove when protobuf is released with a version of rules_python that supports 8.x
27+
bazel_dep(name = "rules_python", version = "1.0.0", dev_dependency = True)

tests/MODULE.bazel

+23-13
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ bazel_dep(name = "rules_rust", version = "0.54.1")
2828
bazel_dep(name = "rules_foreign_cc", version = "0.13.0")
2929
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")
3030

31+
# TODO: Remove when protobuf is released with a version of rules_python that supports 8.x
32+
bazel_dep(name = "rules_python", version = "1.0.0")
33+
3134
# As a workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/1018.
3235
rules_foreign_cc_tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
3336
use_repo(rules_foreign_cc_tools, ninja_mac = "ninja_1.12.1_mac")
37+
3438
register_toolchains(
3539
"//:ninja_mac_arm64_toolchain",
3640
)
@@ -66,28 +70,29 @@ LLVM_VERSIONS = {
6670

6771
llvm.toolchain(
6872
name = "llvm_toolchain",
69-
llvm_versions = LLVM_VERSIONS,
7073
cxx_standard = {"": "c++17"},
74+
llvm_versions = LLVM_VERSIONS,
7175
)
7276
llvm.extra_target_compatible_with(
7377
name = "llvm_toolchain",
7478
constraints = ["@//:cxx17"],
7579
)
7680
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")
81+
7782
register_toolchains("@llvm_toolchain//:all")
7883

7984
llvm.toolchain(
8085
name = "llvm_toolchain_cxx20",
81-
llvm_versions = LLVM_VERSIONS,
8286
cxx_standard = {"": "c++20"},
87+
llvm_versions = LLVM_VERSIONS,
8388
)
8489
llvm.extra_target_compatible_with(
8590
name = "llvm_toolchain_cxx20",
8691
constraints = ["//:cxx20"],
8792
)
8893
use_repo(llvm, "llvm_toolchain_cxx20")
89-
register_toolchains("@llvm_toolchain_cxx20//:all")
9094

95+
register_toolchains("@llvm_toolchain_cxx20//:all")
9196

9297
# Example toolchain with user provided URLs.
9398
# TODO(siddharthab): Add test.
@@ -132,6 +137,7 @@ llvm.toolchain(
132137
absolute_paths = True,
133138
llvm_versions = LLVM_VERSIONS,
134139
)
140+
135141
# We can share the downloaded LLVM distribution with the first configuration.
136142
llvm.toolchain_root(
137143
name = "llvm_toolchain_with_absolute_paths",
@@ -144,6 +150,7 @@ llvm.toolchain(
144150
name = "llvm_toolchain_with_system_llvm",
145151
llvm_versions = LLVM_VERSIONS,
146152
)
153+
147154
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
148155
llvm.toolchain_root(
149156
name = "llvm_toolchain_with_system_llvm",
@@ -156,35 +163,38 @@ llvm.toolchain(
156163
name = "llvm_toolchain_with_sysroot",
157164
llvm_versions = LLVM_VERSIONS,
158165
)
166+
159167
# We can share the downloaded LLVM distribution with the first configuration.
160168
llvm.toolchain_root(
161169
name = "llvm_toolchain_with_sysroot",
162170
label = "@llvm_toolchain_llvm//:BUILD",
163171
)
164172
llvm.sysroot(
165173
name = "llvm_toolchain_with_sysroot",
166-
targets = ["linux-x86_64"],
167174
label = "@org_chromium_sysroot_linux_x64//:sysroot",
175+
targets = ["linux-x86_64"],
168176
)
169177
use_repo(llvm, "llvm_toolchain_with_sysroot")
170-
171178
llvm.toolchain(
172179
name = "llvm_toolchain_linux_exec",
180+
exec_arch = "amd64",
181+
# Option 2:
182+
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
183+
exec_os = "linux",
173184
llvm_version = "17.0.6",
174185
# Option 1:
175186
sha256 = {"": "884ee67d647d77e58740c1e645649e29ae9e8a6fe87c1376be0f3a30f3cc9ab3"},
176187
strip_prefix = {"": "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04"},
177188
urls = {"": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz"]},
178-
# Option 2:
179-
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
180-
exec_os = "linux",
181-
exec_arch = "amd64",
182189
)
183190
use_repo(llvm, "llvm_toolchain_linux_exec")
184191

185192
# Toolchain example for WebAssembly.
186193
llvm.toolchain(
187194
name = "llvm_toolchain_wasm",
195+
libclang_rt = {
196+
"@libclang_rt_wasm32//:libclang_rt.builtins-wasm32.a": "wasm32-unknown-unknown/libclang_rt.builtins.a",
197+
},
188198
# WebAssembly tests use a separate (newer) version of LLVM to exercise
189199
# support for experimental features such as wasm64.
190200
llvm_versions = {
@@ -195,9 +205,6 @@ llvm.toolchain(
195205
"wasm32": "libc",
196206
"wasm64": "none",
197207
},
198-
libclang_rt = {
199-
"@libclang_rt_wasm32//:libclang_rt.builtins-wasm32.a": "wasm32-unknown-unknown/libclang_rt.builtins.a",
200-
},
201208
)
202209
llvm.sysroot(
203210
name = "llvm_toolchain_wasm",
@@ -209,17 +216,20 @@ llvm.sysroot(
209216
label = "@wasi_sdk_sysroots//empty",
210217
targets = ["wasm64"],
211218
)
212-
213219
use_repo(llvm, "llvm_toolchain_wasm")
220+
214221
register_toolchains("@llvm_toolchain_wasm//:all")
215222

216223
wasi_sdk_sysroots = use_repo_rule("//wasm:wasi_sdk.bzl", "wasi_sdk_sysroots")
224+
217225
wasi_sdk_sysroots(name = "wasi_sdk_sysroots")
218226

219227
libclang_rt_wasm32 = use_repo_rule("//wasm:wasi_sdk.bzl", "libclang_rt_wasm32")
228+
220229
libclang_rt_wasm32(name = "libclang_rt_wasm32")
221230

222231
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
232+
223233
# This sysroot is used by github.com/vsco/bazel-toolchains.
224234
http_archive(
225235
name = "org_chromium_sysroot_linux_x64",

tests/WORKSPACE

+32
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ rules_rust_dependencies()
250250

251251
rust_register_toolchains()
252252

253+
http_archive(
254+
name = "rules_python",
255+
sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
256+
strip_prefix = "rules_python-1.0.0",
257+
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
258+
)
259+
260+
load("@rules_python//python:repositories.bzl", "py_repositories")
261+
262+
py_repositories()
263+
253264
# For testing rules_foreign_cc.
254265
# See https://bazelbuild.github.io/rules_foreign_cc/0.6.0/cmake.html
255266

@@ -260,6 +271,27 @@ http_archive(
260271
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.13.0.tar.gz",
261272
)
262273

274+
http_archive(
275+
name = "com_google_protobuf",
276+
sha256 = "537d1c4edb6cbfa96d98a021650e3c455fffcf80dbdcea7fe46cb356e6e9732d",
277+
strip_prefix = "protobuf-29.0-rc3",
278+
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v29.0-rc3/protobuf-29.0-rc3.zip"],
279+
)
280+
281+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
282+
283+
protobuf_deps()
284+
285+
http_archive(
286+
name = "rules_java",
287+
sha256 = "6d8c6d5cd86fed031ee48424f238fa35f33abc9921fd97dd4ae1119a29fc807f",
288+
urls = ["https://github.com/bazelbuild/rules_java/releases/download/8.6.3/rules_java-8.6.3.tar.gz"],
289+
)
290+
291+
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
292+
293+
rules_java_dependencies()
294+
263295
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
264296

265297
rules_foreign_cc_dependencies()

tests/scripts/bazel.sh

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ readonly bazel
3838

3939
common_args=(
4040
"--enable_bzlmod=${USE_BZLMOD:-true}"
41+
"--enable_workspace"
4142
)
4243

4344
# shellcheck disable=SC2034

tests/scripts/run_external_tests.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ cd "${scripts_dir}"
2424
# Generate some files needed for the tests.
2525
"${bazel}" query "${common_args[@]}" @io_bazel_rules_go//tests/core/cgo:dylib_test >/dev/null
2626
if [[ ${USE_BZLMOD} == "true" ]]; then
27-
"$("${bazel}" info output_base)/external/rules_go~/tests/core/cgo/generate_imported_dylib.sh"
27+
script="$("${bazel}" info output_base)/external/rules_go~/tests/core/cgo/generate_imported_dylib.sh"
28+
if [[ -f "${script}" ]]; then
29+
"${script}"
30+
else
31+
"$("${bazel}" info output_base)/external/rules_go+/tests/core/cgo/generate_imported_dylib.sh"
32+
fi
2833
else
2934
"$("${bazel}" info output_base)/external/io_bazel_rules_go/tests/core/cgo/generate_imported_dylib.sh"
3035
fi

toolchain/deps.bzl

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def bazel_toolchain_dependencies():
1919
if not native.existing_rule("rules_cc"):
2020
http_archive(
2121
name = "rules_cc",
22-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
23-
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
24-
strip_prefix = "rules_cc-0.0.9",
22+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
23+
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
24+
strip_prefix = "rules_cc-0.0.17",
2525
)
2626

2727
# Load bazel_skylib if the user has not defined them.

0 commit comments

Comments
 (0)