-
Notifications
You must be signed in to change notification settings - Fork 13.4k
add m68k-unknown-none-elf target #135085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add m68k-unknown-none-elf target #135085
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::abi::Endian; | ||
use crate::spec::{CodeModel, PanicStrategy, RelocModel, Target, TargetOptions}; | ||
|
||
pub(crate) fn target() -> Target { | ||
let options = TargetOptions { | ||
cpu: "M68010".into(), | ||
max_atomic_width: None, | ||
endian: Endian::Big, | ||
// LLD currently does not have support for M68k | ||
linker: Some("m68k-linux-gnu-ld".into()), | ||
panic_strategy: PanicStrategy::Abort, | ||
code_model: Some(CodeModel::Medium), | ||
has_rpath: false, | ||
// should be soft-float | ||
llvm_floatabi: None, | ||
relocation_model: RelocModel::Static, | ||
..Default::default() | ||
knickish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
Target { | ||
llvm_target: "m68k".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: Some("Motorola 680x0".into()), | ||
tier: Some(3), | ||
host_tools: Some(false), | ||
std: Some(false), | ||
}, | ||
pointer_width: 32, | ||
data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".into(), | ||
arch: "m68k".into(), | ||
options, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# m68k-unknown-none-elf | ||
|
||
**Tier: 3** | ||
|
||
Bare metal Motorola 680x0 | ||
|
||
## Designated Developers | ||
|
||
* [@knickish](https://github.com/knickish) | ||
* [@glaubitz](https://github.com/glaubitz) | ||
knickish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* [@ricky26](https://github.com/ricky26) | ||
knickish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Requirements | ||
|
||
This target requires an m68k build environment for cross-compilation which | ||
is available on Debian, Debian-based systems, openSUSE, and other distributions. | ||
|
||
On Debian-based systems, it should be sufficient to install a g++ cross-compiler for the m68k | ||
architecture which will automatically pull in additional dependencies such as | ||
the glibc cross development package: | ||
|
||
```sh | ||
apt install g++-m68k-linux-gnu | ||
``` | ||
|
||
Binaries can be run using QEMU user emulation. On Debian-based systems, it should be | ||
sufficient to install the package `qemu-user-static` to be able to run simple static | ||
binaries: | ||
|
||
```text | ||
# apt install qemu-user-static | ||
``` | ||
|
||
To run more complex programs, it will be necessary to set up a Debian/m68k chroot with | ||
the help of the command `debootstrap`: | ||
|
||
```text | ||
# apt install debootstrap debian-ports-archive-keyring | ||
# debootstrap --keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg --arch=m68k unstable debian-68k http://ftp.ports.debian.org/debian-ports | ||
``` | ||
|
||
This chroot can then seamlessly entered using the normal `chroot` command thanks to | ||
QEMU user emulation: | ||
|
||
```text | ||
# chroot /path/to/debian-68k | ||
``` | ||
|
||
To get started with native builds, which are currently untested, a native Debian/m68k | ||
system can be installed either on real hardware such as 68k-based Commodore Amiga or | ||
Atari systems or emulated environments such as QEMU version 4.2 or newer or ARAnyM. | ||
|
||
ISO images for installation are provided by the Debian Ports team and can be obtained | ||
from the Debian CD image server available at: | ||
|
||
[https://cdimage.debian.org/cdimage/ports/current](https://cdimage.debian.org/cdimage/ports/current/) | ||
|
||
Documentation for Debian/m68k is available on the Debian Wiki at: | ||
|
||
[https://wiki.debian.org/M68k](https://wiki.debian.org/M68k) | ||
|
||
Support is available either through the `debian-68k` mailing list: | ||
|
||
[https://lists.debian.org/debian-68k/](https://lists.debian.org/debian-68k/) | ||
|
||
or the `#debian-68k` IRC channel on OFTC network. | ||
|
||
## Building | ||
|
||
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 | ||
|
||
## Cross-compilation | ||
|
||
This target can be cross-compiled from a standard Debian or Debian-based, openSUSE or any | ||
other distribution which has a basic m68k cross-toolchain available. | ||
|
||
## Testing | ||
|
||
Currently there is no support to run the rustc test suite for this target. | ||
|
||
## Building Rust programs | ||
|
||
Recommended `.cargo/config.toml`: | ||
```toml | ||
[unstable] | ||
build-std = ["panic_abort", "core", "alloc"] | ||
|
||
[target.m68k-unknown-none-elf] | ||
# as we're building for ELF, the m68k-linux linker should be adequate | ||
linker = "m68k-linux-gnu-ld" | ||
|
||
# the mold linker also supports m68k, remove the above line and uncomment the | ||
# following ones to use that instead | ||
# linker = "clang" | ||
# rustflags = ["-C", "link-arg=-fuse-ld=/path/to/mold/binary"] | ||
``` | ||
|
||
Rust programs can be built for this target using: | ||
|
||
```sh | ||
cargo build --target m68k-unknown-none-elf | ||
``` | ||
|
||
Very simple programs can be run using the `qemu-m68k-static` program: | ||
|
||
```sh | ||
qemu-m68k-static your-code | ||
``` | ||
|
||
For more complex applications, a chroot or native m68k system is required for testing. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thinks ...well, Amigas don't have USB, so how am I gonna get my program from a modern, made-in-2024 dev computer to the Amiga? ...hmm, I can still find a 5.25 bay, and I can get a floppy drive, I guess? I know there's some adapters that let you drive them via USB, too... hope it's less than 1.44MB... anyways, that all is pretty squarely in Their Problem territory, but I do have one question that this thing should probably answer: would just copying the program to the floppy be sufficient, or should I do something else first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure that just copying it should be sufficient. It's just linux on a different arch, so as long as you cross compile it should be good to go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, for the bare metal target? but yeah sounds good then. |
Uh oh!
There was an error while loading. Please reload this page.