Skip to content

Commit e60a654

Browse files
committed
add m68k-unknown-none-elf target
1 parent 3f43b1a commit e60a654

File tree

7 files changed

+145
-0
lines changed

7 files changed

+145
-0
lines changed

Diff for: compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,7 @@ supported_targets! {
16561656
("loongarch64-unknown-linux-gnu", loongarch64_unknown_linux_gnu),
16571657
("loongarch64-unknown-linux-musl", loongarch64_unknown_linux_musl),
16581658
("m68k-unknown-linux-gnu", m68k_unknown_linux_gnu),
1659+
("m68k-unknown-none-elf", m68k_unknown_none_elf),
16591660
("csky-unknown-linux-gnuabiv2", csky_unknown_linux_gnuabiv2),
16601661
("csky-unknown-linux-gnuabiv2hf", csky_unknown_linux_gnuabiv2hf),
16611662
("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{CodeModel, PanicStrategy, Target, TargetOptions};
3+
4+
pub(crate) fn target() -> Target {
5+
let options = TargetOptions {
6+
cpu: "M68010".into(),
7+
max_atomic_width: None,
8+
endian: Endian::Big,
9+
// LLD currently does not have support for M68k
10+
linker: Some("m68k-linux-gnu-ld".into()),
11+
panic_strategy: PanicStrategy::Abort,
12+
code_model: Some(CodeModel::Medium),
13+
has_rpath: false,
14+
..Default::default()
15+
};
16+
17+
Target {
18+
llvm_target: "m68k".into(),
19+
metadata: crate::spec::TargetMetadata {
20+
description: Some("Motorola 680x0".into()),
21+
tier: Some(3),
22+
host_tools: Some(false),
23+
std: Some(false),
24+
},
25+
pointer_width: 32,
26+
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(),
27+
arch: "m68k".into(),
28+
options,
29+
}
30+
}

Diff for: src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
- [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md)
6161
- [loongarch\*-unknown-none\*](platform-support/loongarch-none.md)
6262
- [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md)
63+
- [m68k-unknown-none-elf](platform-support/m68k-unknown-none-elf.md)
6364
- [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md)
6465
- [mipsel-sony-psx](platform-support/mipsel-sony-psx.md)
6566
- [mipsisa\*r6\*-unknown-linux-gnu\*](platform-support/mips-release-6.md)

Diff for: src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ target | std | host | notes
317317
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | [^x86_32-floats-return-ABI]
318318
[`loongarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | | LoongArch64 OpenHarmony
319319
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
320+
[`m68k-unknown-none-elf`](platform-support/m68k-unknown-none-elf.md) | | | Motorola 680x0
320321
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
321322
`mips-unknown-linux-musl` | ✓ | | MIPS Linux with musl 1.2.3
322323
`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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.

Diff for: src/tools/build-manifest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ static TARGETS: &[&str] = &[
114114
"loongarch64-unknown-none",
115115
"loongarch64-unknown-none-softfloat",
116116
"m68k-unknown-linux-gnu",
117+
"m68k-unknown-none-elf",
117118
"csky-unknown-linux-gnuabiv2",
118119
"csky-unknown-linux-gnuabiv2hf",
119120
"mips-unknown-linux-gnu",

Diff for: src/tools/compiletest/src/header/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ fn is_big_endian() {
617617
("x86_64-unknown-linux-gnu", false),
618618
("bpfeb-unknown-none", true),
619619
("m68k-unknown-linux-gnu", true),
620+
("m68k-unknown-none-elf", true),
620621
("aarch64_be-unknown-linux-gnu", true),
621622
("powerpc64-unknown-linux-gnu", true),
622623
];

0 commit comments

Comments
 (0)