Skip to content
26 changes: 17 additions & 9 deletions .github/workflows/m68k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -59,14 +57,12 @@ 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
run: |
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV



#- name: Cache rust repository
## We only clone the rust repository for rustc tests
Expand All @@ -87,15 +83,15 @@ 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
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
Expand All @@ -106,7 +102,19 @@ 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

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
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
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!
Expand Down
5 changes: 0 additions & 5 deletions build_system/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,6 @@ 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() {
self.target_triple = self.host_triple.clone();
}
Expand Down
6 changes: 3 additions & 3 deletions doc/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ 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`.
* 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=<linker>"`, 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:

* 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:

Expand Down