-
-
Notifications
You must be signed in to change notification settings - Fork 219
/
MODULE.bazel
235 lines (211 loc) · 8.09 KB
/
MODULE.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Copyright 2023 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.
module(name = "toolchains_llvm_tests")
bazel_dep(name = "toolchains_llvm", version = "0.0.0")
local_path_override(
module_name = "toolchains_llvm",
path = "..",
)
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_rust", version = "0.54.1")
bazel_dep(name = "rules_foreign_cc", version = "0.12.0")
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")
# 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",
)
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
name = "go_sdk",
version = "1.21.0",
)
use_repo(go_sdk, "go_toolchains")
register_toolchains("@go_toolchains//:all")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2023")
use_repo(
rust,
"rust_toolchains",
)
register_toolchains("@rust_toolchains//:all")
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.
LLVM_VERSIONS = {
"": "16.0.0",
"darwin-aarch64": "16.0.5",
"darwin-x86_64": "15.0.7",
}
llvm.toolchain(
name = "llvm_toolchain",
llvm_versions = LLVM_VERSIONS,
cxx_standard = {"": "c++17"},
)
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.extra_target_compatible_with(
name = "llvm_toolchain_cxx20",
constraints = ["//:cxx20"],
)
use_repo(llvm, "llvm_toolchain_cxx20")
register_toolchains("@llvm_toolchain_cxx20//: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 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_versions = LLVM_VERSIONS,
)
# We can share the downloaded LLVM distribution with the first configuration.
llvm.toolchain_root(
name = "llvm_toolchain_with_absolute_paths",
label = "@llvm_toolchain_llvm//:BUILD",
)
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_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",
path = "/opt/llvm-16",
)
use_repo(llvm, "llvm_toolchain_with_system_llvm")
# Toolchain example with a sysroot.
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",
)
use_repo(llvm, "llvm_toolchain_with_sysroot")
llvm.toolchain(
name = "llvm_toolchain_linux_exec",
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",
# WebAssembly tests use a separate (newer) version of LLVM to exercise
# support for experimental features such as wasm64.
llvm_versions = {
# The most recent LLVM as of 2024-10-17
"": "19.1.0",
},
stdlib = {
"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",
label = "@wasi_sdk_sysroots//wasm32-wasip2",
targets = ["wasm32"],
)
llvm.sysroot(
name = "llvm_toolchain_wasm",
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",
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"],
)