-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a fairly straightforward change that adds support for using `bazel-toolchain` with `bzlmod`. The `llvm.toolchain` extension is only a wrapper around the existing `llvm_toolchain` repository rule and supports the same attributes. For trying it out, add the following to your `MODULE.bazel`: ``` bazel_dep(name = "com_grail_bazel_toolchain", version = "0.8") git_override(module_name = "com_grail_bazel_toolchain", remote = "https://github.com/grailbio/bazel-toolchain", commit = "cf915e5c7cfcd19a3e71de54e385e01240b865dc") llvm = use_extension("@com_grail_bazel_toolchain//toolchain:extensions.bzl", "llvm") llvm.toolchain( llvm_version = "15.0.0" ) use_repo(llvm, "llvm_toolchain") register_toolchains("@llvm_toolchain//:all") ``` --------- Co-authored-by: James Sharpe <[email protected]> Co-authored-by: Fabian Meumertzheim <[email protected]> Co-authored-by: Gabriel Féron <[email protected]>
- Loading branch information
1 parent
9d8cc8a
commit 5c6f806
Showing
19 changed files
with
591 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module( | ||
name = "llvm_toolchain", | ||
version = "0.0.0", | ||
compatibility_level = 0, | ||
) | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.4.2") | ||
bazel_dep(name = "rules_cc", version = "0.0.8") | ||
bazel_dep(name = "platforms", version = "0.0.6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
module(name = "com_grail_bazel_toolchain_tests") | ||
|
||
bazel_dep(name = "llvm_toolchain", version = "0.8.2", repo_name = "com_grail_bazel_toolchain") | ||
local_path_override(module_name = "llvm_toolchain", path = "..") | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.4.2") | ||
bazel_dep(name = "platforms", version = "0.0.6") | ||
bazel_dep(name = "rules_cc", version = "0.0.8") | ||
bazel_dep(name = "rules_go", version = "0.40.1", repo_name = "io_bazel_rules_go") | ||
bazel_dep(name = "rules_foreign_cc", version = "0.9.0") | ||
bazel_dep(name = "rules_rust", version = "0.27.0") | ||
|
||
# We have to patch abseil-cpp to add a dep on googletest | ||
bazel_dep(name = "abseil-cpp", repo_name = "com_google_absl") | ||
archive_override(module_name = "abseil-cpp", urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20230125.3.tar.gz"], patches = ["//patches:abseil-cpp.patch"], strip_prefix = "abseil-cpp-20230125.3") | ||
|
||
# Temporary overrides until newer versions of these rulesets are released in the central registry | ||
git_override(module_name = "rules_foreign_cc", remote = "https://github.com/bazelbuild/rules_foreign_cc.git", commit = "6ecc134b114f6e086537f5f0148d166467042226") | ||
git_override(module_name = "rules_rust", remote = "https://github.com/bazelbuild/rules_rust.git", commit = "4dbb81a008f4031c9ad65138fa2a49f32352f80f") | ||
|
||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain(edition = "2021") | ||
use_repo( | ||
rust, | ||
"rust_toolchains", | ||
) | ||
|
||
register_toolchains("@rust_toolchains//:all") | ||
|
||
llvm = use_extension("@com_grail_bazel_toolchain//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. | ||
LLVM_VERSION = "15.0.6" | ||
|
||
llvm.toolchain( | ||
name = "llvm_toolchain", | ||
llvm_versions = { | ||
"": "15.0.6", | ||
"darwin-aarch64": "15.0.7", | ||
"darwin-x86_64": "15.0.7", | ||
}, | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm") | ||
register_toolchains("@llvm_toolchain//:all") | ||
|
||
# Example toolchain with user provided URLs. | ||
# TODO(siddharthab): Add test. | ||
llvm.toolchain( | ||
name = "llvm_toolchain_with_urls", | ||
llvm_versions = { | ||
"": "15.0.6", | ||
"darwin-aarch64": "15.0.7", | ||
"darwin-x86_64": "15.0.7", | ||
}, | ||
sha256 = { | ||
"": "38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036", | ||
"darwin-aarch64": "867c6afd41158c132ef05a8f1ddaecf476a26b91c85def8e124414f9a9ba188d", | ||
"darwin-x86_64": "d16b6d536364c5bec6583d12dd7e6cf841b9f508c4430d9ee886726bd9983f1c", | ||
}, | ||
strip_prefix = { | ||
"": "clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04", | ||
"darwin-aarch64": "clang+llvm-15.0.7-arm64-apple-darwin22.0", | ||
"darwin-x86_64": "clang+llvm-15.0.7-x86_64-apple-darwin21.0", | ||
}, | ||
urls = { | ||
"": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz"], | ||
"darwin-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-arm64-apple-darwin22.0.tar.xz"], | ||
"darwin-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz"], | ||
}, | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain_with_urls") | ||
|
||
# # This is the latest version of LLVM that seems to work with rules_go; later | ||
# # versions cause the tests to crash. | ||
llvm.toolchain( | ||
name = "llvm_toolchain_14_0_0", | ||
llvm_version = "14.0.0", | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain_14_0_0") | ||
|
||
# # This is the last known LLVM version with zlib support in ld.lld. Without zlib | ||
# # support, if the installed gcc toolchain has compressed sections in its object | ||
# # files, then ld.lld won't be able to process them. Example is archlinux docker | ||
# # image base-devel as of the time of this writing (23 May 2022). | ||
llvm.toolchain( | ||
name = "llvm_toolchain_13_0_0", | ||
llvm_version = "13.0.0", | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain_13_0_0") | ||
|
||
# ## Toolchain example with absolute paths; tested in GitHub CI. | ||
llvm.toolchain( | ||
name = "llvm_toolchain_with_absolute_paths", | ||
absolute_paths = True, | ||
llvm_version = LLVM_VERSION, | ||
# We can share the downloaded LLVM distribution with the first configuration. | ||
toolchain_roots = { | ||
"": "@llvm_toolchain_llvm//", | ||
}, | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain_with_absolute_paths") | ||
|
||
# ## Toolchain example with system LLVM; tested in GitHub CI. | ||
llvm.toolchain( | ||
name = "llvm_toolchain_with_system_llvm", | ||
llvm_version = LLVM_VERSION, | ||
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here. | ||
# A path in /tmp to be part of system tmp cleanup schedule. | ||
toolchain_roots = {"": "/tmp/llvm-15"}, | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain_with_system_llvm") | ||
|
||
# ## Toolchain example with a sysroot. | ||
|
||
llvm.toolchain( | ||
name = "llvm_toolchain_with_sysroot", | ||
llvm_versions = { | ||
"": "15.0.6", | ||
"darwin-x86_64": "15.0.7", | ||
"darwin-aarch64": "15.0.7", | ||
}, | ||
sysroot = { | ||
"linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot", | ||
}, | ||
# We can share the downloaded LLVM distribution with the first configuration. | ||
toolchain_roots = { | ||
"": "@llvm_toolchain_llvm//", | ||
}, | ||
) | ||
|
||
use_repo(llvm, "llvm_toolchain_with_sysroot") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
workspace(name = "com_grail_bazel_toolchain_tests") | ||
|
||
load("@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", | ||
build_file_content = """ | ||
filegroup( | ||
name = "sysroot", | ||
srcs = glob(["*/**"]), | ||
visibility = ["//visibility:public"], | ||
) | ||
""", | ||
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3", | ||
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"], | ||
) | ||
|
||
# Well known repos; present here only for testing. | ||
|
||
http_archive( | ||
name = "com_github_google_benchmark", | ||
sha256 = "6430e4092653380d9dc4ccb45a1e2dc9259d581f4866dc0759713126056bc1d7", | ||
strip_prefix = "benchmark-1.7.1", | ||
urls = ["https://github.com/google/benchmark/archive/v1.7.1.tar.gz"], | ||
) | ||
|
||
http_archive( | ||
name = "openssl", | ||
build_file = "//openssl:openssl.bazel", | ||
sha256 = "f6fb3079ad15076154eda9413fed42877d668e7069d9b87396d0804fdb3f4c90", | ||
strip_prefix = "openssl-1.1.1c", | ||
urls = ["https://www.openssl.org/source/openssl-1.1.1c.tar.gz"], | ||
) | ||
|
||
_ALL_CONTENT = """\ | ||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
visibility = ["//visibility:public"], | ||
) | ||
""" | ||
|
||
http_archive( | ||
name = "pcre", | ||
build_file_content = _ALL_CONTENT, | ||
sha256 = "0b8e7465dc5e98c757cc3650a20a7843ee4c3edf50aaf60bb33fd879690d2c73", | ||
strip_prefix = "pcre-8.43", | ||
urls = [ | ||
"https://mirror.bazel.build/ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz", | ||
"https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
exports_files( | ||
srcs = glob(["**/*.h"]), | ||
visibility = ["@openssl//:__pkg__"], | ||
visibility = ["//visibility:public"], | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- MODULE.bazel | ||
+++ MODULE.bazel | ||
@@ -0,0 +1,9 @@ | ||
+module( | ||
+ name = "abseil-cpp", | ||
+ version = "20230125.1", | ||
+ compatibility_level = 1, | ||
+) | ||
+bazel_dep(name = "rules_cc", version = "0.0.8") | ||
+bazel_dep(name = "platforms", version = "0.0.6") | ||
+bazel_dep(name = "bazel_skylib", version = "1.4.2") | ||
+bazel_dep(name = "googletest", version = "1.12.1", repo_name = "com_google_googletest") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.