Skip to content

Commit bc8658a

Browse files
authored
docs: mention calling register_toolchains in custom toolchain docs (#2463)
Mention where register_toolchains() should be when defining custom toolchains. Also link to the Bazel docs about toolchains. This stems from Slack discussion where someone was trying to define custom toolchains and got hung up on the last step or registering them.
1 parent a362339 commit bc8658a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/toolchains.md

+9
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,17 @@ toolchain(
444444
],
445445
exec_comaptible_with = ["@platforms/os:linux"]
446446
)
447+
448+
# File: MODULE.bazel or WORKSPACE.bazel
449+
# These toolchains will considered before others
450+
register_toolchains("//toolchains:all")
447451
```
448452

453+
When registering custom toolchains, be aware of the the [toolchain registration
454+
order](https://bazel.build/extending/toolchains#toolchain-resolution). In brief,
455+
toolchain order is the BFS-order of the modules; see the bazel docs for a more
456+
detailed description.
457+
449458
:::{note}
450459
The toolchain() calls should be in a separate BUILD file from everything else.
451460
This avoids Bazel having to perform unnecessary work when it discovers the list

0 commit comments

Comments
 (0)