From 228749148058da556e7d945acc9aefc48ac695e6 Mon Sep 17 00:00:00 2001 From: kirk Date: Fri, 3 Jan 2025 20:22:39 +0000 Subject: add m68k-unknown-none-elf target --- compiler/rustc_target/src/spec/mod.rs | 1 + .../src/spec/targets/m68k_unknown_none_elf.rs | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs (limited to 'compiler') diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 02962d55a60..d406c03c9a4 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..c57470a94c5 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs @@ -0,0 +1,30 @@ +use crate::abi::Endian; +use crate::spec::{CodeModel, PanicStrategy, 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, + ..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, + } +} -- cgit 1.4.1-3-g733a5 From 139ca10f65209265b9f2d830ba05993d46ac392c Mon Sep 17 00:00:00 2001 From: knickish Date: Sat, 4 Jan 2025 12:52:19 -0600 Subject: Apply suggestions from workingjubilee's code review Co-authored-by: Jubilee --- .../src/spec/targets/m68k_unknown_none_elf.rs | 2 ++ .../src/platform-support/m68k-unknown-none-elf.md | 22 +++++++++++----------- src/tools/compiletest/src/header/tests.rs | 1 - 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'compiler') 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 index c57470a94c5..37599fd6151 100644 --- a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs @@ -11,6 +11,8 @@ pub(crate) fn target() -> Target { panic_strategy: PanicStrategy::Abort, code_model: Some(CodeModel::Medium), has_rpath: false, + // should be soft-float + llvm_floatabi: None, ..Default::default() }; diff --git a/src/doc/rustc/src/platform-support/m68k-unknown-none-elf.md b/src/doc/rustc/src/platform-support/m68k-unknown-none-elf.md index acad2853240..fbfd3de366d 100644 --- a/src/doc/rustc/src/platform-support/m68k-unknown-none-elf.md +++ b/src/doc/rustc/src/platform-support/m68k-unknown-none-elf.md @@ -2,7 +2,7 @@ **Tier: 3** -Motorola 680x0 Linux +Bare metal Motorola 680x0 ## Designated Developers @@ -12,15 +12,15 @@ Motorola 680x0 Linux ## Requirements -This target requires am m68k build environment for cross-compilation which -is available on Debian and Debian-based systems, openSUSE and other distributions. +This target requires an m68k build environment for cross-compilation which +is available on Debian, Debian-based systems, openSUSE, and other distributions. -On Debian, it should be sufficient to install a g++ cross-compiler for the m68k +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: -```text -# apt install g++-m68k-linux-gnu +```sh +apt install g++-m68k-linux-gnu ``` Binaries can be run using QEMU user emulation. On Debian-based systems, it should be @@ -83,10 +83,10 @@ Currently there is no support to run the rustc test suite for this target. Recommended `.cargo/config.toml`: ```toml [unstable] -build-std = ["panic_abort","core", "alloc"] +build-std = ["panic_abort", "core", "alloc"] [target.m68k-unknown-none-elf] -# there is no easily available non-linux m68k linker, so just use the linux one +# 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 @@ -97,14 +97,14 @@ linker = "m68k-linux-gnu-ld" Rust programs can be built for this target using: -```text +```sh cargo build --target m68k-unknown-none-elf ``` Very simple programs can be run using the `qemu-m68k-static` program: -```text -$ qemu-m68k-static your-code +```sh +qemu-m68k-static your-code ``` For more complex applications, a chroot or native m68k system is required for testing. diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index dc6f262bbbc..618b66dfd4c 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -617,7 +617,6 @@ fn is_big_endian() { ("x86_64-unknown-linux-gnu", false), ("bpfeb-unknown-none", true), ("m68k-unknown-linux-gnu", true), - ("m68k-unknown-none-elf", true), ("aarch64_be-unknown-linux-gnu", true), ("powerpc64-unknown-linux-gnu", true), ]; -- cgit 1.4.1-3-g733a5 From ff7f818fc789c35f2c0406c33d2aea2aa50437bb Mon Sep 17 00:00:00 2001 From: kirk Date: Sun, 5 Jan 2025 05:04:34 +0000 Subject: change to static relocation model --- compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler') 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 index 37599fd6151..6b8b7c6ae00 100644 --- a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::abi::Endian; -use crate::spec::{CodeModel, PanicStrategy, Target, TargetOptions}; +use crate::spec::{CodeModel, PanicStrategy, RelocModel, Target, TargetOptions}; pub(crate) fn target() -> Target { let options = TargetOptions { @@ -13,6 +13,7 @@ pub(crate) fn target() -> Target { has_rpath: false, // should be soft-float llvm_floatabi: None, + relocation_model: RelocModel::Static, ..Default::default() }; -- cgit 1.4.1-3-g733a5