rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.73k stars 12.64k forks source link

Aarch64-Windows: Cannot build libcore with exception handling enabled #54291

Open michaelwoerister opened 6 years ago

michaelwoerister commented 6 years ago

Trying to cross-compile libcore for aarch64-pc-windows-msvc fails with (see also https://github.com/rust-lang/rust/issues/54190#issuecomment-421968456):

Building stage2 test artifacts (x86_64-pc-windows-msvc -> aarch64-pc-windows-msvc)
   Compiling term v0.0.0 (file:///C:/msys64/home/mw/2-rust/src/libterm)
   Compiling getopts v0.2.17
   Compiling test v0.0.0 (file:///C:/msys64/home/mw/2-rust/src/libtest)
error: cannot link together two panic runtimes: panic_abort and panic_unwind

error: aborting due to previous error

error: Could not compile `test`.

(Note, one has to use link.exe instead of LLD as the linker (see #54290) in order to get that far.)

The underlying problem is (probably) that aarch64-pc-windows-msvc defaults to panic_abort, while libstd is unconditionally compiled with panic_unwind. All other targets that hard-code panic_abort are probably #[no_std]?

Making aarch64-pc-windows-msvc use panic_unwind like the other non-embedded platforms leads to LLVM running into an error while trying to compile libcore:

   Compiling core v0.0.0 (file:///C:/msys64/home/mw/2-rust/src/libcore)
LLVM ERROR: Cannot select: t10: ch = cleanupret t9, libcore\str\mod.rs:3734 @[ libcore\str\mod.rs:3563 ]
In function: _ZN4core3str21_$LT$impl$u20$str$GT$4trim17hd88bcddf6e49abc8E
error: Could not compile `core`.
michaelwoerister commented 6 years ago

It looks like there's already an LLVM upstream bug report here: https://bugs.llvm.org/show_bug.cgi?id=38341. It looks like exception handling for WinARM64 will land soon: https://bugs.llvm.org/show_bug.cgi?id=38341#c5