Start adding an aarch64-pc-windows-msvc target
This commit adds the necessary definitions for target specs and such as well as
the necessary support in libstd to compile basic `aarch64-pc-windows-msvc`
binaries. The target is not currently built on CI, but it can be built locally
with:
./configure --target=aarch64-pc-windows-msvc --set rust.lld
./x.py build src/libstd --target aarch64-pc-windows-msvc
Currently this fails to build `libtest` due to a linker bug (seemingly in LLD?)
which hasn't been investigate yet. Otherwise though with libstd you can build a
hello world program (linked with LLD). I've not tried to execute it yet, but it
at least links!
Full support for this target is still a long road ahead, but this is hopefully a
good stepping stone to get started.
Points of note about this target are:
* Currently defaults to `panic=abort` as support is still landing in LLVM for
SEH on AArch64.
* Currently defaults to LLD as a linker as I was able to get farther with it
than I was with `link.exe`
This commit is contained in:
parent
d767ee1161
commit
fccc04d3e7
8 changed files with 201 additions and 33 deletions
|
|
@ -229,6 +229,7 @@ impl StackFrame for c::STACKFRAME_EX {
|
|||
self.AddrFrame.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
c::IMAGE_FILE_MACHINE_I386
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn init(&mut self, ctx: &c::CONTEXT) -> c::DWORD {
|
||||
self.AddrPC.Offset = ctx.Rip as u64;
|
||||
|
|
@ -240,6 +241,17 @@ impl StackFrame for c::STACKFRAME_EX {
|
|||
c::IMAGE_FILE_MACHINE_AMD64
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
fn init(&mut self, ctx: &c::CONTEXT) -> c::DWORD {
|
||||
self.AddrPC.Offset = ctx.Pc as u64;
|
||||
self.AddrPC.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
self.AddrStack.Offset = ctx.Sp as u64;
|
||||
self.AddrStack.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
self.AddrFrame.Offset = ctx.Fp as u64;
|
||||
self.AddrFrame.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
c::IMAGE_FILE_MACHINE_ARM64
|
||||
}
|
||||
|
||||
fn get_addr(&self) -> *const u8 {
|
||||
(self.AddrPC.Offset - 1) as *const u8
|
||||
}
|
||||
|
|
@ -260,6 +272,7 @@ impl StackFrame for c::STACKFRAME64 {
|
|||
self.AddrFrame.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
c::IMAGE_FILE_MACHINE_I386
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn init(&mut self, ctx: &c::CONTEXT) -> c::DWORD {
|
||||
self.AddrPC.Offset = ctx.Rip as u64;
|
||||
|
|
@ -271,6 +284,17 @@ impl StackFrame for c::STACKFRAME64 {
|
|||
c::IMAGE_FILE_MACHINE_AMD64
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
fn init(&mut self, ctx: &c::CONTEXT) -> c::DWORD {
|
||||
self.AddrPC.Offset = ctx.Pc as u64;
|
||||
self.AddrPC.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
self.AddrStack.Offset = ctx.Sp as u64;
|
||||
self.AddrStack.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
self.AddrFrame.Offset = ctx.Fp as u64;
|
||||
self.AddrFrame.Mode = c::ADDRESS_MODE::AddrModeFlat;
|
||||
c::IMAGE_FILE_MACHINE_ARM64
|
||||
}
|
||||
|
||||
fn get_addr(&self) -> *const u8 {
|
||||
(self.AddrPC.Offset - 1) as *const u8
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,6 +280,9 @@ pub const IMAGE_FILE_MACHINE_I386: DWORD = 0x014c;
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
#[cfg(feature = "backtrace")]
|
||||
pub const IMAGE_FILE_MACHINE_AMD64: DWORD = 0x8664;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[cfg(feature = "backtrace")]
|
||||
pub const IMAGE_FILE_MACHINE_ARM64: DWORD = 0xAA64;
|
||||
|
||||
pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
|
||||
pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
|
||||
|
|
@ -791,9 +794,68 @@ pub struct FLOATING_SAVE_AREA {
|
|||
// will not appear in the final documentation. This should be also defined for
|
||||
// other architectures supported by Windows such as ARM, and for historical
|
||||
// interest, maybe MIPS and PowerPC as well.
|
||||
#[cfg(all(dox, not(any(target_arch = "x86_64", target_arch = "x86"))))]
|
||||
#[cfg(all(dox, not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"))))]
|
||||
pub enum CONTEXT {}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub const ARM64_MAX_BREAKPOINTS: usize = 8;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub const ARM64_MAX_WATCHPOINTS: usize = 2;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[repr(C)]
|
||||
pub struct ARM64_NT_NEON128 {
|
||||
pub D: [f64; 2],
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[repr(C, align(16))]
|
||||
pub struct CONTEXT {
|
||||
pub ContextFlags: DWORD,
|
||||
pub Cpsr: DWORD,
|
||||
pub X0: u64,
|
||||
pub X1: u64,
|
||||
pub X2: u64,
|
||||
pub X3: u64,
|
||||
pub X4: u64,
|
||||
pub X5: u64,
|
||||
pub X6: u64,
|
||||
pub X7: u64,
|
||||
pub X8: u64,
|
||||
pub X9: u64,
|
||||
pub X10: u64,
|
||||
pub X11: u64,
|
||||
pub X12: u64,
|
||||
pub X13: u64,
|
||||
pub X14: u64,
|
||||
pub X15: u64,
|
||||
pub X16: u64,
|
||||
pub X17: u64,
|
||||
pub X18: u64,
|
||||
pub X19: u64,
|
||||
pub X20: u64,
|
||||
pub X21: u64,
|
||||
pub X22: u64,
|
||||
pub X23: u64,
|
||||
pub X24: u64,
|
||||
pub X25: u64,
|
||||
pub X26: u64,
|
||||
pub X27: u64,
|
||||
pub X28: u64,
|
||||
pub Fp: u64,
|
||||
pub Lr: u64,
|
||||
pub Sp: u64,
|
||||
pub Pc: u64,
|
||||
pub V: [ARM64_NT_NEON128; 32],
|
||||
pub Fpcr: DWORD,
|
||||
pub Fpsr: DWORD,
|
||||
pub Bcr: [DWORD; ARM64_MAX_BREAKPOINTS],
|
||||
pub Bvr: [DWORD; ARM64_MAX_BREAKPOINTS],
|
||||
pub Wcr: [DWORD; ARM64_MAX_WATCHPOINTS],
|
||||
pub Wvr: [DWORD; ARM64_MAX_WATCHPOINTS],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SOCKADDR_STORAGE_LH {
|
||||
pub ss_family: ADDRESS_FAMILY,
|
||||
|
|
|
|||
|
|
@ -266,8 +266,12 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
|
|||
// handlers.
|
||||
//
|
||||
// https://msdn.microsoft.com/en-us/library/dn774154.aspx
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
#[allow(unreachable_code)]
|
||||
pub unsafe fn abort_internal() -> ! {
|
||||
asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
|
||||
::intrinsics::unreachable();
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
{
|
||||
asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
|
||||
::intrinsics::unreachable();
|
||||
}
|
||||
::intrinsics::abort();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue