Skip to content

Commit 7ed5c36

Browse files
committed
Add UWP mingw targets
1 parent e88a4ce commit 7ed5c36

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::spec::{LinkerFlavor, Target, TargetResult};
2+
3+
pub fn target() -> TargetResult {
4+
let mut base = super::windows_uwp_base::opts();
5+
base.cpu = "pentium4".to_string();
6+
base.max_atomic_width = Some(64);
7+
base.eliminate_frame_pointer = false; // Required for backtraces
8+
9+
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
10+
// space available to x86 Windows binaries on x86_64.
11+
base.pre_link_args
12+
.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--large-address-aware".to_string());
13+
14+
Ok(Target {
15+
llvm_target: "i686-pc-windows-gnu".to_string(),
16+
target_endian: "little".to_string(),
17+
target_pointer_width: "32".to_string(),
18+
target_c_int_width: "32".to_string(),
19+
data_layout: "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32".to_string(),
20+
arch: "x86".to_string(),
21+
target_os: "windows".to_string(),
22+
target_env: "gnu".to_string(),
23+
target_vendor: "uwp".to_string(),
24+
linker_flavor: LinkerFlavor::Gcc,
25+
options: base,
26+
})
27+
}

src/librustc_target/spec/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ mod solaris_base;
6060
mod uefi_base;
6161
mod windows_base;
6262
mod windows_msvc_base;
63+
mod windows_uwp_base;
6364
mod thumb_base;
6465
mod l4re_base;
6566
mod fuchsia_base;
@@ -434,6 +435,8 @@ supported_targets! {
434435

435436
("x86_64-pc-windows-gnu", x86_64_pc_windows_gnu),
436437
("i686-pc-windows-gnu", i686_pc_windows_gnu),
438+
("i686-uwp-windows-gnu", i686_uwp_windows_gnu),
439+
("x86_64-uwp-windows-gnu", x86_64_uwp_windows_gnu),
437440

438441
("aarch64-pc-windows-msvc", aarch64_pc_windows_msvc),
439442
("x86_64-pc-windows-msvc", x86_64_pc_windows_msvc),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
2+
use std::default::Default;
3+
4+
pub fn opts() -> TargetOptions {
5+
let mut pre_link_args = LinkArgs::new();
6+
pre_link_args.insert(LinkerFlavor::Gcc, vec![
7+
// Tell GCC to avoid linker plugins, because we are not bundling
8+
// them with Windows installer, and Rust does its own LTO anyways.
9+
"-fno-use-linker-plugin".to_string(),
10+
11+
// Always enable DEP (NX bit) when it is available
12+
"-Wl,--nxcompat".to_string(),
13+
]);
14+
15+
let mut late_link_args = LinkArgs::new();
16+
late_link_args.insert(LinkerFlavor::Gcc, vec![
17+
//"-lwinstorecompat".to_string(),
18+
//"-lmingwex".to_string(),
19+
//"-lwinstorecompat".to_string(),
20+
"-lwinstorecompat".to_string(),
21+
"-lruntimeobject".to_string(),
22+
"-lsynchronization".to_string(),
23+
"-lvcruntime140_app".to_string(),
24+
"-lucrt".to_string(),
25+
"-lwindowsapp".to_string(),
26+
"-lmingwex".to_string(),
27+
"-lmingw32".to_string(),
28+
]);
29+
30+
TargetOptions {
31+
// FIXME(#13846) this should be enabled for windows
32+
function_sections: false,
33+
linker: Some("gcc".to_string()),
34+
dynamic_linking: true,
35+
executables: false,
36+
dll_prefix: String::new(),
37+
dll_suffix: ".dll".to_string(),
38+
exe_suffix: ".exe".to_string(),
39+
staticlib_prefix: "lib".to_string(),
40+
staticlib_suffix: ".a".to_string(),
41+
no_default_libraries: true,
42+
target_family: Some("windows".to_string()),
43+
is_like_windows: true,
44+
allows_weak_linkage: false,
45+
pre_link_args,
46+
pre_link_objects_exe: vec![
47+
"rsbegin.o".to_string(), // Rust compiler runtime initialization, see rsbegin.rs
48+
],
49+
pre_link_objects_dll: vec![
50+
"rsbegin.o".to_string(),
51+
],
52+
late_link_args,
53+
post_link_objects: vec![
54+
"rsend.o".to_string(),
55+
],
56+
custom_unwind_resume: true,
57+
abi_return_struct_as_int: true,
58+
emit_debug_gdb_scripts: false,
59+
requires_uwtable: true,
60+
limit_rdylib_exports: false,
61+
62+
.. Default::default()
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::spec::{LinkerFlavor, Target, TargetResult};
2+
3+
pub fn target() -> TargetResult {
4+
let mut base = super::windows_uwp_base::opts();
5+
base.cpu = "x86-64".to_string();
6+
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
7+
base.max_atomic_width = Some(64);
8+
9+
Ok(Target {
10+
llvm_target: "x86_64-pc-windows-gnu".to_string(),
11+
target_endian: "little".to_string(),
12+
target_pointer_width: "64".to_string(),
13+
target_c_int_width: "32".to_string(),
14+
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
15+
arch: "x86_64".to_string(),
16+
target_os: "windows".to_string(),
17+
target_env: "gnu".to_string(),
18+
target_vendor: "uwp".to_string(),
19+
linker_flavor: LinkerFlavor::Gcc,
20+
options: base,
21+
})
22+
}

0 commit comments

Comments
 (0)