Skip to content

Commit dd0a68a

Browse files
authored
[docs] Improve some information about local builds of libReactant (#1396)
[skip tests]
1 parent d4a7a76 commit dd0a68a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/src/tutorials/local-build.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ In the `deps/` subdirectory of the Reactant repository there is a script to do l
88
* A reasonably recent C/C++ compiler, ideally GCC 12+.
99
Older compilers may not work.
1010
* Bazel. If you don't have it already, you can download a build for your platform from [the latest `bazelbuild/bazelisk` release](https://github.com/bazelbuild/bazelisk/releases/latest) and put the `bazel` executable in `PATH`
11-
* not necessary in general, but for debug builds with CUDA support, you'll need a fast linker, like `lld` or `mold`
11+
* not necessary in general, but for debug builds with CUDA support, you'll need a fast linker, like `lld` or `mold`.
1212
Binutils `ld` won't work, don't even try using it.
13-
You can obtain `mold` for your platform from the [latest `rui314/mold` release](https://github.com/rui314/mold/releases/latest) and put the `mold` executable in `PATH`
13+
You can obtain `mold` for your platform from the [latest `rui314/mold` release](https://github.com/rui314/mold/releases/latest) and put the executable in `PATH` with name `ld.mold`.
1414

1515
## Building
1616

@@ -84,8 +84,18 @@ To do that using this `build_local.jl` script pass the options `--extraopt '--st
8484

8585
### Using ccache
8686

87-
If you want to use `ccache` as your compiler, you may have to add the flag `--extraopt "--sandbox_writable_path=/path/to/ccache/directory"` to let `ccache` write to its own directory.
87+
To speed up recompilation you can use [ccache](https://ccache.dev/).
88+
You can use ccache on top of Bazel's own caching system, which is very inflexible: Bazel invalidates cache whenever you change any variable, leading to poor cache hit rate when recompiling code with different options, even if they don't actually affect compilation output.
89+
Since [Bazel interacts badly with ccache](https://github.com/ccache/ccache/discussions/1279) when the latter [masquerades itself as the compiler via symlinks](https://ccache.dev/manual/4.11.3.html#_run_modes), the most reliable way to use ccache with Bazel is to create a small shell wrapper like
8890

91+
```bash
92+
#!/bin/bash
93+
/path/to/ccache /path/to/your/compiler "${@}"
94+
```
95+
96+
replacing `/path/to/ccache` with the path where ccache was installed, and `/path/to/your/compiler` with the path of your compiler.
97+
Then inform Bazel to use this script as the compiler (with the `build_local.jl` script add the flag `--cc /path/to/ccache/wrapper`, where `/path/to/ccache/wrapper` is the path where you saved the shell wrapper).
98+
Finally, you may have to add the flag `--extraopt "--sandbox_writable_path=/path/to/ccache/directory"`, otherwise Bazel will not let `ccache` write the cache output to its own directory.
8999

90100
## `LocalPreferences.toml` file
91101

0 commit comments

Comments
 (0)