Repository: rust
Issue: LLVM ERROR: Undefined temporary symbol when compiling wasm-bindgen-macro-support on powerpc64+powerpc64le linux
Labels: A-LLVM,T-compiler,O-PowerPC,C-bug

See log here https://buildd.debian.org/status/fetch.php?pkg=rust-wasm-bindgen-macro-support&arch=ppc64el&ver=0.2.33-1&stamp=1549258418&raw=0

The same issue is reproducible with the rustc binary from [here](https://static.rust-lang.org/dist/rust-1.32.0-powerpc64le-unknown-linux-gnu.tar.gz), but one needs to first work around #58334/#57345 by building your cargo, e.g. the Debian `cargo` package works.

Stack traces, but locals are optimised out:

Debian rustc
~~~~
$ cargo build --verbose --verbose
[..]
$ rust-gdb -q rustc
[..]
(gdb) break llvm::report_fatal_error
[..]
(gdb) run --crate-name wasm_bindgen_macro_support crates/macro-support/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="spans"' --cfg 'feature="wasm-bindgen-backend"' -C metadata=267ded4c6ac04022 -C extra-filename=-267ded4c6ac04022 --out-dir $HOME/wasm-bindgen/target/debug/deps -C incremental=$HOME/wasm-bindgen/target/debug/incremental -L dependency=$HOME/wasm-bindgen/target/debug/deps --extern proc_macro2=$HOME/wasm-bindgen/target/debug/deps/libproc_macro2-ddf6fe723d049424.rlib --extern quote=$HOME/wasm-bindgen/target/debug/deps/libquote-bd5442aa4aee0f1c.rlib --extern syn=$HOME/wasm-bindgen/target/debug/deps/libsyn-a5d8e6188798fcb2.rlib --extern wasm_bindgen_backend=$HOME/wasm-bindgen/target/debug/deps/libwasm_bindgen_backend-c8bf27854c4fe469.rlib --extern wasm_bindgen_shared=$HOME/wasm-bindgen/target/debug/deps/libwasm_bindgen_shared-216cd9cb4202c473.rlib
[..]
(gdb) bt
#0  __gthread_mutex_lock () at /usr/lib/gcc/powerpc64le-linux-gnu/8/../../../../include/powerpc64le-linux-gnu/c++/8/bits/gthr-default.h:747
#1  lock () at /usr/lib/gcc/powerpc64le-linux-gnu/8/../../../../include/c++/8/bits/std_mutex.h:103
#2  lock_guard () at /usr/lib/gcc/powerpc64le-linux-gnu/8/../../../../include/c++/8/bits/std_mutex.h:162
#3  report_fatal_error () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/Support/ErrorHandling.cpp:101
#4  0x00003fffb202973c in llvm::MCContext::reportError(llvm::SMLoc, llvm::Twine const&) () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/MCContext.cpp:628
#5  0x00003fffb20056a8 in computeSymbolTable () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/ELFObjectWriter.cpp:645
#6  writeObject () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/ELFObjectWriter.cpp:1151
#7  0x00003fffb171ed30 in ?? () from /usr/lib/powerpc64le-linux-gnu/libLLVM-7.so.1
#8  0x00003fffb201b9b4 in Finish () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/MCAssembler.cpp:849
#9  0x00003fffb204aef0 in FinishImpl () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/MCObjectStreamer.cpp:683
#10 0x00003fffb2039474 in FinishImpl () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/MCELFStreamer.cpp:674
#11 0x00003fffb20561c4 in Finish () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/MC/MCStreamer.cpp:863
#12 0x00003fffb1718324 in doFinalization () at /build/llvm-toolchain-7-4s73DP/llvm-toolchain-7-7.0.1/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1548
#13 0x0000000000000000 in ?? ()
~~~~

Upstream rustc
~~~~
$ export PATH=$HOME/vroot/usr/bin:$HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/bin:/usr/local/bin:/usr/bin:/bin
$ export LD_LIBRARY_PATH=$HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rust-std-powerpc64le-unknown-linux-gnu/lib/rustlib/powerpc64le-unknown-linux-gnu/lib
$ export RUSTFLAGS="-L $LD_LIBRARY_PATH"
$ export RUSTDOCFLAGS="-L $LD_LIBRARY_PATH"
$ which cargo
$HOME/vroot/usr/bin/cargo
$ which rustc
$HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/bin/rustc
$ cargo build --verbose --verbose
[..]
$ rust-gdb -q rustc
[..]
(gdb) break llvm::report_fatal_error
[..]
(gdb) run --crate-name wasm_bindgen_macro_support crates/macro-support/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="spans"' --cfg 'feature="wasm-bindgen-backend"' -C metadata=56e98bc84653fd36 -C extra-filename=-56e98bc84653fd36 --out-dir $HOME/wasm-bindgen/target/debug/deps -C incremental=$HOME/wasm-bindgen/target/debug/incremental -L dependency=$HOME/wasm-bindgen/target/debug/deps --extern proc_macro2=$HOME/wasm-bindgen/target/debug/deps/libproc_macro2-a9b42ce46045ad3d.rlib --extern quote=$HOME/wasm-bindgen/target/debug/deps/libquote-b533d9dc523383f1.rlib --extern syn=$HOME/wasm-bindgen/target/debug/deps/libsyn-73f28adcf440f43e.rlib --extern wasm_bindgen_backend=$HOME/wasm-bindgen/target/debug/deps/libwasm_bindgen_backend-0d6dbe292e1636ee.rlib --extern wasm_bindgen_shared=$HOME/wasm-bindgen/target/debug/deps/libwasm_bindgen_shared-7b78e47489df9616.rlib -L $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rust-std-powerpc64le-unknown-linux-gnu/lib/rustlib/powerpc64le-unknown-linux-gnu/lib
[..]
(gdb) bt
#0  0x00003fffb3ab339c in llvm::report_fatal_error(llvm::Twine const&, bool) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#1  0x00003fffb395f540 in llvm::MCContext::reportError(llvm::SMLoc, llvm::Twine const&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#2  0x00003fffb393488c in (anonymous namespace)::ELFWriter::computeSymbolTable(llvm::MCAssembler&, llvm::MCAsmLayout const&, llvm::DenseMap<llvm::MCSectionELF const*, unsigned int, llvm::DenseMapInfo<llvm::MCSectionELF const*>, llvm::detail::DenseMapPair<llvm::MCSectionELF const*, unsigned int> > const&, llvm::DenseMap<llvm::MCSymbol const*, unsigned int, llvm::DenseMapInfo<llvm::MCSymbol const*>, llvm::detail::DenseMapPair<llvm::MCSymbol const*, unsigned int> > const&, std::map<llvm::MCSectionELF const*, std::pair<unsigned long, unsigned long>, std::less<llvm::MCSectionELF const*>, std::allocator<std::pair<llvm::MCSectionELF const* const, std::pair<unsigned long, unsigned long> > > >&) () from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#3  0x00003fffb393695c in (anonymous namespace)::ELFWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) [clone .constprop.391] ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#4  0x00003fffb3938e30 in (anonymous namespace)::ELFSingleObjectWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#5  0x00003fffb3950fa8 in llvm::MCAssembler::Finish() () from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#6  0x00003fffb39852d0 in llvm::MCObjectStreamer::FinishImpl() ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#7  0x00003fffb3972e60 in llvm::MCELFStreamer::FinishImpl() () from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#8  0x00003fffb3993468 in llvm::MCStreamer::Finish() () from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#9  0x00003fffb29e4810 in llvm::AsmPrinter::doFinalization(llvm::Module&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#10 0x00003fffb1b5d774 in (anonymous namespace)::PPCLinuxAsmPrinter::doFinalization(llvm::Module&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#11 0x00003fffb379b188 in llvm::FPPassManager::doFinalization(llvm::Module&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#12 0x00003fffb37aa888 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#13 0x00003fffb37aab3c in llvm::legacy::PassManager::run(llvm::Module&) ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#14 0x00003fffb1710244 in LLVMRustWriteOutputFile () from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#15 0x00003fffb162baac in rustc_codegen_llvm::back::write::write_output_file ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#16 0x00003fffb162f638 in rustc_codegen_llvm::back::write::codegen::{{closure}} ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#17 0x00003fffb162e92c in rustc_codegen_llvm::back::write::codegen ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#18 0x00003fffb15e43a0 in rustc_codegen_ssa::back::write::execute_work_item ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#19 0x00003fffb16d0d9c in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#20 0x00003fffb15a2fd8 in std::panicking::try::do_call () from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#21 0x00003fffb7c62e84 in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:102
#22 0x00003fffb15ac188 in <F as alloc::boxed::FnBox<A>>::call_box ()
   from $HOME/rust-1.32.0-powerpc64le-unknown-linux-gnu/rustc/lib/rustlib/powerpc64le-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#23 0x00003fffb7c5787c in _$LT$alloc..boxed..Box$LT$$LP$dyn$u20$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$RP$$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::hcb2877104e64de51 () at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/liballoc/boxed.rs:683
#24 std::sys_common::thread::start_thread () at src/libstd/sys_common/thread.rs:24
#25 std::sys::unix::thread::Thread::new::thread_start () at src/libstd/sys/unix/thread.rs:90
#26 0x00003fffb4f28e04 in start_thread (arg=0x0) at pthread_create.c:486
#27 0x00003fffb7ad3cd8 in clone () at ../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:82
~~~~