about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLuigi Sartor Piucco <luigipiucco@gmail.com>2025-02-28 14:24:16 -0300
committerLuigi Sartor Piucco <luigipiucco@gmail.com>2025-02-28 18:27:35 -0300
commit4c1f51bf6ecc68fb6eb4b90ea6b0d0b027146aee (patch)
tree560e1369cf1941c5769d349f7e795b55b93d9a55
parent60493b8973ac5ba632952eaa2f212b56bb97ccfe (diff)
downloadrust-4c1f51bf6ecc68fb6eb4b90ea6b0d0b027146aee.tar.gz
rust-4c1f51bf6ecc68fb6eb4b90ea6b0d0b027146aee.zip
Fix link failure on AVR (incompatible ISA error)
Fixes #137739. A reproducer of the issue is present there. I believe the
root cause was introducing the avr-none target (which has no CPU by
default) and trying to get the ISA revision from there. This commit
uses the `target-cpu` option instead, which is already required to be
present for the target.

Co-authored-by: tones111 <tones111@users.noreply.github.com>
-rw-r--r--compiler/rustc_codegen_ssa/src/back/metadata.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index 236507ac0cd..3aacbcde1a7 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -373,7 +373,11 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
         Architecture::Avr => {
             // Resolve the ISA revision and set
             // the appropriate EF_AVR_ARCH flag.
-            ef_avr_arch(&sess.target.options.cpu)
+            if let Some(ref cpu) = sess.opts.cg.target_cpu {
+                ef_avr_arch(cpu)
+            } else {
+                bug!("AVR CPU not explicitly specified")
+            }
         }
         Architecture::Csky => {
             let e_flags = match sess.target.options.abi.as_ref() {