Use inline asm for Windows instead of external assembly#144
Use inline asm for Windows instead of external assembly#144mmastrac wants to merge 1 commit intorust-lang:masterfrom
Conversation
86be7e5 to
26628fa
Compare
Replace external assembly files (aarch64_armasm.asm, x86_64_msvc.asm) with Rust inline asm for all Windows x86_64/aarch64 targets (msvc, gnu, gnullvm). This avoids cross-compilation issues where MASM isn't available and LLVM's assembler rejects ELF directives (.type, .size) on COFF targets. The inline asm module (src/asm/windows/) provides: - rust_psm_stack_direction: trivial constant return - rust_psm_stack_pointer: single asm instruction (approximate without #[naked], safe for stacker's 32KB+ threshold checks) - rust_psm_replace_stack: stack switch + tail call - rust_psm_on_stack: save/restore frame + TIB (x86_64), call callback Deleted: aarch64_armasm.asm, x86_64_msvc.asm Tested: cargo xwin check for x86_64-pc-windows-msvc, aarch64-pc-windows-msvc
26628fa to
5efbb6d
Compare
|
I'm not 100% keen on this specific approach. At the very least I believe the implementation should be using |
|
That's a fair point - The inline asm approach here was pragmatic (solving a cross-compilation blocker), but I agree it's better as a comprehensive migration. Our current blocker is solved by using a temporary fork to work around the issue so we wouldn't be in a rush to land this. If you'd like I can specifically chop out pieces from #77 and have you review them (maybe one platform at a time) and gradually move towards a I've got some bandwidth to assist with this, so let me know what the most effective way might be (or if you'd like to discuss more directly than GH comments)! EDIT: Also, given the low-level nature of the crate, bumping the MSRV for this crate might be an interesting discussion to have before that. |
This set of crates is first and foremost built for the purposes of rustc, so MSRV for this crate is what rustc needs, which is basically the current beta. We can definitely opt even for unstable features (although I'd do that under a feature flag.)
I don't really have the bandwidth currently to keep a super close attention to this effort, mostly just a bit of time to review changes on some of the weekends. In that sense a larger PR that encompasses more of the stuff at once would be better. Fortunately, it seems like there are potentially easy first steps forward with We can explore fancier improvements such as specific ways to construct the |
The external assembly files for aarch64 Windows (aarch64_armasm.asm and the GAS fallback aarch_aapcs64.s) are problematic when cross-compiling from non-Windows hosts: MASM isn't available, and the GAS fallback doesn't receive the necessary preprocessor defines when cc-rs detects an MSVC compiler.
To simplify Windows support, we can just move to inline asm for all the supported platforms - they don't actually support stack switching anyways. x86_64 and aarch64 are ported, but i686's switching code is left as a placeholder (32-bit windows might die off before someone has a chance to get it working...).
There were a few
clang-clmatrix jobs that were failing because of deprecated i686 support in msys. They are no longer an issue because we're just usingasm!for that platform and could be removed.Ideally we'd use
nakedon the SP functions but the MSRV is too high for that. Instead we make theminline(always). I don't believe that the exact SP is required, regardless of this.I added
nostackon thesp-reader function because that seems to be correct:Fixes #143