amiga-sys
Unofficial unsafe bindings for the Amiga (m68k) system libraries.
Tested on rustc 1.99.0-nightly (87e5904f5 2026-07-20) and cargo 1.99.0-nightly (3efb1f477 2026-07-17).
Note: if you want to build high performance games or demos, have a look at amiga-rust.
WARNING: this is an experimental crate built on top of experimental Rust m68k toolchain
It is likely that Rust programs developed for Amiga will crash or simply refuse to compile, because many pieces are still missing:
- the LLVM compiler has only experimental support for m68k: it may produce invalid code or crash during compilation because of many LLVM bugs for m68k
- there's many Rust bugs for m68k
- this crate isn't well tested: it may have bugs and corrupt memory
If you still want to try this out, then read on..
Features
- direct unsafe bindings to the Amiga system libraries (based on Amiga NDK 3.2R4)
- includes almost all definitions from NDK for Kickstart 1.0 (V30) to 3.2 (V47)
- the bindings are unsafe: it is very easy to write a program which crashes
- no dependency to the Amiga Native Development Kit (NDK): no dependency to the NDK headers or amiga.lib (note: these bindings have been generated from some of the NDK headers)
- supports
no_std(no dependency tostdoralloc) - only cross-compiling for Amiga (no building on Amiga)
- extra feature: a lazy developer who doesn't respond quickly to issues or pull requests
Not supported
- no start up code to handle launching programs from Workbench
- no functions with variadic arguments: there's always a similar function available without variadic arguments (the replacement function's name usually ends with Args, List or A)
- no amiga.lib functions: BeginIO(), CreatePort(), CreateTask(), NewList(), TimeDelay(), etc. These are implemented in amiga-support.
- no alib_stdio: functions duplicating libc functionality: printf(), fgetc(), etc.
- no debug.lib or ddebug.lib functions: KGetChar(), KPrintF(), DGetChar(), DPrintF(), etc.
- no direct access to hardware
- no third-party libraries or devices
- no support for AmigaOS 4.0 or other derivatives, PowerPC or other non-m68k Amiga versions
Special cases
- callbacks called by the Amiga libraries have their arguments stored in CPU registers and
should return a value in the CPU register d0. It's up to the callback function
to use assembly code to access the register values. For an example, see the tester
example
test_rawdofmt(). FileInfoBlockandInfoDatashould be aligned to 4 bytes, but they don't have alignment modifiers, because it would change the size ofAnchorPathandAChain. Proper alignment can be achieved by wrappingFileInfoBlockandInfoData:#[repr(C, align(4))] pub struct AlignedFileInfoBlock { data: FileInfoBlock }
Generating the bindings
The crate includes pregenerated bindings. If someone wants to regenerate them, follow these steps. These steps have been tested with nightly-2026-07-20.
- Copy Amiga NDK 3.2R4
to the
amiga-sysparent folder, so that it is next to theamiga-sysfolder - Install bindgen with its requirements.
cd amiga-sys- Run
generate.sh
Building the examples
These steps have been tested on Ubuntu 24.04 LTS.
Prerequisites:
- Rust nightly:
rustup install nightlyandrustup component add rust-src. - the
m68k-linux-gnu-ldlinker for m68k-unknown-none-elf (qemu-user-static isn't needed) - elf2hunk
Building:
cd examples/hello-cli
cargo +nightly build --target m68k-unknown-none-elf --release
elf2hunk target/m68k-unknown-none-elf/release/hello-cli target/m68k-unknown-none-elf/release/hello-cli.exe
# Amiga executable: target/m68k-unknown-none-elf/release/hello-cli.exe
The release build is usually more successful than the debug build.
The examples have a .cargo/config.toml file to select the linker.
To build the tester example, follow the steps above by replacing hello-cli with tester.
Typical build errors
could not compile..(signal: 5, SIGTRAP: trace/breakpoint trap)- solution: fix the compiler
Amiga string handling
Often function string parameters are null-terminated. Sometimes they are not
null-terminated and the length is given as an extra parameter. Structs mostly use null-terminated
strings (STRPTR). Amiga uses the
ECMA-94 encoding,
which is the same as ISO-8859-1 and Latin1.
Related
- amidos: safe API to write CLI programs for Amiga m68k
- amiga-rust: direct access to hardware
- amiga-debug Visual Studio Code Extension: C/C++ and build tools for Amiga
License
Licensed under either of Apache License, Version 2.0 or 0BSD license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.