Skip to content

Commit b87bfdc

Browse files
harin-rameshFrancescoV1985antoyo
authored
Better document some combinations of flags (#808)
--------- Co-authored-by: FrancescoV1985 <[email protected]> Co-authored-by: FrancescoV1985 <[email protected]> Co-authored-by: antoyo <[email protected]>
1 parent c3c8a9a commit b87bfdc

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,43 @@ We encourage new contributors to join our communication channels and introduce t
2525

2626
## Understanding Core Concepts
2727

28+
### Sysroot & compilation flags
29+
30+
#### What *is* the sysroot?
31+
The **sysroot** is the directory that stores the compiled standard
32+
library (`core`, `alloc`, `std`, `test`, …) and compiler built-ins.
33+
Rustup ships these libraries **pre-compiled with LLVM**.
34+
35+
**rustc_codegen_gcc** replaces LLVM with the GCC backend.
36+
37+
The freshly compiled sysroot ends up in
38+
`build/build_sysroot/...`.
39+
40+
A rebuild of sysroot is needed when
41+
42+
* the backend changes in a way that affects code generation, or
43+
* the user switches toolchains / updates submodules.
44+
45+
Both backend and sysroot can be built using different [profiles](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles).
46+
That is exactly what the `--sysroot`, `--release-sysroot` and `--release` flag supported by the build system script `y.sh` take care of.
47+
48+
49+
#### Typical flag combinations
50+
51+
| Command | Backend Profile | Sysroot Profile | Usage Scenario |
52+
|--------------------------------------------|-------------------------------|----------------------------------|------------------------------------------------------------|
53+
| `./y.sh build` | &nbsp;dev* | &nbsp;n/a | &nbsp;Build backend in dev mode with optimized dependencies without rebuilding sysroot |
54+
| `./y.sh build --release` | &nbsp;release (optimized) | &nbsp;n/a | &nbsp;Build backend in release mode with optimized dependencies without rebuilding sysroot |
55+
| `./y.sh build --release --sysroot` | &nbsp;release (optimized) | &nbsp;dev | &nbsp;Build backend in release mode with optimized dependencies and sysroot in dev mode (unoptimized) |
56+
| `./y.sh build --sysroot` | &nbsp;dev* | &nbsp;dev | &nbsp;Build backend in dev mode with optimized dependencies and sysroot in dev mode (unoptimized) |
57+
| `./y.sh build --release-sysroot --sysroot`| &nbsp;dev* | &nbsp;release (optimized) | &nbsp;Build backend in dev mode and sysroot in release mode, both with optimized dependencies |
58+
59+
\* In `dev` mode, dependencies are compiled with optimizations, while the code of the backend itself is not.
60+
61+
62+
Note: `--release-sysroot` must be used together with `--sysroot`.
63+
64+
2865
### Common Development Tasks
2966

3067
#### Running Specific Tests

build_system/src/build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,16 @@ impl BuildArg {
4646
println!(
4747
r#"
4848
`build` command help:
49-
50-
--sysroot : Build with sysroot"#
49+
--sysroot : When used on its own, build backend in dev mode with optimized dependencies
50+
and sysroot in dev mode (unoptimized)
51+
When used together with --release, build backend in release mode with optimized dependencies
52+
When used together with --release-sysroot,
53+
build the sysroot in release mode with optimized dependencies instead of in dev mode
54+
--release-sysroot : When combined with --sysroot, additionally
55+
build the sysroot in release mode with optimized dependencies.
56+
It has no effect if `--sysroot` is not specified.
57+
It should not be used on its own.
58+
--sysroot-panic-abort : Build the sysroot without unwinding support"#
5159
);
5260
ConfigInfo::show_usage();
5361
println!(" --help : Show this help");

build_system/src/config.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,11 @@ impl ConfigInfo {
459459

460460
pub fn show_usage() {
461461
println!(
462-
"\
463-
--features [arg] : Add a new feature [arg]
462+
" --features [arg] : Add a new feature [arg]
464463
--target-triple [arg] : Set the target triple to [arg]
465464
--target [arg] : Set the target to [arg]
465+
--release : Build backend in release mode with optimized dependencies
466466
--out-dir : Location where the files will be generated
467-
--release : Build in release mode
468-
--release-sysroot : Build sysroot in release mode
469-
--sysroot-panic-abort : Build the sysroot without unwinding support
470467
--config-file : Location of the config file to be used
471468
--gcc-path : Location of the GCC root folder
472469
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used

build_system/src/test.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ fn show_usage() {
6464
r#"
6565
`test` command help:
6666
67-
--release : Build codegen in release mode
68-
--sysroot-panic-abort : Build the sysroot without unwinding support.
6967
--features [arg] : Add a new feature [arg]
7068
--use-system-gcc : Use system installed libgccjit
7169
--build-only : Only build rustc_codegen_gcc then exits
@@ -92,7 +90,6 @@ struct TestArg {
9290
test_args: Vec<String>,
9391
nb_parts: Option<usize>,
9492
current_part: Option<usize>,
95-
sysroot_panic_abort: bool,
9693
config_info: ConfigInfo,
9794
sysroot_features: Vec<String>,
9895
keep_lto_tests: bool,
@@ -128,9 +125,6 @@ impl TestArg {
128125
test_arg.current_part =
129126
Some(get_number_after_arg(&mut args, "--current-part")?);
130127
}
131-
"--sysroot-panic-abort" => {
132-
test_arg.sysroot_panic_abort = true;
133-
}
134128
"--keep-lto-tests" => {
135129
test_arg.keep_lto_tests = true;
136130
}

0 commit comments

Comments
 (0)