We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4b723d9 commit 1c10013Copy full SHA for 1c10013
3 files changed
dev-tools/gen-target-info/src/main.rs
@@ -21,6 +21,22 @@ fn generate_riscv_arch_mapping(f: &mut File, target_specs: &RustcTargetSpecs) {
21
write_target_tuple_mapping(f, "RISCV_ARCH_MAPPING", &riscv_target_mapping);
22
}
23
24
+fn generate_windows_triple_mapping(f: &mut File, target_specs: &RustcTargetSpecs) {
25
+ let mut windows_target_mapping = target_specs
26
+ .0
27
+ .iter()
28
+ .filter_map(|(target, target_spec)| {
29
+ let rust_target_parts = target.splitn(4, '-').collect::<Vec<_>>();
30
+ let os = *rust_target_parts.get(2)?;
31
+ (os.contains("windows") && target != &*target_spec.llvm_target)
32
+ .then_some((&**target, &*target_spec.llvm_target))
33
+ })
34
+ .collect::<Vec<_>>();
35
+ windows_target_mapping.sort_unstable_by_key(|(triple, _)| &**triple);
36
+ windows_target_mapping.dedup();
37
+ write_target_tuple_mapping(f, "WINDOWS_TRIPLE_MAPPING", &windows_target_mapping);
38
+}
39
+
40
fn main() {
41
let target_specs = get_target_specs_from_json();
42
@@ -34,6 +50,7 @@ fn main() {
50
51
// Start generating
52
generate_riscv_arch_mapping(&mut f, &target_specs);
53
+ generate_windows_triple_mapping(&mut f, &target_specs);
54
55
// Flush the data onto disk
56
f.flush().unwrap();
src/lib.rs
@@ -2189,6 +2189,17 @@ impl Build {
2189
2190
2191
cmd.push_cc_arg(format!("--target={}", target).into());
2192
+ } else if let Ok(index) = target_info::WINDOWS_TRIPLE_MAPPING
2193
+ .binary_search_by_key(&target, |(target, _)| target)
2194
+ {
2195
+ cmd.args.push(
2196
+ format!(
2197
+ "--target={}-{}",
2198
+ target_info::WINDOWS_TRIPLE_MAPPING[index].1,
2199
+ rest
2200
+ )
2201
+ .into(),
2202
2203
} else {
2204
2205
src/target_info.rs
@@ -12,3 +12,15 @@ pub const RISCV_ARCH_MAPPING: &[(&str, &str)] = &[
12
("riscv64gc", "riscv64"),
13
("riscv64imac", "riscv64"),
14
];
15
+pub const WINDOWS_TRIPLE_MAPPING: &[(&str, &str)] = &[
16
+ ("aarch64-pc-windows-gnullvm", "aarch64-pc-windows-gnu"),
17
+ ("aarch64-uwp-windows-msvc", "aarch64-pc-windows-msvc"),
18
+ ("i686-pc-windows-gnullvm", "i686-pc-windows-gnu"),
19
+ ("i686-uwp-windows-gnu", "i686-pc-windows-gnu"),
20
+ ("i686-uwp-windows-msvc", "i686-pc-windows-msvc"),
+ ("i686-win7-windows-msvc", "i686-pc-windows-msvc"),
+ ("thumbv7a-uwp-windows-msvc", "thumbv7a-pc-windows-msvc"),
+ ("x86_64-pc-windows-gnullvm", "x86_64-pc-windows-gnu"),
+ ("x86_64-uwp-windows-gnu", "x86_64-pc-windows-gnu"),
+ ("x86_64-uwp-windows-msvc", "x86_64-pc-windows-msvc"),
+];
0 commit comments