You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorials/local-build.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ In the `deps/` subdirectory of the Reactant repository there is a script to do l
8
8
* A reasonably recent C/C++ compiler, ideally GCC 12+.
9
9
Older compilers may not work.
10
10
* 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`.
12
12
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`.
14
14
15
15
## Building
16
16
@@ -84,8 +84,18 @@ To do that using this `build_local.jl` script pass the options `--extraopt '--st
84
84
85
85
### Using ccache
86
86
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
88
90
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.
0 commit comments