|
| 1 | +# m68k-unknown-none-elf |
| 2 | + |
| 3 | +**Tier: 3** |
| 4 | + |
| 5 | +Bare metal Motorola 680x0 |
| 6 | + |
| 7 | +## Designated Developers |
| 8 | + |
| 9 | +* [@knickish](https://github.com/knickish) |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +This target requires an m68k build environment for cross-compilation which |
| 14 | +is available on Debian, Debian-based systems, openSUSE, and other distributions. |
| 15 | + |
| 16 | +On Debian-based systems, it should be sufficient to install a g++ cross-compiler for the m68k |
| 17 | +architecture which will automatically pull in additional dependencies such as |
| 18 | +the glibc cross development package: |
| 19 | + |
| 20 | +```sh |
| 21 | +apt install g++-m68k-linux-gnu |
| 22 | +``` |
| 23 | + |
| 24 | +Binaries can be run using QEMU user emulation. On Debian-based systems, it should be |
| 25 | +sufficient to install the package `qemu-user-static` to be able to run simple static |
| 26 | +binaries: |
| 27 | + |
| 28 | +```text |
| 29 | +# apt install qemu-user-static |
| 30 | +``` |
| 31 | + |
| 32 | +To run more complex programs, it will be necessary to set up a Debian/m68k chroot with |
| 33 | +the help of the command `debootstrap`: |
| 34 | + |
| 35 | +```text |
| 36 | +# apt install debootstrap debian-ports-archive-keyring |
| 37 | +# debootstrap --keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg --arch=m68k unstable debian-68k http://ftp.ports.debian.org/debian-ports |
| 38 | +``` |
| 39 | + |
| 40 | +This chroot can then seamlessly entered using the normal `chroot` command thanks to |
| 41 | +QEMU user emulation: |
| 42 | + |
| 43 | +```text |
| 44 | +# chroot /path/to/debian-68k |
| 45 | +``` |
| 46 | + |
| 47 | +To get started with native builds, which are currently untested, a native Debian/m68k |
| 48 | +system can be installed either on real hardware such as 68k-based Commodore Amiga or |
| 49 | +Atari systems or emulated environments such as QEMU version 4.2 or newer or ARAnyM. |
| 50 | + |
| 51 | +ISO images for installation are provided by the Debian Ports team and can be obtained |
| 52 | +from the Debian CD image server available at: |
| 53 | + |
| 54 | +[https://cdimage.debian.org/cdimage/ports/current](https://cdimage.debian.org/cdimage/ports/current/) |
| 55 | + |
| 56 | +Documentation for Debian/m68k is available on the Debian Wiki at: |
| 57 | + |
| 58 | +[https://wiki.debian.org/M68k](https://wiki.debian.org/M68k) |
| 59 | + |
| 60 | +Support is available either through the `debian-68k` mailing list: |
| 61 | + |
| 62 | +[https://lists.debian.org/debian-68k/](https://lists.debian.org/debian-68k/) |
| 63 | + |
| 64 | +or the `#debian-68k` IRC channel on OFTC network. |
| 65 | + |
| 66 | +## Building |
| 67 | + |
| 68 | +At least llvm version `19.1.5` is required to build `core` and `alloc` for this target, and currently the gnu linker is required, as `lld` has no support for the `m68k` architecture |
| 69 | + |
| 70 | +## Cross-compilation |
| 71 | + |
| 72 | +This target can be cross-compiled from a standard Debian or Debian-based, openSUSE or any |
| 73 | +other distribution which has a basic m68k cross-toolchain available. |
| 74 | + |
| 75 | +## Testing |
| 76 | + |
| 77 | +Currently there is no support to run the rustc test suite for this target. |
| 78 | + |
| 79 | +## Building Rust programs |
| 80 | + |
| 81 | +Recommended `.cargo/config.toml`: |
| 82 | +```toml |
| 83 | +[unstable] |
| 84 | +build-std = ["panic_abort", "core", "alloc"] |
| 85 | + |
| 86 | +[target.m68k-unknown-none-elf] |
| 87 | +# as we're building for ELF, the m68k-linux linker should be adequate |
| 88 | +linker = "m68k-linux-gnu-ld" |
| 89 | + |
| 90 | +# the mold linker also supports m68k, remove the above line and uncomment the |
| 91 | +# following ones to use that instead |
| 92 | +# linker = "clang" |
| 93 | +# rustflags = ["-C", "link-arg=-fuse-ld=/path/to/mold/binary"] |
| 94 | +``` |
| 95 | + |
| 96 | +Rust programs can be built for this target using: |
| 97 | + |
| 98 | +```sh |
| 99 | +cargo build --target m68k-unknown-none-elf |
| 100 | +``` |
| 101 | + |
| 102 | +Very simple programs can be run using the `qemu-m68k-static` program: |
| 103 | + |
| 104 | +```sh |
| 105 | +qemu-m68k-static your-code |
| 106 | +``` |
| 107 | + |
| 108 | +For more complex applications, a chroot or native m68k system is required for testing. |
0 commit comments