rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.62k stars 101 forks source link

What is causing this crash? #1510

Closed frederikhors closed 3 months ago

frederikhors commented 3 months ago

cargo-clif.exe run -p app is crashing with:

thread 'rustc' panicked at src\archive.rs:23:9:
not implemented: creating dll imports is not yet supported
stack backtrace:
   Compiling ryu v1.0.18
   0:     0x7ff8c00a4e3d - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ff8c00a4e3d - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff8c00a4e3d - std::sys::backtrace::_print_fmt
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\sys\backtrace.rs:68
   3:     0x7ff8c00a4e3d - std::sys::backtrace::_print::impl$0::fmt
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\sys\backtrace.rs:44
   4:     0x7ff8c00d54a9 - core::fmt::rt::Argument::fmt
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\core\src\fmt\rt.rs:173
   5:     0x7ff8c00d54a9 - core::fmt::write
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\core\src\fmt\mod.rs:1182
   6:     0x7ff8c009b341 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\io\mod.rs:1835
   7:     0x7ff8c00a4c16 - std::sys::backtrace::print
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\sys\backtrace.rs:34
   8:     0x7ff8c00a7e18 - std::panicking::default_hook::closure$1
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\panicking.rs:265
   9:     0x7ff8c00a7ac9 - std::panicking::default_hook
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\panicking.rs:292
  10:     0x7ff8a2b7b115 - memchr
  11:     0x7ff8c00a859b - alloc::boxed::impl$50::call
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\alloc\src\boxed.rs:2078
  12:     0x7ff8c00a859b - std::panicking::rust_panic_with_hook
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\panicking.rs:804
  13:     0x7ff8c00a836f - std::panicking::begin_panic_handler::closure$0
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\panicking.rs:663
  14:     0x7ff8c00a57af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\sys\backtrace.rs:171
  15:     0x7ff8c00a7f86 - std::panicking::begin_panic_handler
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\panicking.rs:661
  16:     0x7ff8c00fde54 - core::panicking::panic_fmt
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\core\src\panicking.rs:74
  17:     0x7ff8bf82830c - <rustc_codegen_cranelift::archive::ArArchiveBuilderBuilder as rustc_codegen_ssa::back::archive::ArchiveBuilderBuilder>::create_dll_import_lib::h138e4a4d05900f0a
  18:     0x7ff8a138f428 - rustc_codegen_ssa[f52e3fb87beb71e3]::back::link::each_linked_rlib
  19:     0x7ff8a138a9f6 - rustc_codegen_ssa[f52e3fb87beb71e3]::back::link::link_binary
  20:     0x7ff8bf85a4c6 - <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link::hd19571cdbe1c7838
  21:     0x7ff89e895ad8 - <rustc_interface[b7ec6dbec7ff60f5]::queries::Linker>::link
  22:     0x7ff89e846bff - _wpgmptr
  23:     0x7ff89e841f4f - _wpgmptr
  24:     0x7ff89e84bd0b - _wpgmptr
  25:     0x7ff8c00b963d - alloc::boxed::impl$48::call_once
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\alloc\src\boxed.rs:2064
  26:     0x7ff8c00b963d - alloc::boxed::impl$48::call_once
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\alloc\src\boxed.rs:2064
  27:     0x7ff8c00b963d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/35b658fb1071d752d092751d9f17a9fa7b154ec4/library\std\src\sys\pal\windows\thread.rs:52
  28:     0x7ff902f67344 - BaseThreadInitThunk
  29:     0x7ff90387cc91 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `C:\Users\Fred\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cc-1.1.2\rustc-ice-2024-07-13T13_09_51-10436.txt` to your bug report

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C strip=debuginfo -C panic=abort -Z panic-abort-tests -Z codegen-backend=C:\clif\bin\rustc_codegen_cranelift.dll

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `cc` (lib)
warning: build failed, waiting for other jobs to finish...

src\archive.rs is not my file.

How to know what crate is causing this?

I'm on the latest rust, clif and windows dependencies as of today.

bjorn3 commented 3 months ago

Looks like the cc crate has started using raw-dylib on Windows: https://github.com/rust-lang/cc-rs/pull/1137 cg_clif doesn't know how to build import libraries yet, and as such raw-dylib doesn't work.

frederikhors commented 3 months ago

Oh crap. And now?

bjorn3 commented 3 months ago

https://github.com/rust-lang/ar_archive_writer/pull/15 is a port of LLVM's import library writer to rust allowing it to be used by cg_clif. It was opened a while ago, but I didn't get around to reviewing it until a week ago. It is currently waiting on the author of the PR.

bjorn3 commented 3 months ago

I've pushed a commit to get a regular fatal error rather than a panic when using raw-dylib.

frederikhors commented 3 months ago

Ok. In the meantime they maybe are reverting that change... https://github.com/rust-lang/cc-rs/issues/1156#issuecomment-2226916579

bjorn3 commented 3 months ago

raw-dylib has been implemented in https://github.com/rust-lang/rustc_codegen_cranelift/pull/1524.