Skip to content

Commit

Permalink
Merge pull request #2204 from soxfox42/rust-docs-update
Browse files Browse the repository at this point in the history
Update Rust template to remove optimisation issue
  • Loading branch information
nesbox authored May 26, 2023
2 parents 6b87ce5 + 2c51b4a commit 0509a6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion templates/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ crate-type = ["cdylib"]
buddy-alloc = { version = "0.4.1", optional = true }

[profile.release]
opt-level = 0
lto = true
strip = true

Expand Down
5 changes: 2 additions & 3 deletions templates/rust/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Rust Starter Project Template

## Important Note
This template currently produces unoptimised builds. This is required due to TIC-80's memory layout placing data at the address 0, which Rust does not understand.
If you aren't using direct framebuffer access, you should be able to use another level by changing the `Cargo.toml`.
Don't access TIC-80's I/O memory by dereferencing raw pointers. The optimiser will ruin attempts to do this, because Rust has no equivalent to C's `volatile` for direct access. Instead, use [`std::ptr::read_volatile`](https://doc.rust-lang.org/std/ptr/fn.read_volatile.html) and [`std::ptr::write_volatile`](https://doc.rust-lang.org/std/ptr/fn.write_volatile.html), or just use the standard TIC-80 `peek`/`poke`.

This is a Rust / TIC-80 starter template. Before using it, make sure you have installed the `wasm32-unknown-unknown` target using rustup:
```
Expand Down Expand Up @@ -37,4 +36,4 @@ It is highly recommended that you run `wasm-opt` on the output `cart.wasm` file,
```
wasm-opt -Os target/wasm32-unknown-unknown/release/cart.wasm -o cart.wasm
```
This will create a new, smaller `cart.wasm` file in the working directory.
This will create a new, smaller `cart.wasm` file in the working directory.

0 comments on commit 0509a6e

Please sign in to comment.