build sysroot flag (#16)

This commit is contained in:
Shashank Trivedi 2024-04-10 17:53:51 +05:30 committed by GitHub
parent c7f1d5d409
commit 8692192582
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 19 additions and 13 deletions

View File

@ -78,7 +78,7 @@ jobs:
- name: Build
run: |
./y.sh prepare --only-libcore
./y.sh build
./y.sh build --sysroot
cargo test
- name: Run y.sh cargo build

View File

@ -67,7 +67,7 @@ jobs:
- name: Build
run: |
./y.sh prepare --only-libcore --libgccjit12-patches
./y.sh build --no-default-features --sysroot-panic-abort
./y.sh build --sysroot --no-default-features --sysroot-panic-abort
cargo test --no-default-features
./y.sh clean all

View File

@ -85,14 +85,14 @@ jobs:
- name: Build sample project with target defined as JSON spec
run: |
./y.sh prepare --only-libcore --cross
./y.sh build --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh clean all
- name: Build
run: |
./y.sh prepare --only-libcore --cross
./y.sh build --target-triple m68k-unknown-linux-gnu
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
./y.sh clean all

View File

@ -53,7 +53,7 @@ jobs:
- name: Build
run: |
./y.sh prepare --only-libcore
EMBED_LTO_BITCODE=1 ./y.sh build --release --release-sysroot
EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot
cargo test
./y.sh clean all

View File

@ -58,7 +58,7 @@ jobs:
- name: Build
run: |
./y.sh prepare --only-libcore
./y.sh build --release --release-sysroot
./y.sh build --sysroot --release --release-sysroot
- name: Set env (part 2)
run: |

View File

@ -80,7 +80,7 @@ Then you can run commands like this:
```bash
$ ./y.sh prepare # download and patch sysroot src and install hyperfine for benchmarking
$ ./y.sh build --release
$ ./y.sh build --sysroot --release
```
To run the tests:

View File

@ -11,6 +11,7 @@
struct BuildArg {
flags: Vec<String>,
config_info: ConfigInfo,
build_sysroot: bool,
}
impl BuildArg {
@ -31,6 +32,9 @@ fn new() -> Result<Option<Self>, String> {
);
}
}
"--sysroot" => {
build_arg.build_sysroot = true;
}
"--help" => {
Self::usage();
return Ok(None);
@ -50,7 +54,8 @@ fn usage() {
r#"
`build` command help:
--features [arg] : Add a new feature [arg]"#
--features [arg] : Add a new feature [arg]
--sysroot : Build with sysroot"#
);
ConfigInfo::show_usage();
println!(" --help : Show this help");
@ -205,9 +210,10 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
let _ = fs::remove_dir_all("target/out");
let gccjit_target = "target/out/gccjit";
create_dir(gccjit_target)?;
if args.build_sysroot {
println!("[BUILD] sysroot");
build_sysroot(&env, &args.config_info)?;
}
Ok(())
}

View File

@ -54,13 +54,13 @@ generate it in [gimple.md](./doc/gimple.md).
* Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case.
* Set the path to the cross-compiling libgccjit in `gcc-path` (in `config.toml`).
* 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`.
* 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`.
* Build your project by specifying the target: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target m68k-unknown-linux-gnu`.
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).
Then, you can use it the following way:
* 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`
* 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`
* 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`.
If you get the following error: