Skip to content

Commit fcf5820

Browse files
document combination of flags
1 parent 35cd7f5 commit fcf5820

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

build_system/src/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ impl BuildArg {
4444
fn usage() {
4545
println!(
4646
r#"
47-
`build` command help:
48-
49-
--sysroot : Build with sysroot"#
47+
`build` command help:"#
5048
);
5149
ConfigInfo::show_usage();
5250
println!(" --help : Show this help");

build_system/src/config.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,22 @@ impl ConfigInfo {
472472

473473
pub fn show_usage() {
474474
println!(
475-
"\
475+
"
476476
--features [arg] : Add a new feature [arg]
477477
--target-triple [arg] : Set the target triple to [arg]
478478
--target [arg] : Set the target to [arg]
479479
--out-dir : Location where the files will be generated
480-
--release : Build in release mode
481-
--release-sysroot : Build sysroot in release mode
480+
--release : Build and optimize the backend in release mode
481+
--sysroot : When used on its own, build both
482+
sysroot and backend in dev. mode. Only the backend is optimized.
483+
When used together with --release, build and optimize the backend
484+
in release mode instead of in dev. mode.
485+
When used together with --release-sysroot,
486+
build and optimize the sysroot in release mode instead of in dev. mode
487+
--release-sysroot : When used on its own, build and optimize only the backend in dev. mode.
488+
When combined with --release, it has no effect.
489+
When combined with --sysroot, additionally
490+
build and optimize the sysroot in release mode
482491
--sysroot-panic-abort : Build the sysroot without unwinding support
483492
--config-file : Location of the config file to be used
484493
--gcc-path : Location of the GCC root folder

0 commit comments

Comments
 (0)