From 39efa7c590a9e0d761550005d161a9356a54339a Mon Sep 17 00:00:00 2001
From: Vladyslav Tsilytskyi <vladyslav.tsilytskyi.extern@tasking.com>
Date: Mon, 17 Mar 2025 14:19:55 +0100
Subject: [PATCH] Make default_codegen_backend serializable

---
 compiler/rustc_target/src/spec/json.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs
index 134405f3630e7..4b6de5e18f50f 100644
--- a/compiler/rustc_target/src/spec/json.rs
+++ b/compiler/rustc_target/src/spec/json.rs
@@ -103,6 +103,12 @@ impl Target {
                     base.$key_name = Some(s);
                 }
             } );
+            ($key_name:ident, Option<StaticCow<str>>) => ( {
+                let name = (stringify!($key_name)).replace("_", "-");
+                if let Some(s) = obj.remove(&name).and_then(|b| Some(b.as_str()?.to_string())) {
+                    base.$key_name = Some(s.into());
+                }
+            } );
             ($key_name:ident, BinaryFormat) => ( {
                 let name = (stringify!($key_name)).replace("_", "-");
                 obj.remove(&name).and_then(|f| f.as_str().and_then(|s| {
@@ -623,6 +629,7 @@ impl Target {
         key!(stack_probes, StackProbeType)?;
         key!(min_global_align, Option<u64>);
         key!(default_codegen_units, Option<u64>);
+        key!(default_codegen_backend, Option<StaticCow<str>>);
         key!(trap_unreachable, bool);
         key!(requires_lto, bool);
         key!(singlethread, bool);
@@ -801,6 +808,7 @@ impl ToJson for Target {
         target_option_val!(stack_probes);
         target_option_val!(min_global_align);
         target_option_val!(default_codegen_units);
+        target_option_val!(default_codegen_backend);
         target_option_val!(trap_unreachable);
         target_option_val!(requires_lto);
         target_option_val!(singlethread);