Skip to content

Commit a3b74ec

Browse files
Bump upstream from ffb5c6c to b10a557 (#183)
* Bump upstream from `ffb5c6c` to `b10a557` Bumps [upstream](https://github.com/bazelbuild/bazel) from `ffb5c6c` to `b10a557`. - [Release notes](https://github.com/bazelbuild/bazel/releases) - [Commits](bazelbuild/bazel@ffb5c6c...b10a557) --- updated-dependencies: - dependency-name: upstream dependency-version: b10a5579ae9b0cfaab6ccfe539a474bfbb0593e6 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * chore: update documentation from upstream Bazel repo Generated by GitHub Actions workflow from upstream Bazel repository. This commit includes transformed documentation files ready for Mintlify deployment. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent bbcfd61 commit a3b74ec

File tree

2 files changed

+126
-21
lines changed

2 files changed

+126
-21
lines changed

configure/windows.mdx

Lines changed: 125 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -232,37 +232,142 @@ Bazel where LLVM is installed by `BAZEL_LLVM`.
232232
set BAZEL_LLVM=C:\Program Files\LLVM
233233
```
234234

235-
To enable the Clang toolchain for building C++, there are several situations.
235+
To enable the Clang toolchain, the configuration depends on your Bazel version
236+
and whether you are using Bzlmod or WORKSPACE.
236237

237-
* In Bazel 7.0.0 and newer: Add a platform target to your `BUILD file` (eg. the
238-
top level `BUILD` file):
238+
---
239239

240-
```
241-
platform(
242-
name = "x64_windows-clang-cl",
243-
constraint_values = [
244-
"@platforms//cpu:x86_64",
245-
"@platforms//os:windows",
246-
"@bazel_tools//tools/cpp:clang-cl",
247-
],
248-
)
249-
```
240+
**Bazel 8 and newer:**
250241

251-
Then enable the Clang toolchain by specifying the following build flags:
242+
* **Using Bzlmod (Recommended):**
252243

253-
```
254-
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
255-
```
244+
1. Ensure you have `rules_cc` loaded in your `MODULE.bazel` and configure
245+
the CC toolchains:
246+
```python
247+
bazel_dep(name = "rules_cc", version = "0.0.17") # Or newer
248+
249+
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
250+
use_repo(cc_configure, "local_config_cc")
251+
```
252+
253+
2. Define a `platform` target in a BUILD file (e.g., the root BUILD file):
254+
```python
255+
platform(
256+
name = "x64_windows-clang-cl",
257+
constraint_values = [
258+
"@platforms//cpu:x86_64",
259+
"@platforms//os:windows",
260+
"@bazel_tools//tools/cpp:clang-cl", # Alias to the @rules_cc constraint in Bazel 8+
261+
],
262+
)
263+
```
264+
265+
3. Enable the toolchain using these flags:
266+
```bash
267+
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
268+
```
269+
270+
* **Using WORKSPACE:**
271+
272+
1. Load the `rules_cc` dependencies and toolchains in your `WORKSPACE` file
273+
:
274+
```python
275+
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
276+
rules_cc_dependencies()
277+
rules_cc_toolchains()
278+
```
279+
280+
2. Define a `platform` target in a BUILD file (e.g., the root BUILD file):
281+
```python
282+
platform(
283+
name = "x64_windows-clang-cl",
284+
constraint_values = [
285+
"@platforms//cpu:x86_64",
286+
"@platforms//os:windows",
287+
"@bazel_tools//tools/cpp:clang-cl", # Alias to the @rules_cc constraint in Bazel 8+
288+
],
289+
)
290+
```
291+
292+
3. Enable the toolchain using these flags:
293+
```bash
294+
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
295+
```
256296

257-
* In Bazel older than 7.0.0 but newer than 0.28: Enable the Clang toolchain by
297+
---
298+
299+
**Bazel 7:**
300+
301+
**Note:** In Bazel 7, `@bazel_tools//tools/cpp:clang-cl` is *not* an alias for
302+
the `@rules_cc` constraint. To correctly use `clang-cl` with `rules_cc` in Bazel
303+
7, you must reference a constraint within the `@rules_cc` repository. The label
304+
`@rules_cc//cc/private/toolchain:clang-cl` is technically private but is
305+
necessary for consistent behavior between WORKSPACE and Bzlmod setups in Bazel
306+
7.
307+
308+
* **Using Bzlmod:**
309+
310+
1. Setup `MODULE.bazel` as in the Bazel 8 example.
311+
312+
2. Define the `platform` target using the `@rules_cc` private constraint:
313+
```python
314+
platform(
315+
name = "x64_windows-clang-cl",
316+
constraint_values = [
317+
"@platforms//cpu:x86_64",
318+
"@platforms//os:windows",
319+
"@rules_cc//cc/private/toolchain:clang-cl", # Necessary for Bazel 7
320+
],
321+
)
322+
```
323+
324+
3. Enable the toolchain using these flags:
325+
```bash
326+
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
327+
```
328+
329+
* **Using WORKSPACE:**
330+
331+
1. Load the `rules_cc` dependencies and toolchains in your `WORKSPACE` file
332+
:
333+
```python
334+
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
335+
rules_cc_dependencies()
336+
rules_cc_toolchains()
337+
```
338+
339+
2. Define the `platform` target using the `@rules_cc` private constraint:
340+
```python
341+
platform(
342+
name = "x64_windows-clang-cl",
343+
constraint_values = [
344+
"@platforms//cpu:x86_64",
345+
"@platforms//os:windows",
346+
"@rules_cc//cc/private/toolchain:clang-cl", # Necessary for Bazel 7
347+
],
348+
)
349+
```
350+
351+
3. Enable the toolchain using these flags:
352+
```bash
353+
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
354+
```
355+
356+
---
357+
358+
**Bazel 0.29 to 6.x:**
359+
360+
* Enable the Clang toolchain by
258361
a build flag `--compiler=clang-cl`.
259362

260-
If your build sets the flag
363+
* If your build sets the flag
261364
[\-\-incompatible_enable_cc_toolchain_resolution]
262365
(https://github.com/bazelbuild/bazel/issues/7260)
263366
to `true`, then use the approach for Bazel 7.0.0.
264367

265-
* In Bazel 0.28 and older: Clang is not supported.
368+
**Bazel 0.28 and older:**
369+
370+
* Clang is not supported.
266371

267372
### Build Java
268373

upstream

Submodule upstream updated 67 files

0 commit comments

Comments
 (0)