@@ -71,7 +71,7 @@ llvm_register_toolchains()
7171
7272And add the following section to your .bazelrc file:
7373
74- ```
74+ ``` sh
7575# Not needed after https://github.com/bazelbuild/bazel/issues/7260 is closed
7676build --incompatible_enable_cc_toolchain_resolution
7777
@@ -91,7 +91,7 @@ attributes to `llvm_toolchain`.
9191
9292## Advanced Usage
9393
94- #### Per host architecture LLVM version
94+ ### Per host architecture LLVM version
9595
9696LLVM does not come with distributions for all host architectures in each
9797version. In particular patch versions often come with few prebuilt packages.
@@ -104,7 +104,7 @@ specified explicitly. This is like providing `llvm_version = "15.0.6"`, just
104104like in the example on the top. However, here we provide two more entries that
105105map their respective target to a distinct version:
106106
107- ```
107+ ``` starlark
108108llvm_toolchain(
109109 name = " llvm_toolchain" ,
110110 llvm_versions = {
@@ -115,7 +115,7 @@ llvm_toolchain(
115115)
116116```
117117
118- #### Customizations
118+ ### Customizations
119119
120120We currently offer limited customizability through attributes of the
121121[ llvm_toolchain\_\* rules] ( toolchain/rules.bzl ) . You can send us a PR to add
@@ -127,7 +127,7 @@ new compiler features, etc., my advice would be to look at the toolchain
127127configurations generated by this repo, and copy-paste/edit to make your own in
128128any package in your own workspace.
129129
130- ```
130+ ``` sh
131131bazel query --output=build @llvm_toolchain//:all | grep -v -e ' ^#' -e ' ^ generator'
132132```
133133
@@ -140,7 +140,7 @@ directory, and also create a wrapper script for clang such that the actual
140140clang invocation is not through the symlinked path. See the files in the
141141` @llvm_toolchain//: ` package as a reference.
142142
143- ```
143+ ``` sh
144144# See generated files for reference.
145145ls -lR " $( bazel info output_base) /external/llvm_toolchain"
146146
@@ -158,7 +158,7 @@ See [bazel
158158tutorial] ( https://docs.bazel.build/versions/main/tutorial/cc-toolchain-config.html )
159159for how CC toolchains work in general.
160160
161- #### Selecting Toolchains
161+ ### Selecting Toolchains
162162
163163If toolchains are registered (see Quickstart section above), you do not need to
164164do anything special for bazel to find the toolchain. You may want to check once
@@ -172,7 +172,7 @@ For specifying unregistered toolchains on the command line, please use the
172172We no longer support the ` --crosstool_top=@llvm_toolchain//:toolchain ` flag,
173173and instead rely on the ` --incompatible_enable_cc_toolchain_resolution ` flag.
174174
175- #### Bring Your Own LLVM
175+ ### Bring Your Own LLVM
176176
177177The following mechanisms are available for using an LLVM toolchain:
178178
@@ -204,7 +204,7 @@ The following mechanisms are available for using an LLVM toolchain:
204204 a toolchain root specified through the ` toolchain_roots ` attribute with an
205205 empty key.
206206
207- #### Sysroots
207+ ### Sysroots
208208
209209A sysroot can be specified through the ` sysroot ` attribute. This can be either
210210a path on the user's system, or a bazel ` filegroup ` like label. One way to
@@ -213,7 +213,7 @@ entire filesystem for the image you want. Another way is to use the build
213213scripts provided by the [ Chromium
214214project] ( https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/sysroot.md ) .
215215
216- #### Cross-compilation
216+ ### Cross-compilation
217217
218218The toolchain supports cross-compilation if you bring your own sysroot. When
219219cross-compiling, we link against the libstdc++ from the sysroot
@@ -231,14 +231,14 @@ Then, when cross-compiling, explicitly specify the toolchain with the sysroot
231231and the target platform. For example, see the [ WORKSPACE] ( tests/WORKSPACE ) file and
232232the [ test script] ( tests/scripts/run_xcompile_tests.sh ) for cross-compilation.
233233
234- ```
234+ ``` sh
235235bazel build \
236236 --platforms=@com_grail_bazel_toolchain//platforms:linux-x86_64 \
237237 --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux \
238238 //...
239239```
240240
241- #### Supporting New Target Platforms
241+ ### Supporting New Target Platforms
242242
243243The following is a rough (untested) list of steps:
244244
@@ -256,7 +256,7 @@ The following is a rough (untested) list of steps:
256256 ` toolchain_roots ` or ` urls ` attribute.
2572576 . Test your build.
258258
259- #### Sandbox
259+ ### Sandbox
260260
261261Sandboxing the toolchain introduces a significant overhead (100ms per action,
262262as of mid 2018). To overcome this, one can use
@@ -267,12 +267,12 @@ substitute templated paths to the toolchain as absolute paths. When running
267267bazel actions, these paths will be available from inside the sandbox as part of
268268the / read-only mount. Note that this will make your builds non-hermetic.
269269
270- #### Compatibility
270+ ### Compatibility
271271
272272The toolchain is tested to work with ` rules_go ` , ` rules_rust ` , and
273273` rules_foreign_cc ` .
274274
275- #### Accessing tools
275+ ### Accessing tools
276276
277277The LLVM distribution also provides several tools like ` clang-format ` . You can
278278depend on these tools directly in the bin directory of the distribution. When
0 commit comments