toolchain-gcc/0001-Hackery.patch
Kevin Hamacher 59f3c95a18 Compile rust-mega-drive using rustc_codegen_gcc
This still generates binaries for 68020 + stdlib functions are stubbed
out.
2025-01-14 19:04:41 +01:00

111 lines
3.8 KiB
Diff

From e2b431ff117b9e58c4a487f6021da5aa54cbbd77 Mon Sep 17 00:00:00 2001
From: User <user@example.com>
Date: Tue, 14 Jan 2025 17:23:55 +0000
Subject: [PATCH] Hackery
---
build_system/build_sysroot/Cargo.toml | 11 +++++++----
src/base.rs | 1 +
src/gcc_util.rs | 3 +--
src/lib.rs | 1 +
target_specs/m68k-unknown-linux-gnu.json | 10 +++++-----
5 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/build_system/build_sysroot/Cargo.toml b/build_system/build_sysroot/Cargo.toml
index 2415207..8076c81 100644
--- a/build_system/build_sysroot/Cargo.toml
+++ b/build_system/build_sysroot/Cargo.toml
@@ -5,12 +5,14 @@ version = "0.0.0"
resolver = "2"
[dependencies]
+# rustc-dep-of-std?
core = { path = "./sysroot_src/library/core" }
-compiler_builtins = "0.1"
+compiler_builtins = { version = "0.1" }
+#compiler_builtins = { version = "0.1", features = ['rustc-dep-of-std'] }
alloc = { path = "./sysroot_src/library/alloc" }
-std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
-test = { path = "./sysroot_src/library/test" }
-proc_macro = { path = "./sysroot_src/library/proc_macro" }
+# std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
+# test = { path = "./sysroot_src/library/test" }
+# proc_macro = { path = "./sysroot_src/library/proc_macro" }
[patch.crates-io]
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
@@ -35,4 +37,5 @@ codegen-units = 10000
[profile.release]
debug = "limited"
+panic = "abort"
#lto = "fat" # TODO(antoyo): re-enable when the failing LTO tests regarding proc-macros are fixed.
diff --git a/src/base.rs b/src/base.rs
index c9701fb..97c28f1 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -156,6 +156,7 @@ pub fn compile_codegen_unit(
let target_cpu = gcc_util::target_cpu(tcx.sess);
if target_cpu != "generic" {
context.add_command_line_option(format!("-march={}", target_cpu));
+ context.add_command_line_option("-mcpu=68000");
}
if tcx
diff --git a/src/gcc_util.rs b/src/gcc_util.rs
index 560aff4..39b1889 100644
--- a/src/gcc_util.rs
+++ b/src/gcc_util.rs
@@ -242,8 +242,7 @@ pub fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]>
fn arch_to_gcc(name: &str) -> &str {
match name {
- "M68020" => "68020",
- _ => name,
+ _ => "68000",
}
}
diff --git a/src/lib.rs b/src/lib.rs
index f6ad0c7..e19dbcf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -196,6 +196,7 @@ impl CodegenBackend for GccCodegenBackend {
let context = Context::default();
if target_cpu != "generic" {
context.add_command_line_option(format!("-march={}", target_cpu));
+ context.add_command_line_option("-mcpu=68000");
}
**self.target_info.info.lock().expect("lock") = context.get_target_info();
diff --git a/target_specs/m68k-unknown-linux-gnu.json b/target_specs/m68k-unknown-linux-gnu.json
index 95ea061..026dc98 100644
--- a/target_specs/m68k-unknown-linux-gnu.json
+++ b/target_specs/m68k-unknown-linux-gnu.json
@@ -1,17 +1,17 @@
{
"arch": "m68k",
- "cpu": "M68020",
+ "cpu": "M68000",
"crt-static-respected": true,
"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",
- "dynamic-linking": true,
+ "dynamic-linking": false,
"env": "gnu",
"has-rpath": true,
- "has-thread-local": true,
+ "has-thread-local": false,
"llvm-target": "m68k-unknown-linux-gnu",
"max-atomic-width": 32,
"os": "linux",
- "position-independent-executables": true,
- "relro-level": "full",
+ "position-independent-executables": false,
+ "relro-level": "none",
"supported-split-debuginfo": [
"packed",
"unpacked",
--
2.34.1