Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw: panic when compiling rustc_llvm #97299

Closed
filnet opened this issue May 22, 2022 · 4 comments · Fixed by #97328
Closed

mingw: panic when compiling rustc_llvm #97299

filnet opened this issue May 22, 2022 · 4 comments · Fixed by #97328
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@filnet
Copy link

filnet commented May 22, 2022

Code

There is no code.
The internal compiler error happens when building rustc itself (on MSYS2/Mingw)

Meta

We are trying to build Rust 1.61.0.
The error happens when building rustc_llvm while processing the libs passed on the rustc command line.
The issue concerns native library modifiers and was most probably introduced by 1004783.
The line that triggers the panic is here: https://github.com/rust-lang/rust/blob/1.61.0/compiler/rustc_metadata/src/native_libs.rs#L384

The code change in question broke the handling of -bundle (i.e. no bundle) which is used when building on mingw.
See here for an example: https://github.com/rust-lang/rust/blob/1.61.0/compiler/rustc_llvm/build.rs#L369

Error output

 thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler\rustc_metadata\src\native_libs.rs:386:74
  stack backtrace:
     0:     0x7ff8d4902636 - std::backtrace_rs::backtrace::trace_unsynchronized::h3cb9fa0b4eb9649b
     1:     0x7ff8d49359b6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h65c026da46caf570
     2:     0x7ff8d49a1e2b - core::fmt::write::hfbd8b4ae8d1d8261
     3:     0x7ff8d492e0a3 - std::io::Write::write_fmt::h51a571397dfc95e2
     4:     0x7ff8d491c4f7 - std::panicking::default_hook::{{closure}}::h6239a46f99031682
     5:     0x7ff8d491c139 - std::panicking::default_hook::hcac462487509d5df
     6:     0x7ff8ac676636 - rustc_driver[ddc4f3ba51bdc44f]::DEFAULT_HOOK::{closure#0}::{closure#0}
     7:     0x7ff8d491ce53 - std::panicking::rust_panic_with_hook::h4e8678b6d74de03a
     8:     0x7ff8d4935db7 - std::panicking::begin_panic_handler::{{closure}}::hd1f47aae2c8008e1
     9:     0x7ff8d4935ae7 - std::sys_common::backtrace::__rust_end_short_backtrace::h2b2de33c83651502
    10:     0x7ff8d491c992 - rust_begin_unwind
    11:     0x7ff8d49a5ff5 - core::panicking::panic_fmt::he9ec58019eef6ddb
    12:     0x7ff8d49a5e3c - core::panicking::panic::h456a135f33f4e076
    13:     0x7ff8ae354939 - <alloc[724c5fba744dfcfc]::vec::drain_filter::DrainFilter<rustc_session[70f13f7fb85729a0]::cstore::NativeLib, <rustc_metadata[c75917afec703090]::native_libs::Collector>::process_command_line::{closure#2}> as core[b46926f3a58ba61]::iter::traits::iterator::Iterator>::next
    14:     0x7ff8ae3f00ab - <alloc[724c5fba744dfcfc]::vec::Vec<rustc_session[70f13f7fb85729a0]::cstore::NativeLib> as alloc[724c5fba744dfcfc]::vec::spec_from_iter::SpecFromIter<rustc_session[70f13f7fb85729a0]::cstore::NativeLib, alloc[724c5fba744dfcfc]::vec::drain_filter::DrainFilter<rustc_session[70f13f7fb85729a0]::cstore::NativeLib, <rustc_metadata[c75917afec703090]::native_libs::Collector>::process_command_line::{closure#2}>>>::from_iter
    15:     0x7ff8ae43cfee - rustc_metadata[c75917afec703090]::native_libs::collect
    16:     0x7ff8ae412f17 - <rustc_metadata[c75917afec703090]::rmeta::decoder::cstore_impl::provide::{closure#5} as core[b46926f3a58ba61]::ops::function::FnOnce<(rustc_middle[eaeac80584ece6a4]::ty::context::TyCtxt, rustc_span[f371218bcd00efc5]::def_id::CrateNum)>>::call_once
    17:     0x7ff8adac1613 - rustc_query_system[440b8cd36ab51988]::query::plumbing::try_execute_query::<rustc_query_impl[428a825d9a5ae547]::plumbing::QueryCtxt, rustc_query_system[440b8cd36ab51988]::query::caches::ArenaCache<rustc_span[f371218bcd00efc5]::def_id::CrateNum, alloc[724c5fba744dfcfc]::vec::Vec<rustc_session[70f13f7fb85729a0]::cstore::NativeLib>>>
    18:     0x7ff8adbfafb5 - rustc_query_system[440b8cd36ab51988]::query::plumbing::get_query::<rustc_query_impl[428a825d9a5ae547]::queries::native_libraries, rustc_query_impl[428a825d9a5ae547]::plumbing::QueryCtxt>
    19:     0x7ff8ae2feb0f - <rustc_metadata[c75917afec703090]::rmeta::encoder::EncodeContext>::encode_crate_root
    20:     0x7ff8ae313d4d - rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata_impl
    21:     0x7ff8ae40ee39 - rustc_data_structures[c2a2b29f8eb69237]::sync::join::<rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata::{closure#1}, rustc_metadata[c75917afec703090]::rmeta::encoder::EncodedMetadata, ()>
    22:     0x7ff8ae31335b - rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata
    23:     0x7ff8ac789cc0 - <rustc_interface[34867592904978ed]::passes::QueryContext>::enter::<<rustc_interface[34867592904978ed]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[b46926f3a58ba61]::result::Result<alloc[724c5fba744dfcfc]::boxed::Box<dyn core[b46926f3a58ba61]::any::Any>, rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    24:     0x7ff8ac83b421 - <rustc_interface[34867592904978ed]::queries::Queries>::ongoing_codegen
    25:     0x7ff8ac6aaa04 - <rustc_interface[34867592904978ed]::interface::Compiler>::enter::<rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}::{closure#2}, core[b46926f3a58ba61]::result::Result<core[b46926f3a58ba61]::option::Option<rustc_interface[34867592904978ed]::queries::Linker>, rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    26:     0x7ff8ac632119 - rustc_span[f371218bcd00efc5]::with_source_map::<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_interface[34867592904978ed]::interface::create_compiler_and_run<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#1}>
    27:     0x7ff8ac6a98f0 - rustc_interface[34867592904978ed]::interface::create_compiler_and_run::<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>
    28:     0x7ff8ac62eee0 - <scoped_tls[5f0ff43c88f47810]::ScopedKey<rustc_span[f371218bcd00efc5]::SessionGlobals>>::set::<rustc_interface[34867592904978ed]::interface::run_compiler<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    29:     0x7ff8ac6904a6 - std[eb09d43dfca15b52]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[34867592904978ed]::util::run_in_thread_pool_with_globals<rustc_interface[34867592904978ed]::interface::run_compiler<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    30:     0x7ff8ac635bd7 - <<std[eb09d43dfca15b52]::thread::Builder>::spawn_unchecked_<rustc_interface[34867592904978ed]::util::run_in_thread_pool_with_globals<rustc_interface[34867592904978ed]::interface::run_compiler<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>::{closure#1} as core[b46926f3a58ba61]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
    31:     0x7ff8d4936ad7 - std::sys::windows::thread::Thread::new::thread_start::h5ae94f48bf461847
    32:     0x7ff8eb8c4ed0 - <unknown>
    33:     0x7ff8ecf2e39b - <unknown>
  
  error: internal compiler error: unexpected panic
  
  note: 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: rustc 1.61.0 running on x86_64-pc-windows-gnu
  
  note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C linker=gcc -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -Z tls-model=initial-exec -Z unstable-options -C prefer-dynamic -Z binary-dep-depinfo -Z force-unstable-if-unmarked
  
  note: some of the compiler flags provided by cargo are hidden
  
  Did not run successfully: exit code: 0x80000003
  
  "C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1\\bin\\rustc.exe" "--crate-name" "rustc_llvm" "--edition=2021" "compiler\\rustc_llvm\\src\\lib.rs" "--error-format=json" "--json=diagnostic-rendered-ansi,artifacts,future-incompat" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=3" "-C" "embed-bitcode=no" "-C" "debuginfo=0" "-C" "metadata=faaaa3f518e5040d" "-C" "extra-filename=-faaaa3f518e5040d" "--out-dir" "C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1-rustc\\x86_64-pc-windows-gnu\\release\\deps" "--target" "x86_64-pc-windows-gnu" "-C" "linker=gcc" "-L" "dependency=C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1-rustc\\x86_64-pc-windows-gnu\\release\\deps" "-L" "dependency=C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1-rustc\\release\\deps" "--extern" "libc=C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1-rustc\\x86_64-pc-windows-gnu\\release\\deps\\liblibc-67302588d96e19e1.rmeta" "-Csymbol-mangling-version=v0" "-Zunstable-options" "--check-cfg=names()" "--check-cfg=values()" "--check-cfg=values(bootstrap)" "--check-cfg=values(parallel_compiler)" "--check-cfg=values(no_btreemap_remove_entry)" "--check-cfg=values(crossbeam_loom)" "--check-cfg=values(span_locations)" "-Zmacro-backtrace" "-Ztls-model=initial-exec" "-Zunstable-options" "-Wrustc::internal" "-Cprefer-dynamic" "-Z" "binary-dep-depinfo" "-L" "native=C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1-rustc\\x86_64-pc-windows-gnu\\release\\build\\rustc_llvm-bcb4b05243305d50\\out" "-L" "native=D:/M/msys64/mingw64/lib" "-L" "native=D:/M/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../lib" "--cfg" "llvm_component=\"aarch64\"" "--cfg" "llvm_component=\"amdgpu\"" "--cfg" "llvm_component=\"arm\"" "--cfg" "llvm_component=\"asmparser\"" "--cfg" "llvm_component=\"avr\"" "--cfg" "llvm_component=\"bitreader\"" "--cfg" "llvm_component=\"bitwriter\"" "--cfg" "llvm_component=\"bpf\"" "--cfg" "llvm_component=\"coverage\"" "--cfg" "llvm_component=\"instrumentation\"" "--cfg" "llvm_component=\"ipo\"" "--cfg" "llvm_component=\"linker\"" "--cfg" "llvm_component=\"lto\"" "--cfg" "llvm_component=\"mips\"" "--cfg" "llvm_component=\"msp430\"" "--cfg" "llvm_component=\"nvptx\"" "--cfg" "llvm_component=\"riscv\"" "--cfg" "llvm_component=\"webassembly\"" "--cfg" "llvm_component=\"x86\"" "-l" "static=llvm-wrapper" "-l" "static=LLVMX86TargetMCA" "-l" "static=LLVMX86Disassembler" "-l" "static=LLVMX86AsmParser" "-l" "static=LLVMX86CodeGen" "-l" "static=LLVMX86Desc" "-l" "static=LLVMX86Info" "-l" "static=LLVMWebAssemblyDisassembler" "-l" "static=LLVMWebAssemblyAsmParser" "-l" "static=LLVMWebAssemblyCodeGen" "-l" "static=LLVMWebAssemblyDesc" "-l" "static=LLVMWebAssemblyUtils" "-l" "static=LLVMWebAssemblyInfo" "-l" "static=LLVMRISCVDisassembler" "-l" "static=LLVMRISCVAsmParser" "-l" "static=LLVMRISCVCodeGen" "-l" "static=LLVMRISCVDesc" "-l" "static=LLVMRISCVInfo" "-l" "static=LLVMNVPTXCodeGen" "-l" "static=LLVMNVPTXDesc" "-l" "static=LLVMNVPTXInfo" "-l" "static=LLVMMSP430Disassembler" "-l" "static=LLVMMSP430AsmParser" "-l" "static=LLVMMSP430CodeGen" "-l" "static=LLVMMSP430Desc" "-l" "static=LLVMMSP430Info" "-l" "static=LLVMMipsDisassembler" "-l" "static=LLVMMipsAsmParser" "-l" "static=LLVMMipsCodeGen" "-l" "static=LLVMMipsDesc" "-l" "static=LLVMMipsInfo" "-l" "static=LLVMLTO" "-l" "static=LLVMExtensions" "-l" "static=LLVMCoverage" "-l" "static=LLVMBPFDisassembler" "-l" "static=LLVMBPFAsmParser" "-l" "static=LLVMBPFCodeGen" "-l" "static=LLVMBPFDesc" "-l" "static=LLVMBPFInfo" "-l" "static=LLVMAVRDisassembler" "-l" "static=LLVMAVRAsmParser" "-l" "static=LLVMAVRCodeGen" "-l" "static=LLVMAVRDesc" "-l" "static=LLVMAVRInfo" "-l" "static=LLVMARMDisassembler" "-l" "static=LLVMARMAsmParser" "-l" "static=LLVMARMCodeGen" "-l" "static=LLVMARMDesc" "-l" "static=LLVMARMUtils" "-l" "static=LLVMARMInfo" "-l" "static=LLVMAMDGPUTargetMCA" "-l" "static=LLVMMCA" "-l" "static=LLVMAMDGPUDisassembler" "-l" "static=LLVMAMDGPUAsmParser" "-l" "static=LLVMAMDGPUCodeGen" "-l" "static=LLVMMIRParser" "-l" "static=LLVMAMDGPUDesc" "-l" "static=LLVMAMDGPUUtils" "-l" "static=LLVMAMDGPUInfo" "-l" "static=LLVMPasses" "-l" "static=LLVMObjCARCOpts" "-l" "static=LLVMCoroutines" "-l" "static=LLVMipo" "-l" "static=LLVMInstrumentation" "-l" "static=LLVMVectorize" "-l" "static=LLVMLinker" "-l" "static=LLVMIRReader" "-l" "static=LLVMAsmParser" "-l" "static=LLVMFrontendOpenMP" "-l" "static=LLVMAArch64Disassembler" "-l" "static=LLVMMCDisassembler" "-l" "static=LLVMAArch64AsmParser" "-l" "static=LLVMAArch64CodeGen" "-l" "static=LLVMCFGuard" "-l" "static=LLVMGlobalISel" "-l" "static=LLVMSelectionDAG" "-l" "static=LLVMAsmPrinter" "-l" "static=LLVMDebugInfoMSF" "-l" "static=LLVMCodeGen" "-l" "static=LLVMTarget" "-l" "static=LLVMScalarOpts" "-l" "static=LLVMInstCombine" "-l" "static=LLVMAggressiveInstCombine" "-l" "static=LLVMTransformUtils" "-l" "static=LLVMBitWriter" "-l" "static=LLVMAnalysis" "-l" "static=LLVMProfileData" "-l" "static=LLVMDebugInfoDWARF" "-l" "static=LLVMObject" "-l" "static=LLVMTextAPI" "-l" "static=LLVMMCParser" "-l" "static=LLVMBitReader" "-l" "static=LLVMCore" "-l" "static=LLVMRemarks" "-l" "static=LLVMBitstreamReader" "-l" "static=LLVMAArch64Desc" "-l" "static=LLVMAArch64Utils" "-l" "static=LLVMAArch64Info" "-l" "static=LLVMMC" "-l" "static=LLVMDebugInfoCodeView" "-l" "static=LLVMBinaryFormat" "-l" "static=LLVMSupport" "-l" "static=LLVMDemangle" "-l" "dylib=psapi" "-l" "dylib=shell32" "-l" "dylib=ole32" "-l" "dylib=uuid" "-l" "dylib=advapi32" "-l" "dylib=pthread" "-l" "dylib=z" "-l" "dylib=xml2" "-l" "static:-bundle=stdc++" "-l" "static:-bundle=ffi" "-l" "static:-bundle=pthread" "-Wrust_2018_idioms" "-Wunused_lifetimes" "-Wsemicolon_in_expressions_from_macros" "-Dwarnings" "--sysroot" "C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage1" "-Z" "force-unstable-if-unmarked"
  -------------
  query stack during panic:
  #0 [native_libraries] looking up the native libraries of a linked crate
  end of query stack
  error: could not compile `rustc_llvm`
  
  Caused by:
    process didn't exit successfully: `C:\_\mingw-w64-rust\src\MINGW64\build\bootstrap\debug\rustc --crate-name rustc_llvm --edition=2021 'compiler\rustc_llvm\src\lib.rs' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C metadata=faaaa3f518e5040d -C extra-filename=-faaaa3f518e5040d --out-dir 'C:\_\mingw-w64-rust\src\MINGW64\build\x86_64-pc-windows-gnu\stage1-rustc\x86_64-pc-windows-gnu\release\deps' --target x86_64-pc-windows-gnu -C linker=gcc -L 'dependency=C:\_\mingw-w64-rust\src\MINGW64\build\x86_64-pc-windows-gnu\stage1-rustc\x86_64-pc-windows-gnu\release\deps' -L 'dependency=C:\_\mingw-w64-rust\src\MINGW64\build\x86_64-pc-windows-gnu\stage1-rustc\release\deps' --extern 'libc=C:\_\mingw-w64-rust\src\MINGW64\build\x86_64-pc-windows-gnu\stage1-rustc\x86_64-pc-windows-gnu\release\deps\liblibc-67302588d96e19e1.rmeta' -Csymbol-mangling-version=v0 -Zunstable-options '--check-cfg=names()' '--check-cfg=values()' '--check-cfg=values(bootstrap)' '--check-cfg=values(parallel_compiler)' '--check-cfg=values(no_btreemap_remove_entry)' '--check-cfg=values(crossbeam_loom)' '--check-cfg=values(span_locations)' -Zmacro-backtrace -Ztls-model=initial-exec -Zunstable-options '-Wrustc::internal' -Cprefer-dynamic -Z binary-dep-depinfo -L 'native=C:\_\mingw-w64-rust\src\MINGW64\build\x86_64-pc-windows-gnu\stage1-rustc\x86_64-pc-windows-gnu\release\build\rustc_llvm-bcb4b05243305d50\out' -L 'native=D:/M/msys64/mingw64/lib' -L 'native=D:/M/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../lib' --cfg 'llvm_component="aarch64"' --cfg 'llvm_component="amdgpu"' --cfg 'llvm_component="arm"' --cfg 'llvm_component="asmparser"' --cfg 'llvm_component="avr"' --cfg 'llvm_component="bitreader"' --cfg 'llvm_component="bitwriter"' --cfg 'llvm_component="bpf"' --cfg 'llvm_component="coverage"' --cfg 'llvm_component="instrumentation"' --cfg 'llvm_component="ipo"' --cfg 'llvm_component="linker"' --cfg 'llvm_component="lto"' --cfg 'llvm_component="mips"' --cfg 'llvm_component="msp430"' --cfg 'llvm_component="nvptx"' --cfg 'llvm_component="riscv"' --cfg 'llvm_component="webassembly"' --cfg 'llvm_component="x86"' -l static=llvm-wrapper -l static=LLVMX86TargetMCA -l static=LLVMX86Disassembler -l static=LLVMX86AsmParser -l static=LLVMX86CodeGen -l static=LLVMX86Desc -l static=LLVMX86Info -l static=LLVMWebAssemblyDisassembler -l static=LLVMWebAssemblyAsmParser -l static=LLVMWebAssemblyCodeGen -l static=LLVMWebAssemblyDesc -l static=LLVMWebAssemblyUtils -l static=LLVMWebAssemblyInfo -l static=LLVMRISCVDisassembler -l static=LLVMRISCVAsmParser -l static=LLVMRISCVCodeGen -l static=LLVMRISCVDesc -l static=LLVMRISCVInfo -l static=LLVMNVPTXCodeGen -l static=LLVMNVPTXDesc -l static=LLVMNVPTXInfo -l static=LLVMMSP430Disassembler -l static=LLVMMSP430AsmParser -l static=LLVMMSP430CodeGen -l static=LLVMMSP430Desc -l static=LLVMMSP430Info -l static=LLVMMipsDisassembler -l static=LLVMMipsAsmParser -l static=LLVMMipsCodeGen -l static=LLVMMipsDesc -l static=LLVMMipsInfo -l static=LLVMLTO -l static=LLVMExtensions -l static=LLVMCoverage -l static=LLVMBPFDisassembler -l static=LLVMBPFAsmParser -l static=LLVMBPFCodeGen -l static=LLVMBPFDesc -l static=LLVMBPFInfo -l static=LLVMAVRDisassembler -l static=LLVMAVRAsmParser -l static=LLVMAVRCodeGen -l static=LLVMAVRDesc -l static=LLVMAVRInfo -l static=LLVMARMDisassembler -l static=LLVMARMAsmParser -l static=LLVMARMCodeGen -l static=LLVMARMDesc -l static=LLVMARMUtils -l static=LLVMARMInfo -l static=LLVMAMDGPUTargetMCA -l static=LLVMMCA -l static=LLVMAMDGPUDisassembler -l static=LLVMAMDGPUAsmParser -l static=LLVMAMDGPUCodeGen -l static=LLVMMIRParser -l static=LLVMAMDGPUDesc -l static=LLVMAMDGPUUtils -l static=LLVMAMDGPUInfo -l static=LLVMPasses -l static=LLVMObjCARCOpts -l static=LLVMCoroutines -l static=LLVMipo -l static=LLVMInstrumentation -l static=LLVMVectorize -l static=LLVMLinker -l static=LLVMIRReader -l static=LLVMAsmParser -l static=LLVMFrontendOpenMP -l static=LLVMAArch64Disassembler -l static=LLVMMCDisassembler -l static=LLVMAArch64AsmParser -l static=LLVMAArch64CodeGen -l static=LLVMCFGuard -l static=LLVMGlobalISel -l static=LLVMSelectionDAG -l static=LLVMAsmPrinter -l static=LLVMDebugInfoMSF -l static=LLVMCodeGen -l static=LLVMTarget -l static=LLVMScalarOpts -l static=LLVMInstCombine -l static=LLVMAggressiveInstCombine -l static=LLVMTransformUtils -l static=LLVMBitWriter -l static=LLVMAnalysis -l static=LLVMProfileData -l static=LLVMDebugInfoDWARF -l static=LLVMObject -l static=LLVMTextAPI -l static=LLVMMCParser -l static=LLVMBitReader -l static=LLVMCore -l static=LLVMRemarks -l static=LLVMBitstreamReader -l static=LLVMAArch64Desc -l static=LLVMAArch64Utils -l static=LLVMAArch64Info -l static=LLVMMC -l static=LLVMDebugInfoCodeView -l static=LLVMBinaryFormat -l static=LLVMSupport -l static=LLVMDemangle -l dylib=psapi -l dylib=shell32 -l dylib=ole32 -l dylib=uuid -l dylib=advapi32 -l dylib=pthread -l dylib=z -l dylib=xml2 -l 'static:-bundle=stdc++' -l 'static:-bundle=ffi' -l 'static:-bundle=pthread'` (exit code: 0x80000003)
  warning: build failed, waiting for other jobs to finish...
  error: build failed
  command did not execute successfully: "\\\\?\\C:\\_\\mingw-w64-rust\\src\\MINGW64\\build\\x86_64-pc-windows-gnu\\stage0\\bin\\cargo.exe" "build" "--target" "x86_64-pc-windows-gnu" "-Zbinary-dep-depinfo" "-j" "2" "-v" "--release" "--color" "always" "--features" "llvm max_level_info" "--manifest-path" "C:\\_\\mingw-w64-rust\\src\\rustc-1.61.0-src\\compiler/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
  expected success, got: exit code: 101
  Traceback (most recent call last):
    File "C:\_\mingw-w64-rust\src\rustc-1.61.0-src\x.py", line 27, in <module>
      bootstrap.main()
    File "C:/_/mingw-w64-rust/src/rustc-1.61.0-src/src/bootstrap/bootstrap.py", line 1324, in main
      bootstrap(help_triggered)
    File "C:/_/mingw-w64-rust/src/rustc-1.61.0-src/src/bootstrap/bootstrap.py", line 1310, in bootstrap
      run(args, env=env, verbose=build.verbose, is_bootstrap=True)
    File "C:/_/mingw-w64-rust/src/rustc-1.61.0-src/src/bootstrap/bootstrap.py", line 185, in run
      raise RuntimeError(err)
  RuntimeError: failed to run: C:/_/mingw-w64-rust/src/MINGW64/build/bootstrap/debug/bootstrap build --verbose --stage 2
  ==> ERROR: A failure occurred in build().
      Aborting...
  ==> Removing installed dependencies...
  checking dependencies...
Backtrace

 thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler\rustc_metadata\src\native_libs.rs:386:74
  stack backtrace:
     0:     0x7ff8d4902636 - std::backtrace_rs::backtrace::trace_unsynchronized::h3cb9fa0b4eb9649b
     1:     0x7ff8d49359b6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h65c026da46caf570
     2:     0x7ff8d49a1e2b - core::fmt::write::hfbd8b4ae8d1d8261
     3:     0x7ff8d492e0a3 - std::io::Write::write_fmt::h51a571397dfc95e2
     4:     0x7ff8d491c4f7 - std::panicking::default_hook::{{closure}}::h6239a46f99031682
     5:     0x7ff8d491c139 - std::panicking::default_hook::hcac462487509d5df
     6:     0x7ff8ac676636 - rustc_driver[ddc4f3ba51bdc44f]::DEFAULT_HOOK::{closure#0}::{closure#0}
     7:     0x7ff8d491ce53 - std::panicking::rust_panic_with_hook::h4e8678b6d74de03a
     8:     0x7ff8d4935db7 - std::panicking::begin_panic_handler::{{closure}}::hd1f47aae2c8008e1
     9:     0x7ff8d4935ae7 - std::sys_common::backtrace::__rust_end_short_backtrace::h2b2de33c83651502
    10:     0x7ff8d491c992 - rust_begin_unwind
    11:     0x7ff8d49a5ff5 - core::panicking::panic_fmt::he9ec58019eef6ddb
    12:     0x7ff8d49a5e3c - core::panicking::panic::h456a135f33f4e076
    13:     0x7ff8ae354939 - <alloc[724c5fba744dfcfc]::vec::drain_filter::DrainFilter<rustc_session[70f13f7fb85729a0]::cstore::NativeLib, <rustc_metadata[c75917afec703090]::native_libs::Collector>::process_command_line::{closure#2}> as core[b46926f3a58ba61]::iter::traits::iterator::Iterator>::next
    14:     0x7ff8ae3f00ab - <alloc[724c5fba744dfcfc]::vec::Vec<rustc_session[70f13f7fb85729a0]::cstore::NativeLib> as alloc[724c5fba744dfcfc]::vec::spec_from_iter::SpecFromIter<rustc_session[70f13f7fb85729a0]::cstore::NativeLib, alloc[724c5fba744dfcfc]::vec::drain_filter::DrainFilter<rustc_session[70f13f7fb85729a0]::cstore::NativeLib, <rustc_metadata[c75917afec703090]::native_libs::Collector>::process_command_line::{closure#2}>>>::from_iter
    15:     0x7ff8ae43cfee - rustc_metadata[c75917afec703090]::native_libs::collect
    16:     0x7ff8ae412f17 - <rustc_metadata[c75917afec703090]::rmeta::decoder::cstore_impl::provide::{closure#5} as core[b46926f3a58ba61]::ops::function::FnOnce<(rustc_middle[eaeac80584ece6a4]::ty::context::TyCtxt, rustc_span[f371218bcd00efc5]::def_id::CrateNum)>>::call_once
    17:     0x7ff8adac1613 - rustc_query_system[440b8cd36ab51988]::query::plumbing::try_execute_query::<rustc_query_impl[428a825d9a5ae547]::plumbing::QueryCtxt, rustc_query_system[440b8cd36ab51988]::query::caches::ArenaCache<rustc_span[f371218bcd00efc5]::def_id::CrateNum, alloc[724c5fba744dfcfc]::vec::Vec<rustc_session[70f13f7fb85729a0]::cstore::NativeLib>>>
    18:     0x7ff8adbfafb5 - rustc_query_system[440b8cd36ab51988]::query::plumbing::get_query::<rustc_query_impl[428a825d9a5ae547]::queries::native_libraries, rustc_query_impl[428a825d9a5ae547]::plumbing::QueryCtxt>
    19:     0x7ff8ae2feb0f - <rustc_metadata[c75917afec703090]::rmeta::encoder::EncodeContext>::encode_crate_root
    20:     0x7ff8ae313d4d - rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata_impl
    21:     0x7ff8ae40ee39 - rustc_data_structures[c2a2b29f8eb69237]::sync::join::<rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata::{closure#1}, rustc_metadata[c75917afec703090]::rmeta::encoder::EncodedMetadata, ()>
    22:     0x7ff8ae31335b - rustc_metadata[c75917afec703090]::rmeta::encoder::encode_metadata
    23:     0x7ff8ac789cc0 - <rustc_interface[34867592904978ed]::passes::QueryContext>::enter::<<rustc_interface[34867592904978ed]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[b46926f3a58ba61]::result::Result<alloc[724c5fba744dfcfc]::boxed::Box<dyn core[b46926f3a58ba61]::any::Any>, rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    24:     0x7ff8ac83b421 - <rustc_interface[34867592904978ed]::queries::Queries>::ongoing_codegen
    25:     0x7ff8ac6aaa04 - <rustc_interface[34867592904978ed]::interface::Compiler>::enter::<rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}::{closure#2}, core[b46926f3a58ba61]::result::Result<core[b46926f3a58ba61]::option::Option<rustc_interface[34867592904978ed]::queries::Linker>, rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    26:     0x7ff8ac632119 - rustc_span[f371218bcd00efc5]::with_source_map::<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_interface[34867592904978ed]::interface::create_compiler_and_run<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#1}>
    27:     0x7ff8ac6a98f0 - rustc_interface[34867592904978ed]::interface::create_compiler_and_run::<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>
    28:     0x7ff8ac62eee0 - <scoped_tls[5f0ff43c88f47810]::ScopedKey<rustc_span[f371218bcd00efc5]::SessionGlobals>>::set::<rustc_interface[34867592904978ed]::interface::run_compiler<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    29:     0x7ff8ac6904a6 - std[eb09d43dfca15b52]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[34867592904978ed]::util::run_in_thread_pool_with_globals<rustc_interface[34867592904978ed]::interface::run_compiler<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>
    30:     0x7ff8ac635bd7 - <<std[eb09d43dfca15b52]::thread::Builder>::spawn_unchecked_<rustc_interface[34867592904978ed]::util::run_in_thread_pool_with_globals<rustc_interface[34867592904978ed]::interface::run_compiler<core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>, rustc_driver[ddc4f3ba51bdc44f]::run_compiler::{closure#1}>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>::{closure#0}, core[b46926f3a58ba61]::result::Result<(), rustc_errors[be9326e5c57961e0]::ErrorGuaranteed>>::{closure#1} as core[b46926f3a58ba61]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
    31:     0x7ff8d4936ad7 - std::sys::windows::thread::Thread::new::thread_start::h5ae94f48bf461847
    32:     0x7ff8eb8c4ed0 - <unknown>
    33:     0x7ff8ecf2e39b - <unknown>
  
  error: internal compiler error: unexpected panic
  
  note: 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: rustc 1.61.0 running on x86_64-pc-windows-gnu
  
  note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C linker=gcc -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -Z tls-model=initial-exec -Z unstable-options -C prefer-dynamic -Z binary-dep-depinfo -Z force-unstable-if-unmarked
  
  note: some of the compiler flags provided by cargo are hidden
  
  Did not run successfully: exit code: 0x80000003

@filnet filnet added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2022
@filnet
Copy link
Author

filnet commented May 22, 2022

Note that we have -l dylib=pthread -l 'static:-bundle=pthread' on the rustc command line.
So we have the same lib twice and one has modifiers which triggers the error.
It should actually trigger an overriding linking modifiers from command line is not supported error but panics before...

@petrochenkov
Copy link
Contributor

Yes, the ICE is caused by unwrap() used to determine the span for the error.
There's a PR in progress that fixes that - #94962.

Even without ICE you'll need a workaround for the error that it's masking - linking the library with modifiers either only from command line, or only from #[link] attributes.
#94962 will relax these restrictions as well.

@petrochenkov
Copy link
Contributor

The ICE is a regression from #93901.

@petrochenkov petrochenkov added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label May 23, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 23, 2022
@petrochenkov petrochenkov self-assigned this May 23, 2022
@petrochenkov
Copy link
Contributor

Fixed in #97328.

@bors bors closed this as completed in 0067078 May 25, 2022
@inquisitivecrystal inquisitivecrystal added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 25, 2022
filnet added a commit to filnet/MINGW-packages that referenced this issue May 26, 2022
Fixes a number of issues in compiler/rustc_llvm regarding lib handling.
This is a moving part in current rust releases...

- Disabled llvm-static-stdcpp
Fixes CLANG64 build error:
    thread 'main' panicked at 'assertion failed: !cxxflags.contains(\"stdlib=libc++\")', compiler\rustc_llvm\build.rs:351:13
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

- Removed `pthread` from forced libs in compiler/rustc_llvm/build.rs
`pthread` is also provided by llvm-config and having both now triggers an error about mixed link modifiers.
See rust-lang/rust#97299

    $ llvm-config --system-libs --link-static
    -lpsapi -lshell32 -lole32 -luuid -ladvapi32 -lpthread -lz -lxml2

Note that `ffi` is still forced by the patch as llvm-config does not provide it.
See 0001-rustc-llvm-fix-libs.patch (replaces 0001-add-missing-libs.patch).

- Rebased 0007-clang-subsystem.patch

quick and dirty test
filnet added a commit to filnet/MINGW-packages that referenced this issue May 26, 2022
Fixes a number of issues in compiler/rustc_llvm regarding lib handling.
This is a moving part in current rust releases...

- Disabled llvm-static-stdcpp
Fixes CLANG64 build error:
    thread 'main' panicked at 'assertion failed: !cxxflags.contains(\"stdlib=libc++\")', compiler\rustc_llvm\build.rs:351:13
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

- Removed `pthread` from forced libs in compiler/rustc_llvm/build.rs
`pthread` is also provided by llvm-config and having both now triggers an error about mixed link modifiers.
See rust-lang/rust#97299

    $ llvm-config --system-libs --link-static
    -lpsapi -lshell32 -lole32 -luuid -ladvapi32 -lpthread -lz -lxml2

Note that `ffi` is still forced by the patch as llvm-config does not provide it.
See 0001-rustc-llvm-fix-libs.patch (replaces 0001-add-missing-libs.patch).

- Rebased 0007-clang-subsystem.patch
ehuss pushed a commit to ehuss/rust that referenced this issue Jun 1, 2022
…rister

rustc: Fix ICE in native library error reporting

Fixes rust-lang#97299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants