-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
175 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::spec::Target; | ||
|
||
pub fn target() -> Target { | ||
let mut base = super::windows_gnullvm_base::opts(); | ||
base.max_atomic_width = Some(64); | ||
base.features = "+neon,+fp-armv8".into(); | ||
base.linker = Some("aarch64-w64-mingw32-clang".into()); | ||
|
||
Target { | ||
llvm_target: "aarch64-pc-windows-gnu".into(), | ||
pointer_width: 64, | ||
data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), | ||
arch: "aarch64".into(), | ||
options: base, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::spec::{cvs, LinkArgs, LinkerFlavor, TargetOptions}; | ||
|
||
pub fn opts() -> TargetOptions { | ||
let pre_link_args = LinkArgs::from([( | ||
LinkerFlavor::Gcc, | ||
vec![ | ||
// We cannot use `-nodefaultlibs` because compiler-rt has to be passed | ||
// as a path since it's not added to linker search path by the default. | ||
// There were attemts to make it behave like libgcc (so one can just use -l<name>) | ||
// but LLVM maintainers rejected it: https://reviews.llvm.org/D51440 | ||
"-nolibc".into(), | ||
"--unwindlib=none".into(), | ||
], | ||
)]); | ||
let late_link_args = LinkArgs::from([( | ||
LinkerFlavor::Gcc, | ||
// Order of `late_link_args*` does not matter with LLD. | ||
vec![ | ||
"-lmingw32".into(), | ||
"-lmingwex".into(), | ||
"-lmsvcrt".into(), | ||
"-lkernel32".into(), | ||
"-luser32".into(), | ||
], | ||
)]); | ||
|
||
TargetOptions { | ||
os: "windows".into(), | ||
env: "gnu".into(), | ||
vendor: "pc".into(), | ||
abi: "llvm".into(), | ||
linker: Some("clang".into()), | ||
dynamic_linking: true, | ||
executables: true, | ||
dll_prefix: "".into(), | ||
dll_suffix: ".dll".into(), | ||
exe_suffix: ".exe".into(), | ||
families: cvs!["windows"], | ||
is_like_windows: true, | ||
allows_weak_linkage: false, | ||
pre_link_args, | ||
late_link_args, | ||
abi_return_struct_as_int: true, | ||
emit_debug_gdb_scripts: false, | ||
requires_uwtable: true, | ||
eh_frame_header: false, | ||
no_default_libraries: false, | ||
has_thread_local: true, | ||
|
||
..Default::default() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::spec::{LinkerFlavor, Target}; | ||
|
||
pub fn target() -> Target { | ||
let mut base = super::windows_gnullvm_base::opts(); | ||
base.cpu = "x86-64".into(); | ||
let gcc_pre_link_args = base.pre_link_args.entry(LinkerFlavor::Gcc).or_default(); | ||
gcc_pre_link_args.push("-m64".into()); | ||
base.max_atomic_width = Some(64); | ||
base.linker = Some("x86_64-w64-mingw32-clang".into()); | ||
|
||
Target { | ||
llvm_target: "x86_64-pc-windows-gnu".into(), | ||
pointer_width: 64, | ||
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
.into(), | ||
arch: "x86_64".into(), | ||
options: base, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# \*-pc-windows-gnullvm | ||
|
||
**Tier: 3** | ||
|
||
Windows targets similar to `*-pc-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of GCC/Binutils. | ||
|
||
Target triples avaiable so far: | ||
- `aarch64-pc-windows-gnullvm` | ||
- `x86_64-pc-windows-gnullvm` | ||
|
||
## Target maintainers | ||
|
||
- [@mati865](https://github.com/mati865) | ||
|
||
## Requirements | ||
|
||
The easiest way to obtain these targets is cross-compilation but native build from `x86_64-pc-windows-gnu` is possible with few hacks which I don't recommend. | ||
Std support is expected to be on pair with `*-pc-windows-gnu`. | ||
|
||
Binaries for this target should be at least on pair with `*-pc-windows-gnu` in terms of requirements and functionality. | ||
|
||
Those targets follow Windows calling convention for `extern "C"`. | ||
|
||
Like with any other Windows target created binaries are in PE format. | ||
|
||
## Building the target | ||
|
||
For cross-compilation I recommend using [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) toolchain, one change that seems necessary beside configuring corss compilers is disabling experimental `m86k` target. Otherwise LLVM build fails with `multiple definition ...` errors. | ||
Native bootstrapping builds require rather fragile hacks until host artifacts are avaiable so I won't describe them here. | ||
|
||
## Building Rust programs | ||
|
||
Rust does not yet ship pre-compiled artifacts for this target. To compile for | ||
this target, you will either need to build Rust with the target enabled (see | ||
"Building the target" above), or build your own copy of `core` by using | ||
`build-std` or similar. | ||
|
||
## Testing | ||
|
||
Created binaries work fine on Windows or Wine using native hardware. Testing AArch64 on x86_64 is problematic though and requires spending some time with QEMU. | ||
Once these targets bootstrap themselves on native hardware they should pass Rust testsuite. | ||
|
||
## Cross-compilation toolchains and C code | ||
|
||
Compatible C code can be built with Clang's `aarch64-pc-windows-gnu` and `x86_64-pc-windows-gnu` targets as long as LLVM based C toolchains are used. | ||
Those include: | ||
- [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) | ||
- [MSYS2 with CLANG* environment](https://www.msys2.org/docs/environments) |