Skip to content

Commit 35db4cc

Browse files
committed
use asymmetric json roundtripping
this ensures roundtripping of stable and unstable values: - backwards-compatible values can be deserialized, as well as the new unstable values - unstable values are serialized.
1 parent b0a6798 commit 35db4cc

File tree

1 file changed

+16
-1
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+16
-1
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ impl LinkerFlavor {
284284
}
285285
}
286286

287+
/// Returns the corresponding backwards-compatible CLI flavor.
287288
fn to_cli(self) -> LinkerFlavorCli {
288289
match self {
289290
LinkerFlavor::Gnu(Cc::Yes, _)
@@ -304,6 +305,20 @@ impl LinkerFlavor {
304305
}
305306
}
306307

308+
/// Returns the modern CLI flavor that is the counterpart of this flavor.
309+
fn to_cli_counterpart(self) -> LinkerFlavorCli {
310+
match self {
311+
LinkerFlavor::Gnu(cc, lld) => LinkerFlavorCli::Gnu(cc, lld),
312+
LinkerFlavor::Darwin(cc, lld) => LinkerFlavorCli::Darwin(cc, lld),
313+
LinkerFlavor::WasmLld(cc) => LinkerFlavorCli::WasmLld(cc),
314+
LinkerFlavor::Unix(cc) => LinkerFlavorCli::Unix(cc),
315+
LinkerFlavor::Msvc(lld) => LinkerFlavorCli::Msvc(lld),
316+
LinkerFlavor::EmCc => LinkerFlavorCli::EmCc,
317+
LinkerFlavor::Bpf => LinkerFlavorCli::Bpf,
318+
LinkerFlavor::Ptx => LinkerFlavorCli::Ptx,
319+
}
320+
}
321+
307322
fn infer_cli_hints(cli: LinkerFlavorCli) -> (Option<Cc>, Option<Lld>) {
308323
match cli {
309324
LinkerFlavorCli::Gnu(cc, lld) | LinkerFlavorCli::Darwin(cc, lld) => {
@@ -2270,7 +2285,7 @@ impl TargetOptions {
22702285
}
22712286

22722287
fn update_to_cli(&mut self) {
2273-
self.linker_flavor_json = self.linker_flavor.to_cli();
2288+
self.linker_flavor_json = self.linker_flavor.to_cli_counterpart();
22742289
self.lld_flavor_json = self.linker_flavor.lld_flavor();
22752290
self.linker_is_gnu_json = self.linker_flavor.is_gnu();
22762291
for (args, args_json) in [

0 commit comments

Comments
 (0)