Skip to content

Commit

Permalink
Remove OVERWRITE_TARGET_TRIPLE env var now that config.sh is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Feb 8, 2024
1 parent 8235b26 commit bfb5dd0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/m68k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,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 @@ -109,4 +107,13 @@ jobs:
- name: Run tests
run: |
# TODO: remove --features master when it is back to the default.
./y.sh test --release --features master --clean --build-sysroot ${{ matrix.commands }}
./y.sh test --target-triple m68k-unknown-linux-gnu --release --features master --clean --build-sysroot ${{ matrix.commands }}
- name: Run Hello World!
run: |
# TODO: remove --features master when it is back to the default.
./y.sh build --target-triple m68k-unknown-linux-gnu --features master
cd projects/hello_world
../../y.sh cargo run --target m68k-unknown-linux-gnu > hello_world_stdout
test $(cat hello_world_stdout) == "Hello, world!" || exit 1
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,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`.
* 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`.
* 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 --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
10 changes: 7 additions & 3 deletions build_system/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ impl ConfigInfo {
};

if self.target_triple.is_empty() {
if let Some(overwrite) = env.get("OVERWRITE_TARGET_TRIPLE") {
self.target_triple = overwrite.clone();
}
// 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();
Expand Down
8 changes: 8 additions & 0 deletions projects/hello_world/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "hello_world"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
3 changes: 3 additions & 0 deletions projects/hello_world/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit bfb5dd0

Please sign in to comment.