From 0f72faa2b84dda5a1d67d2a55126572867ca5b0d Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Thu, 3 Oct 2024 23:40:21 +0100 Subject: [PATCH] Generate correct symbols.o for sparc-unknown-none-elf Fixes #130172 --- compiler/rustc_codegen_ssa/src/back/metadata.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 (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),