about summary refs log tree commit diff
path: root/compiler/rustc_target/src/spec/json.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-23 23:49:11 +0000
committerbors <bors@rust-lang.org>2025-02-23 23:49:11 +0000
commit9af8985e059071ea2e0566969a4f140eca73fca9 (patch)
treeba685121e522acccaa15e56fb8ff2bbba147127a /compiler/rustc_target/src/spec/json.rs
parentf8a913b1381e90379c7ca63ac2b88b9518936628 (diff)
parent18ffee2126f71fe15a677d718bd27c501b0ccf52 (diff)
downloadrust-9af8985e059071ea2e0566969a4f140eca73fca9.tar.gz
rust-9af8985e059071ea2e0566969a4f140eca73fca9.zip
Auto merge of #137497 - tgross35:rollup-1oeclrr, r=tgross35
Rollup of 8 pull requests

Successful merges:

 - #136439 (Misc. `rustc_codegen_ssa` cleanups 🧹)
 - #136543 (intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic)
 - #136637 (Add binary_format to rustc target specs)
 - #137099 (Fix rustdoc test directives that were accidentally ignored 🧐)
 - #137297 (Update `compiler-builtins` to 0.1.147)
 - #137451 (FIx `sym` -> `syn` typo in tail-expr-drop-order type opt-out)
 - #137452 (bootstrap: add module docs for core:metadata)
 - #137483 (rename sub_ptr to offset_from_unsigned)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_target/src/spec/json.rs')
-rw-r--r--compiler/rustc_target/src/spec/json.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs
index f703132e51f..134405f3630 100644
--- a/compiler/rustc_target/src/spec/json.rs
+++ b/compiler/rustc_target/src/spec/json.rs
@@ -103,6 +103,19 @@ impl Target {
                     base.$key_name = Some(s);
                 }
             } );
+            ($key_name:ident, BinaryFormat) => ( {
+                let name = (stringify!($key_name)).replace("_", "-");
+                obj.remove(&name).and_then(|f| f.as_str().and_then(|s| {
+                    match s.parse::<super::BinaryFormat>() {
+                        Ok(binary_format) => base.$key_name = binary_format,
+                        _ => return Some(Err(format!(
+                            "'{s}' is not a valid value for binary_format. \
+                            Use 'coff', 'elf', 'mach-o', 'wasm' or 'xcoff' "
+                        ))),
+                    }
+                    Some(Ok(()))
+                })).unwrap_or(Ok(()))
+            } );
             ($key_name:ident, MergeFunctions) => ( {
                 let name = (stringify!($key_name)).replace("_", "-");
                 obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
@@ -585,6 +598,7 @@ impl Target {
         key!(is_like_msvc, bool);
         key!(is_like_wasm, bool);
         key!(is_like_android, bool);
+        key!(binary_format, BinaryFormat)?;
         key!(default_dwarf_version, u32);
         key!(allows_weak_linkage, bool);
         key!(has_rpath, bool);
@@ -762,6 +776,7 @@ impl ToJson for Target {
         target_option_val!(is_like_msvc);
         target_option_val!(is_like_wasm);
         target_option_val!(is_like_android);
+        target_option_val!(binary_format);
         target_option_val!(default_dwarf_version);
         target_option_val!(allows_weak_linkage);
         target_option_val!(has_rpath);