@@ -25,6 +25,45 @@ We encourage new contributors to join our communication channels and introduce t
2525
2626## Understanding Core Concepts
2727
28+
29+
30+ ### Sysroot & compilation flags
31+
32+ #### What * is* the sysroot?
33+ The ** sysroot** is the directory that stores the compiled standard
34+ library (` core ` , ` alloc ` , ` std ` , ` test ` , …) and compiler built-ins.
35+ Rustup ships these libraries ** pre-compiled with LLVM** .
36+
37+ Because ** rustc_codegen_gcc** replaces LLVM with the GCC backend, the shipped
38+ LLVM artefacts are ** incompatible** .
39+ Therefore the standard library must be ** rebuilt with GCC** before ordinary Rust crates can be compiled.
40+
41+ The freshly compiled sysroot ends up in
42+ ` build/build_sysroot/... ` .
43+
44+ A rebuild of sysroot is needed when
45+
46+ * the backend changes in a way that affects code generation, or
47+ * the user switches toolchains / updates submodules.
48+
49+ Both backend and sysroot can be built using different [ profiles] ( https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles ) .
50+ That is exactly what the ` --sysroot ` , ` --release-sysroot ` and ` --release ` flag supported by the frontend script ` y.sh ` take care of.
51+
52+
53+ #### Typical flag combinations
54+
55+ | Command | Backend Profile | Sysroot Profile | Usage Scenario |
56+ | --------------------------------------------| -------------------------------| ----------------------------------| ------------------------------------------------------------|
57+ | ` ./y.sh build ` |   ; dev (optimized + debuginfo) |   ; X |   ; Optimize backend with debug capabilities |
58+ | ` ./y.sh build --release ` |   ; release (optimized) |   ; X |   ; Optimize backend without rebuilding sysroot |
59+ | ` ./y.sh build --release --release-sysroot ` |   ; release (optimized) |   ; X |   ; Same as --release |
60+ | ` ./y.sh build --release --sysroot ` |   ; release (optimized) |   ; dev (unoptimized + debuginfo) |   ; Optimize backend for release without full sysroot rebuild |
61+ | ` ./y.sh build --sysroot ` |   ; dev (optimized + debuginfo) |   ; dev (unoptimized + debuginfo) |   ; Full debug capabilities with optimized backend |
62+ | ` ./y.sh build --release-sysroot ` |   ; dev (optimized + debuginfo) |   ; X |   ; Build only optimized backend with debug capabilities |
63+ | ` ./y.sh build --release-sysroot --sysroot ` |   ; dev (optimized + debuginfo) |   ; release (optimized) |   ; Build optimized backend and sysroot for debugging and release, respectively |
64+
65+
66+
2867### Common Development Tasks
2968
3069#### Running Specific Tests
0 commit comments