about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-01-06 05:23:55 +0000
committerbors <bors@rust-lang.org>2025-01-06 05:23:55 +0000
commitfd98df8f1423e5f9d12fae44ec2a6ae062783a7b (patch)
treebd1613e41c90e13693a45b1e032297b034f18a2d /compiler
parent56f9e6f935f9b0d6e83092a0f86d4dbeb878f17d (diff)
parentf985a37c57bfb33e23ea1c586e0ba03365fe47a3 (diff)
downloadrust-fd98df8f1423e5f9d12fae44ec2a6ae062783a7b.tar.gz
rust-fd98df8f1423e5f9d12fae44ec2a6ae062783a7b.zip
Auto merge of #135085 - knickish:m68k_unknown_none, r=workingjubilee
add m68k-unknown-none-elf target

r? `@workingjubilee`

The existing `m68k-unknown-linux-gnu` target builds `std` by default, requires atomics, and has a base cpu with an fpu. A smaller/more embedded target is desirable both to have a baseline target for the ISA, as well to make debugging easier for working on the llvm backend. Currently this target is using the `M68010` as the minimum CPU due, but as missing features are merged into the `M68k` llvm backend I am hoping to lower this further.

I have been able to build very small crates using a toolchain built against this target (together with a later version of `object`) using the configuration described in the target platform-support documentation, although getting anything of substantial complexity to build quickly hits errors in the llvm backend
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_target/src/spec/mod.rs1
-rw-r--r--compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs33
2 files changed, 34 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index ddfa6e248c3..0dc1d795a8e 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -1656,6 +1656,7 @@ supported_targets! {
     ("loongarch64-unknown-linux-gnu", loongarch64_unknown_linux_gnu),
     ("loongarch64-unknown-linux-musl", loongarch64_unknown_linux_musl),
     ("m68k-unknown-linux-gnu", m68k_unknown_linux_gnu),
+    ("m68k-unknown-none-elf", m68k_unknown_none_elf),
     ("csky-unknown-linux-gnuabiv2", csky_unknown_linux_gnuabiv2),
     ("csky-unknown-linux-gnuabiv2hf", csky_unknown_linux_gnuabiv2hf),
     ("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
diff --git a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs
new file mode 100644
index 00000000000..6b8b7c6ae00
--- /dev/null
+++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs
@@ -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()
+    };
+
+    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,
+    }
+}