Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
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.0.0, latest] # Minimum supported Bazel version is 7.0.0.
bazel_version: [7.x, latest] # Minimum supported Bazel version is 7.x
bzlmod: [true, false]
runs-on: ${{ matrix.os }}
steps:
Expand Down
7 changes: 5 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
module(
name = "toolchains_llvm",
version = "0.0.0",
compatibility_level = 0,
bazel_compatibility = [">=7.0.0"],
compatibility_level = 0,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "platforms", version = "0.0.8")

# 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)
36 changes: 23 additions & 13 deletions tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ bazel_dep(name = "rules_rust", version = "0.54.1")
bazel_dep(name = "rules_foreign_cc", version = "0.13.0")
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")

# 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")

# As a workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/1018.
rules_foreign_cc_tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
use_repo(rules_foreign_cc_tools, ninja_mac = "ninja_1.12.1_mac")

register_toolchains(
"//:ninja_mac_arm64_toolchain",
)
Expand Down Expand Up @@ -66,28 +70,29 @@ LLVM_VERSIONS = {

llvm.toolchain(
name = "llvm_toolchain",
llvm_versions = LLVM_VERSIONS,
cxx_standard = {"": "c++17"},
llvm_versions = LLVM_VERSIONS,
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain",
constraints = ["@//:cxx17"],
)
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")

register_toolchains("@llvm_toolchain//:all")

llvm.toolchain(
name = "llvm_toolchain_cxx20",
llvm_versions = LLVM_VERSIONS,
cxx_standard = {"": "c++20"},
llvm_versions = LLVM_VERSIONS,
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_cxx20",
constraints = ["//:cxx20"],
)
use_repo(llvm, "llvm_toolchain_cxx20")
register_toolchains("@llvm_toolchain_cxx20//:all")

register_toolchains("@llvm_toolchain_cxx20//:all")

# Example toolchain with user provided URLs.
# TODO(siddharthab): Add test.
Expand Down Expand Up @@ -132,6 +137,7 @@ llvm.toolchain(
absolute_paths = True,
llvm_versions = LLVM_VERSIONS,
)

# We can share the downloaded LLVM distribution with the first configuration.
llvm.toolchain_root(
name = "llvm_toolchain_with_absolute_paths",
Expand All @@ -144,6 +150,7 @@ llvm.toolchain(
name = "llvm_toolchain_with_system_llvm",
llvm_versions = LLVM_VERSIONS,
)

# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
llvm.toolchain_root(
name = "llvm_toolchain_with_system_llvm",
Expand All @@ -156,35 +163,38 @@ llvm.toolchain(
name = "llvm_toolchain_with_sysroot",
llvm_versions = LLVM_VERSIONS,
)

# We can share the downloaded LLVM distribution with the first configuration.
llvm.toolchain_root(
name = "llvm_toolchain_with_sysroot",
label = "@llvm_toolchain_llvm//:BUILD",
)
llvm.sysroot(
name = "llvm_toolchain_with_sysroot",
targets = ["linux-x86_64"],
label = "@org_chromium_sysroot_linux_x64//:sysroot",
targets = ["linux-x86_64"],
)
use_repo(llvm, "llvm_toolchain_with_sysroot")

llvm.toolchain(
name = "llvm_toolchain_linux_exec",
exec_arch = "amd64",
# Option 2:
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
exec_os = "linux",
llvm_version = "17.0.6",
# Option 1:
sha256 = {"": "884ee67d647d77e58740c1e645649e29ae9e8a6fe87c1376be0f3a30f3cc9ab3"},
strip_prefix = {"": "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04"},
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"]},
# Option 2:
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
exec_os = "linux",
exec_arch = "amd64",
)
use_repo(llvm, "llvm_toolchain_linux_exec")

# Toolchain example for WebAssembly.
llvm.toolchain(
name = "llvm_toolchain_wasm",
libclang_rt = {
"@libclang_rt_wasm32//:libclang_rt.builtins-wasm32.a": "wasm32-unknown-unknown/libclang_rt.builtins.a",
},
# WebAssembly tests use a separate (newer) version of LLVM to exercise
# support for experimental features such as wasm64.
llvm_versions = {
Expand All @@ -195,9 +205,6 @@ llvm.toolchain(
"wasm32": "libc",
"wasm64": "none",
},
libclang_rt = {
"@libclang_rt_wasm32//:libclang_rt.builtins-wasm32.a": "wasm32-unknown-unknown/libclang_rt.builtins.a",
},
)
llvm.sysroot(
name = "llvm_toolchain_wasm",
Expand All @@ -209,17 +216,20 @@ llvm.sysroot(
label = "@wasi_sdk_sysroots//empty",
targets = ["wasm64"],
)

use_repo(llvm, "llvm_toolchain_wasm")

register_toolchains("@llvm_toolchain_wasm//:all")

wasi_sdk_sysroots = use_repo_rule("//wasm:wasi_sdk.bzl", "wasi_sdk_sysroots")

wasi_sdk_sysroots(name = "wasi_sdk_sysroots")

libclang_rt_wasm32 = use_repo_rule("//wasm:wasi_sdk.bzl", "libclang_rt_wasm32")

libclang_rt_wasm32(name = "libclang_rt_wasm32")

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

# This sysroot is used by github.com/vsco/bazel-toolchains.
http_archive(
name = "org_chromium_sysroot_linux_x64",
Expand Down
32 changes: 32 additions & 0 deletions tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ rules_rust_dependencies()

rust_register_toolchains()

http_archive(
name = "rules_python",
sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
strip_prefix = "rules_python-1.0.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

# For testing rules_foreign_cc.
# See https://bazelbuild.github.io/rules_foreign_cc/0.6.0/cmake.html

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

http_archive(
name = "com_google_protobuf",
sha256 = "537d1c4edb6cbfa96d98a021650e3c455fffcf80dbdcea7fe46cb356e6e9732d",
strip_prefix = "protobuf-29.0-rc3",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v29.0-rc3/protobuf-29.0-rc3.zip"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

http_archive(
name = "rules_java",
sha256 = "6d8c6d5cd86fed031ee48424f238fa35f33abc9921fd97dd4ae1119a29fc807f",
urls = ["https://github.com/bazelbuild/rules_java/releases/download/8.6.3/rules_java-8.6.3.tar.gz"],
)

load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")

rules_java_dependencies()

load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ readonly bazel

common_args=(
"--enable_bzlmod=${USE_BZLMOD:-true}"
"--enable_workspace"
)

# shellcheck disable=SC2034
Expand Down
7 changes: 6 additions & 1 deletion tests/scripts/run_external_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ cd "${scripts_dir}"
# Generate some files needed for the tests.
"${bazel}" query "${common_args[@]}" @io_bazel_rules_go//tests/core/cgo:dylib_test >/dev/null
if [[ ${USE_BZLMOD} == "true" ]]; then
"$("${bazel}" info output_base)/external/rules_go~/tests/core/cgo/generate_imported_dylib.sh"
script="$("${bazel}" info output_base)/external/rules_go~/tests/core/cgo/generate_imported_dylib.sh"
if [[ -f "${script}" ]]; then
"${script}"
else
"$("${bazel}" info output_base)/external/rules_go+/tests/core/cgo/generate_imported_dylib.sh"
fi
else
"$("${bazel}" info output_base)/external/io_bazel_rules_go/tests/core/cgo/generate_imported_dylib.sh"
fi
Expand Down
6 changes: 3 additions & 3 deletions toolchain/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def bazel_toolchain_dependencies():
if not native.existing_rule("rules_cc"):
http_archive(
name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
strip_prefix = "rules_cc-0.0.17",
)

# Load bazel_skylib if the user has not defined them.
Expand Down
Loading