Skip to content

Commit 945dbcd

Browse files
Use -windows-gnu for all UEFI targets
This restores the behavior prior to #1252, when the UEFI targets were hardcoded in src/lib.rs.
1 parent 7a786c5 commit 945dbcd

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

Diff for: dev-tools/gen-target-info/src/main.rs

+35-5
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,47 @@ fn generate_target_mapping(f: &mut File, target_specs: &RustcTargetSpecs) -> std
2626
let env = spec.env.as_deref().unwrap_or("");
2727
let abi = spec.abi.as_deref().unwrap_or("");
2828

29-
// Remove deployment target information from LLVM target triples (we
30-
// will add this in another part of CC).
31-
//
32-
// FIXME(madsmtm): Should become unnecessary after
33-
// https://github.com/rust-lang/rust/pull/131037
3429
let unversioned_llvm_target = if spec.llvm_target.contains("apple") {
30+
// Remove deployment target information from LLVM target triples (we
31+
// will add this in another part of CC).
32+
//
33+
// FIXME(madsmtm): Should become unnecessary after
34+
// https://github.com/rust-lang/rust/pull/131037
3535
let mut components = spec.llvm_target.split("-").collect::<Vec<_>>();
3636

3737
components[2] = components[2].trim_end_matches(|c: char| c.is_numeric() || c == '.');
3838

3939
components.join("-")
40+
} else if os == "uefi" {
41+
// Override the UEFI LLVM targets.
42+
//
43+
// The rustc mappings (as of 1.82) for the UEFI targets are:
44+
// * i686-unknown-uefi -> i686-unknown-windows-gnu
45+
// * x86_64-unknown-uefi -> x86_64-unknown-windows
46+
// * aarch64-unknown-uefi -> aarch64-unknown-windows
47+
//
48+
// However, in cc-rs all the UEFI targets use
49+
// -windows-gnu. This has been the case since 2021 [1].
50+
// * i686-unknown-uefi -> i686-unknown-windows-gnu
51+
// * x86_64-unknown-uefi -> x86_64-unknown-windows-gnu
52+
// * aarch64-unknown-uefi -> aarch64-unknown-windows-gnu
53+
//
54+
// For now, override the UEFI mapping to keep the behavior
55+
// of cc-rs unchanged.
56+
//
57+
// TODO: as discussed in [2], it may be possible to switch
58+
// to new UEFI targets added to clang, and regardless it
59+
// would be good to have consistency between rustc and
60+
// cc-rs.
61+
//
62+
// [1]: https://github.com/rust-lang/cc-rs/pull/623
63+
// [2]: https://github.com/rust-lang/cc-rs/pull/1264
64+
let arch = if spec.arch == "x86" {
65+
"i686"
66+
} else {
67+
&spec.arch
68+
};
69+
format!("{}-unknown-windows-gnu", arch)
4070
} else {
4171
spec.llvm_target.clone()
4272
};

Diff for: src/target/generated.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ pub(crate) const LIST: &[(&str, TargetInfo<'static>)] = &[
409409
os: "uefi",
410410
env: "",
411411
abi: "",
412-
unversioned_llvm_target: "aarch64-unknown-windows",
412+
unversioned_llvm_target: "aarch64-unknown-windows-gnu",
413413
},
414414
),
415415
(
@@ -3205,7 +3205,7 @@ pub(crate) const LIST: &[(&str, TargetInfo<'static>)] = &[
32053205
os: "uefi",
32063206
env: "",
32073207
abi: "",
3208-
unversioned_llvm_target: "x86_64-unknown-windows",
3208+
unversioned_llvm_target: "x86_64-unknown-windows-gnu",
32093209
},
32103210
),
32113211
(

0 commit comments

Comments
 (0)