about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorJonathan 'theJPster' Pallant <github@thejpster.org.uk>2024-10-03 23:40:21 +0100
committerJonathan 'theJPster' Pallant <github@thejpster.org.uk>2024-10-03 23:40:21 +0100
commit0f72faa2b84dda5a1d67d2a55126572867ca5b0d (patch)
treeb6b7673f133f45af937f816dca6663cc9e7003a3 /compiler
parent56e35a5dbb37898433a43133dff0398f46d577b8 (diff)
downloadrust-0f72faa2b84dda5a1d67d2a55126572867ca5b0d.tar.gz
rust-0f72faa2b84dda5a1d67d2a55126572867ca5b0d.zip
Generate correct symbols.o for sparc-unknown-none-elf
Fixes #130172
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/metadata.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index 8857fda1e97..77a84cfc7b7 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -209,7 +209,15 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
         "powerpc64" => (Architecture::PowerPc64, None),
         "riscv32" => (Architecture::Riscv32, None),
         "riscv64" => (Architecture::Riscv64, None),
-        "sparc" => (Architecture::Sparc32Plus, None),
+        "sparc" => {
+            if sess.target.options.cpu == "v9" {
+                // Target uses V8+, aka EM_SPARC32PLUS, aka 64-bit V9 but in 32-bit mode
+                (Architecture::Sparc32Plus, None)
+            } else {
+                // Target uses V7 or V8, aka EM_SPARC
+                (Architecture::Sparc, None)
+            }
+        }
         "sparc64" => (Architecture::Sparc64, None),
         "avr" => (Architecture::Avr, None),
         "msp430" => (Architecture::Msp430, None),