Skip to content

Commit 8692192

Browse files
authored
build sysroot flag (#16)
1 parent c7f1d5d commit 8692192

File tree

8 files changed

+19
-13
lines changed

8 files changed

+19
-13
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
- name: Build
7979
run: |
8080
./y.sh prepare --only-libcore
81-
./y.sh build
81+
./y.sh build --sysroot
8282
cargo test
8383
8484
- name: Run y.sh cargo build

.github/workflows/gcc12.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Build
6868
run: |
6969
./y.sh prepare --only-libcore --libgccjit12-patches
70-
./y.sh build --no-default-features --sysroot-panic-abort
70+
./y.sh build --sysroot --no-default-features --sysroot-panic-abort
7171
cargo test --no-default-features
7272
./y.sh clean all
7373

.github/workflows/m68k.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ jobs:
8585
- name: Build sample project with target defined as JSON spec
8686
run: |
8787
./y.sh prepare --only-libcore --cross
88-
./y.sh build --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
88+
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
8989
./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
9090
./y.sh clean all
9191
9292
- name: Build
9393
run: |
9494
./y.sh prepare --only-libcore --cross
95-
./y.sh build --target-triple m68k-unknown-linux-gnu
95+
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu
9696
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
9797
./y.sh clean all
9898

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Build
5454
run: |
5555
./y.sh prepare --only-libcore
56-
EMBED_LTO_BITCODE=1 ./y.sh build --release --release-sysroot
56+
EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot
5757
cargo test
5858
./y.sh clean all
5959

.github/workflows/stdarch.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Build
5959
run: |
6060
./y.sh prepare --only-libcore
61-
./y.sh build --release --release-sysroot
61+
./y.sh build --sysroot --release --release-sysroot
6262
6363
- name: Set env (part 2)
6464
run: |

Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Then you can run commands like this:
8080

8181
```bash
8282
$ ./y.sh prepare # download and patch sysroot src and install hyperfine for benchmarking
83-
$ ./y.sh build --release
83+
$ ./y.sh build --sysroot --release
8484
```
8585

8686
To run the tests:

build_system/src/build.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::path::Path;
1111
struct BuildArg {
1212
flags: Vec<String>,
1313
config_info: ConfigInfo,
14+
build_sysroot: bool,
1415
}
1516

1617
impl BuildArg {
@@ -31,6 +32,9 @@ impl BuildArg {
3132
);
3233
}
3334
}
35+
"--sysroot" => {
36+
build_arg.build_sysroot = true;
37+
}
3438
"--help" => {
3539
Self::usage();
3640
return Ok(None);
@@ -50,7 +54,8 @@ impl BuildArg {
5054
r#"
5155
`build` command help:
5256
53-
--features [arg] : Add a new feature [arg]"#
57+
--features [arg] : Add a new feature [arg]
58+
--sysroot : Build with sysroot"#
5459
);
5560
ConfigInfo::show_usage();
5661
println!(" --help : Show this help");
@@ -205,9 +210,10 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
205210
let _ = fs::remove_dir_all("target/out");
206211
let gccjit_target = "target/out/gccjit";
207212
create_dir(gccjit_target)?;
208-
209-
println!("[BUILD] sysroot");
210-
build_sysroot(&env, &args.config_info)?;
213+
if args.build_sysroot {
214+
println!("[BUILD] sysroot");
215+
build_sysroot(&env, &args.config_info)?;
216+
}
211217
Ok(())
212218
}
213219

doc/tips.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ generate it in [gimple.md](./doc/gimple.md).
5454

5555
* Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case.
5656
* Set the path to the cross-compiling libgccjit in `gcc-path` (in `config.toml`).
57-
* Make sure you have the linker for your target (for instance `m68k-unknown-linux-gnu-gcc`) in your `$PATH`. Currently, the linker name is hardcoded as being `$TARGET-gcc`. Specify the target when building the sysroot: `./y.sh build --target-triple m68k-unknown-linux-gnu`.
57+
* Make sure you have the linker for your target (for instance `m68k-unknown-linux-gnu-gcc`) in your `$PATH`. Currently, the linker name is hardcoded as being `$TARGET-gcc`. Specify the target when building the sysroot: `./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu`.
5858
* Build your project by specifying the target: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target m68k-unknown-linux-gnu`.
5959

6060
If the target is not yet supported by the Rust compiler, create a [target specification file](https://docs.rust-embedded.org/embedonomicon/custom-target.html) (note that the `arch` specified in this file must be supported by the rust compiler).
6161
Then, you can use it the following way:
6262

63-
* Add the target specification file using `--target` as an **absolute** path to build the sysroot: `./y.sh build --target-triple m68k-unknown-linux-gnu --target $(pwd)/m68k-unknown-linux-gnu.json`
63+
* Add the target specification file using `--target` as an **absolute** path to build the sysroot: `./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target $(pwd)/m68k-unknown-linux-gnu.json`
6464
* Build your project by specifying the target specification file: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target path/to/m68k-unknown-linux-gnu.json`.
6565

6666
If you get the following error:

0 commit comments

Comments
 (0)