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