From 1d2b874b847e2d59a7deb639ef79999b87ee2837 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 18:29:17 -0400 Subject: [PATCH 01/10] Remove OVERWRITE_TARGET_TRIPLE env var now that config.sh is gone --- .github/workflows/m68k.yml | 13 ++++++++++--- build_system/src/config.rs | 12 ++++++++---- doc/tips.md | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 245bee7f2a3..4a8ccebaf79 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -14,8 +14,6 @@ permissions: env: # Enable backtraces for easier debugging RUST_BACKTRACE: 1 - # TODO: remove when confish.sh is removed. - OVERWRITE_TARGET_TRIPLE: m68k-unknown-linux-gnu jobs: build: @@ -106,7 +104,16 @@ jobs: - name: Run tests run: | - ./y.sh test --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }} + ./y.sh test--target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }} + + - name: Run Hello World! + run: | + ./y.sh build --target-triple m68k-unknown-linux-gnu + + cd tests/hello-world + ../../y.sh cargo build --target m68k-unknown-linux-gnu + ../../y.sh cargo run --target m68k-unknown-linux-gnu > hello_world_stdout + test $(cat hello_world_stdout) == "Hello, world!" || exit 1 # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! diff --git a/build_system/src/config.rs b/build_system/src/config.rs index 650c030ca53..121c43822fd 100644 --- a/build_system/src/config.rs +++ b/build_system/src/config.rs @@ -352,10 +352,14 @@ impl ConfigInfo { None => return Err("no host found".to_string()), }; - if self.target_triple.is_empty() - && let Some(overwrite) = env.get("OVERWRITE_TARGET_TRIPLE") - { - self.target_triple = overwrite.clone(); + if self.target_triple.is_empty() { + // TODO: set target triple. + // TODO: why do we even need to set target_triple? + // It seems to only be needed for the linker (we could add an environment variable to + // remove this need) and the sysroot (perhaps we could find another way to find it). + // TODO TODO: seems like we would still need OVERWRITE_TARGET_TRIPLE when using a + // json spec file. + // ====> maybe not since we specify both --target and --target-triple. } if self.target_triple.is_empty() { self.target_triple = self.host_triple.clone(); diff --git a/doc/tips.md b/doc/tips.md index 86c22db186e..4ab135f3df6 100644 --- a/doc/tips.md +++ b/doc/tips.md @@ -63,13 +63,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 --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`. + * Build your project by specifying the target: `../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 --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`. + * Build your project by specifying the target specification file: `../y.sh cargo build --target path/to/m68k-unknown-linux-gnu.json`. If you get the following error: From 1bbe5946f231b4c05818fb18f9252b68af251498 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 18:50:39 -0400 Subject: [PATCH 02/10] Fix installation of libgccjit for m68k --- .github/workflows/m68k.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 4a8ccebaf79..04e09dc7b8c 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -57,7 +57,7 @@ jobs: - name: Setup path to libgccjit run: | - sudo dpkg -i gcc-m68k-15.deb + sudo dpkg --force-overwrite -i gcc-m68k-15.deb echo 'gcc-path = "/usr/lib/"' > config.toml - name: Set env From 89f0cb3bfc97473a33cb5ae073be6073fa0931b9 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 19:03:08 -0400 Subject: [PATCH 03/10] Specify linker in m68k CI --- .github/workflows/m68k.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 04e09dc7b8c..249fb965be1 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -63,8 +63,6 @@ jobs: - name: Set env run: | echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV - - #- name: Cache rust repository ## We only clone the rust repository for rustc tests @@ -85,7 +83,7 @@ jobs: run: | ./y.sh prepare --only-libcore --cross ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --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 + CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./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 From cf509d87d909c551c942b315ac16f2722a71db2e Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 19:17:18 -0400 Subject: [PATCH 04/10] Add missing --target-triple flags in m68k CI --- .github/workflows/m68k.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 249fb965be1..b78f17c0e26 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -90,8 +90,8 @@ jobs: run: | ./y.sh prepare --only-libcore --cross ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu - ./y.sh test --mini-tests - CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests + ./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu + CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu ./y.sh clean all - name: Prepare dependencies From fec79b86a2fb9f7086229d1b94bafd204eec6c27 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 19:35:39 -0400 Subject: [PATCH 05/10] Add missing space before --target-triple --- .github/workflows/m68k.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index b78f17c0e26..511e2ff3dec 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -102,7 +102,7 @@ jobs: - name: Run tests run: | - ./y.sh test--target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }} + ./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }} - name: Run Hello World! run: | From 3021598bdfc5adec0e71401a191e780bdc0060fb Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 19:44:00 -0400 Subject: [PATCH 06/10] Specify the linker when building the test project in m68k CI --- .github/workflows/m68k.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 511e2ff3dec..5f347498f32 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -109,8 +109,8 @@ jobs: ./y.sh build --target-triple m68k-unknown-linux-gnu cd tests/hello-world - ../../y.sh cargo build --target m68k-unknown-linux-gnu - ../../y.sh cargo run --target m68k-unknown-linux-gnu > hello_world_stdout + CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu + CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo run --target m68k-unknown-linux-gnu > hello_world_stdout test $(cat hello_world_stdout) == "Hello, world!" || exit 1 # Summary job for the merge queue. From ed1e9b7015a3b1599d1322a433771b5845beae68 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 2 Jul 2025 09:24:55 -0400 Subject: [PATCH 07/10] Manually run in a VM in the m68k CI --- .github/workflows/m68k.yml | 6 ++++-- build_system/src/config.rs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 5f347498f32..8b8f58fef5f 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -108,10 +108,12 @@ jobs: run: | ./y.sh build --target-triple m68k-unknown-linux-gnu + vm_dir=$(pwd)/vm cd tests/hello-world CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu - CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo run --target m68k-unknown-linux-gnu > hello_world_stdout - test $(cat hello_world_stdout) == "Hello, world!" || exit 1 + sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ + sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout + test $(cat hello_world_stdout) == "Hello, world!" || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! diff --git a/build_system/src/config.rs b/build_system/src/config.rs index 121c43822fd..428f3766e5d 100644 --- a/build_system/src/config.rs +++ b/build_system/src/config.rs @@ -374,6 +374,7 @@ impl ConfigInfo { if self.target_triple.is_empty() { return Err("Unknown non-native platform".to_string()); } + // TODO: check if this is still needed. linker = Some(format!("-Clinker={}-gcc", self.target_triple)); self.run_in_vm = true; } From 21c8639d797850bfbb55546d69c09ba424361aa2 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 2 Jul 2025 11:39:27 -0400 Subject: [PATCH 08/10] Fix to use the correct expected output for m68k CI test --- .github/workflows/m68k.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 8b8f58fef5f..4b67360df9d 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -113,7 +113,8 @@ jobs: CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout - test $(cat hello_world_stdout) == "Hello, world!" || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) + expected_output="40" + test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! From 188108733af702a7f60982c18da2d87d54ed8f5b Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 2 Jul 2025 11:48:49 -0400 Subject: [PATCH 09/10] Update the doc to reflect the new way to specify the linker for cross-compilation --- doc/tips.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/tips.md b/doc/tips.md index 4ab135f3df6..e62c3402a29 100644 --- a/doc/tips.md +++ b/doc/tips.md @@ -62,8 +62,8 @@ 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 --sysroot --target-triple m68k-unknown-linux-gnu`. - * Build your project by specifying the target: `../y.sh cargo build --target m68k-unknown-linux-gnu`. + * Make sure you have the linker for your target (for instance `m68k-unknown-linux-gnu-gcc`) in your `$PATH`. You can specify which linker to use via `CG_RUSTFLAGS="-Clinker="`, for instance: `CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-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 and the linker to use: `CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../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: From f1c71ffb4764b17d6d23b432d871c3f0c7bb9d91 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 2 Jul 2025 11:49:05 -0400 Subject: [PATCH 10/10] Clean some config stuff up --- build_system/src/config.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/build_system/src/config.rs b/build_system/src/config.rs index 428f3766e5d..a5f802e293a 100644 --- a/build_system/src/config.rs +++ b/build_system/src/config.rs @@ -352,15 +352,6 @@ impl ConfigInfo { None => return Err("no host found".to_string()), }; - if self.target_triple.is_empty() { - // TODO: set target triple. - // TODO: why do we even need to set target_triple? - // It seems to only be needed for the linker (we could add an environment variable to - // remove this need) and the sysroot (perhaps we could find another way to find it). - // TODO TODO: seems like we would still need OVERWRITE_TARGET_TRIPLE when using a - // json spec file. - // ====> maybe not since we specify both --target and --target-triple. - } if self.target_triple.is_empty() { self.target_triple = self.host_triple.clone(); } @@ -374,7 +365,6 @@ impl ConfigInfo { if self.target_triple.is_empty() { return Err("Unknown non-native platform".to_string()); } - // TODO: check if this is still needed. linker = Some(format!("-Clinker={}-gcc", self.target_triple)); self.run_in_vm = true; }