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

1.17.0 powerpc64le: "LLVM ERROR: Undefined temporary symbol" after disabling optimisation #42476

Open
infinity0 opened this issue Jun 6, 2017 · 10 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-PowerPC Target: PowerPC processors T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@infinity0
Copy link
Contributor

Build log: https://buildd.debian.org/status/fetch.php?pkg=rustc&arch=ppc64el&ver=1.17.0%2Bdfsg2-1&stamp=1495038619&raw=0 - but it also happens when I try to cross-compile from amd64 to ppc64el.

   Compiling rustc v0.0.0 (file:///<<BUILDDIR>>/rustc-1.17.0+dfsg2/src/librustc)
     Running `/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/bootstrap/debug/rustc --crate-name rustc src/librustc/lib.rs --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C debug-assertions=off -C metadata=2dbabbd65e8c1fb6 -C extra-filename=-2dbabbd65e8c1fb6 --out-dir '/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps' --target powerpc64le-unknown-linux-gnu -L 'dependency=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps' -L 'dependency=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/debug/deps' --extern 'fmt_macros=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libfmt_macros-0ae3a1110c5d6a59.so' --extern 'graphviz=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libgraphviz-69f251278e17c653.so' --extern 'log=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/liblog-2d7ede29ab054d41.so' --extern 'log=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/liblog-2d7ede29ab054d41.rlib' --extern 'syntax=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libsyntax-ee039db76fa2c9bd.so' --extern 'rustc_back=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_back-d3da270de1cf5da2.so' --extern 'rustc_data_structures=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_data_structures-e81620800e45ed83.so' --extern 'syntax_pos=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libsyntax_pos-64299e60f35ddd83.so' --extern 'rustc_errors=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_errors-6033144335693d9c.so' --extern 'arena=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libarena-b26c5a582e48af8e.so' --extern 'serialize=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libserialize-2a05f301b8174a1d.so' --extern 'serialize=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libserialize-2a05f301b8174a1d.rlib' --extern 'rustc_llvm=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_llvm-ad254c719b9de2ea.so' --extern 'rustc_const_math=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_const_math-3ce64b122f5b797c.so' --extern 'rustc_bitflags=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_bitflags-af221885a3a0a71c.rlib' -C link-args=-Wl,-z,relro -L 'native=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/build/rustc_llvm-345e2146446b30f9/out' -L native=/usr/lib/llvm-3.9/lib`
LLVM ERROR: Undefined temporary symbol
error: Could not compile `rustc`.

Caused by:
  process didn't exit successfully: `/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/bootstrap/debug/rustc --crate-name rustc src/librustc/lib.rs --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C debug-assertions=off -C metadata=2dbabbd65e8c1fb6 -C extra-filename=-2dbabbd65e8c1fb6 --out-dir /<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps --target powerpc64le-unknown-linux-gnu -L dependency=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps -L dependency=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/debug/deps --extern fmt_macros=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libfmt_macros-0ae3a1110c5d6a59.so --extern graphviz=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libgraphviz-69f251278e17c653.so --extern log=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/liblog-2d7ede29ab054d41.so --extern log=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/liblog-2d7ede29ab054d41.rlib --extern syntax=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libsyntax-ee039db76fa2c9bd.so --extern rustc_back=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_back-d3da270de1cf5da2.so --extern rustc_data_structures=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_data_structures-e81620800e45ed83.so --extern syntax_pos=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libsyntax_pos-64299e60f35ddd83.so --extern rustc_errors=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_errors-6033144335693d9c.so --extern arena=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libarena-b26c5a582e48af8e.so --extern serialize=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libserialize-2a05f301b8174a1d.so --extern serialize=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libserialize-2a05f301b8174a1d.rlib --extern rustc_llvm=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_llvm-ad254c719b9de2ea.so --extern rustc_const_math=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_const_math-3ce64b122f5b797c.so --extern rustc_bitflags=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_bitflags-af221885a3a0a71c.rlib -C link-args=-Wl,-z,relro -L native=/<<BUILDDIR>>/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/build/rustc_llvm-345e2146446b30f9/out -L native=/usr/lib/llvm-3.9/lib` (exit code: 1)


command did not execute successfully: "/usr/bin/cargo" "build" "-j" "4" "--target" "powerpc64le-unknown-linux-gnu" "-v" "--frozen" "--features" " jemalloc" "--manifest-path" "/<<BUILDDIR>>/rustc-1.17.0+dfsg2/src/rustc/Cargo.toml"
expected success, got: exit code: 101


Build completed unsuccessfully in 0:53:22

The differences between Debian and Rust LLVM are here but I couldn't see anything relevant to powerpc64le.

@cuviper
Copy link
Member

cuviper commented Jun 6, 2017

The error came during stage0, so that's running Debian's local rustc-1.16. Do you have a way to try this build using the upstream binaries for stage0? (just for comparison)

@infinity0
Copy link
Contributor Author

Good idea, I'll try that. Yes, we have something called "build profiles" in Debian and for the rustc package I just have to set an envvar to make it download them.

@infinity0
Copy link
Contributor Author

Yeah, it also happens when using upstream 1.16 to bootstrap. Unfortunately I'm having trouble getting a backtrace, all threads exit normally after LLVM emits that error message and I don't know how to set the correct breakpoint. :(

(sid_ppc64el-dchroot)infinity0@plummer:~/build2/rustc-1.17.0+dfsg2$ find . -name rustc -type f -exec sha256sum '{}' \;                                                                                                                                                     
8630ede4b76d76e1d4e62445603f29f658b00a8d8228d7e5626fc68129d7ad39  ./build/powerpc64le-unknown-linux-gnu/stage0/bin/rustc
^^^^ matches the one from rustc-1.16.0-powerpc64le-unknown-linux-gnu.tar.gz
85118ed15801ff873be64910ba51d2b0eeb0e9c8fc45e7e44436d9db8f35b97d  ./build/bootstrap/debug/rustc


(sid_ppc64el-dchroot)infinity0@plummer:~/build2/rustc-1.17.0+dfsg2$ cat try.sh 
#!/bin/sh
env \
CFG_COMPILER_HOST_TRIPLE=powerpc64le-unknown-linux-gnu \
CFG_RELEASE=1.17.0 \
CFG_RELEASE_CHANNEL=stable \
CFG_VERSION=1.17.0 \
CFG_PREFIX=/usr \
CFG_LIBDIR_RELATIVE=lib \
CFG_DISABLE_UNSTABLE_FEATURES=1 \
CFG_LLVM_ROOT=/usr/lib/llvm-3.9/bin/llvm-config \
CFG_DEFAULT_LINKER=cc \
CFG_DEFAULT_AR=ar \
CXXFLAGS="-g -O2 -fdebug-prefix-map=$PWD=. -fstack-protector-strong -Wformat -Werror=format-security" \
RUSTFLAGS="-C link-args=-Wl,-z,relro" \
SRC=$PWD \
DEB_BUILD_PROFILES=pkg.rustc.dlstage0 \
PWD=$PWD \
CFLAGS="-g -O2 -fdebug-prefix-map=$PWD=. -fstack-protector-strong -Wformat -Werror=format-security -Wno-misleading-indentation" \
CARGO_TARGET_DIR=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc \
RUSTBUILD_NATIVE_DIR=$PWD/build/powerpc64le-unknown-linux-gnu/native \
RUSTC=$PWD/build/bootstrap/debug/rustc \
RUSTC_REAL=$PWD/build/powerpc64le-unknown-linux-gnu/stage0/bin/rustc \
RUSTC_STAGE=0 \
RUSTC_CODEGEN_UNITS=1 \
RUSTC_DEBUG_ASSERTIONS=false \
RUSTC_SYSROOT=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-sysroot \
RUSTC_LIBDIR=$PWD/build/powerpc64le-unknown-linux-gnu/stage0/lib \
RUSTC_RPATH=true \
RUSTDOC=$PWD/build/bootstrap/debug/rustdoc \
RUSTDOC_REAL=$PWD/build/powerpc64le-unknown-linux-gnu/stage0/bin/rustdoc \
RUSTC_FLAGS= \
RUSTC_BOOTSTRAP=1 \
RUST_TEST_THREADS=16 \
RUSTC_SNAPSHOT=$PWD/build/powerpc64le-unknown-linux-gnu/stage0/bin/rustc \
RUSTC_SNAPSHOT_LIBDIR=$PWD/build/powerpc64le-unknown-linux-gnu/stage0/lib \
RUSTC_VERBOSE=1 \
CFLAGS_powerpc64le-unknown-linux-gnu="-ffunction-sections -fdata-sections -fPIC -g -fdebug-prefix-map=$PWD=. -fstack-protector-strong -Wformat -Werror=format-security -Wno-misleading-indentation -m64" \
LD_LIBRARY_PATH=$PWD/build/powerpc64le-unknown-linux-gnu/stage0/lib:$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/debug/deps \
CARGO_PKG_AUTHORS="The Rust Project Developers" \
CARGO_PKG_NAME=rustc \
CARGO_MANIFEST_DIR=$PWD/src/librustc \
gdb -q -d $PWD/../llvm-toolchain-3.9-3.9.1 $PWD/build/bootstrap/debug/rustc --args $PWD/build/bootstrap/debug/rustc \
 --crate-name rustc src/librustc/lib.rs \
 --crate-type dylib \
 --emit=dep-info,link \
 -C prefer-dynamic \
 -C debug-assertions=off \
 -C metadata=9a8968af757a1bcf \
 -C extra-filename=-9a8968af757a1bcf \
 --out-dir $PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps \
 --target powerpc64le-unknown-linux-gnu \
 -L dependency=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps \
 -L dependency=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/debug/deps \
 --extern graphviz=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libgraphviz-8d5c9086242d226f.so \
 --extern arena=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libarena-ecf05c11671d08a9.so \
 --extern rustc_bitflags=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_bitflags-5443fa303d330cea.rlib \
 --extern syntax_pos=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libsyntax_pos-de3247a75eb1a0d3.so \
 --extern rustc_back=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_back-aa35c36e4accdf0b.so \
 --extern syntax=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libsyntax-9d28a1eeb59de909.so \
 --extern rustc_errors=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_errors-3002b2b649d6174e.so \
 --extern fmt_macros=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libfmt_macros-ccb8b8a8d85f24b4.so \
 --extern log=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/liblog-020f4c11c7de4724.so \
 --extern log=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/liblog-020f4c11c7de4724.rlib \
 --extern rustc_llvm=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_llvm-fb29f2ce0720bfb7.so \
 --extern serialize=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libserialize-73e180825ba6b5d6.so \
 --extern serialize=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/libserialize-73e180825ba6b5d6.rlib \
 --extern rustc_const_math=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_const_math-bcc6e22b8fdc9aff.so \
 --extern rustc_data_structures=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/deps/librustc_data_structures-1869e4636a27d433.so \
 -C link-args=-Wl,-z,relro \
 -L native=$PWD/build/powerpc64le-unknown-linux-gnu/stage0-rustc/powerpc64le-unknown-linux-gnu/debug/build/rustc_llvm-e71cc07af9389273/out \
 -L native=/usr/lib/llvm-3.9/lib


(sid_ppc64el-dchroot)infinity0@plummer:~/build2/rustc-1.17.0+dfsg2$ ./try.sh
Reading symbols from /home/infinity0/build2/rustc-1.17.0+dfsg2/build/bootstrap/debug/rustc...done.
(gdb) break lib/MC/ELFObjectWriter.cpp:802 
No source file named lib/MC/ELFObjectWriter.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (lib/MC/ELFObjectWriter.cpp:802) pending.
(gdb) run
Starting program: /home/infinity0/build2/rustc-1.17.0+dfsg2/build/bootstrap/debug/rustc [.. args, as above ..]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
process 8246 is executing new program: /home/infinity0/build2/rustc-1.17.0+dfsg2/build/powerpc64le-unknown-linux-gnu/stage0/bin/rustc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
[New Thread 0x3fffb399eee0 (LWP 8249)]
LLVM ERROR: Undefined temporary symbol
[Thread 0x3fffb399eee0 (LWP 8249) exited]
[Inferior 1 (process 8246) exited with code 01]
(gdb) bt
No stack.
(gdb) 

@cuviper
Copy link
Member

cuviper commented Jun 6, 2017

process 8246 is executing new program: [...]/stage0/bin/rustc

I think you'll need to set follow-fork-mode child, and maybe set detach-on-fork off. What you've got here is just the bootstrap/debug/rustc shim that will run the real stage0/bin/rustc

@infinity0
Copy link
Contributor Author

OK, that worked. I had to revert back to using Debian's rustc 1.16 because it was easier for me to find the debugging symbols for it and LLVM:

(sid_ppc64el-dchroot)infinity0@plummer:~/rustc-1.17.0+dfsg2$ cat try.sh 
[..]
rust-gdb -q -d $HOME/debug \
 -ex "set breakpoint pending on" \
 -ex "break lib/MC/ELFObjectWriter.cpp:802" \
 -ex "set follow-fork-mode child" \
 -ex "set detach-on-fork off" \
 $PWD/build/bootstrap/debug/rustc --args $PWD/build/bootstrap/debug/rustc \
[..]

(sid_ppc64el-dchroot)infinity0@plummer:~/rustc-1.17.0+dfsg2$ ./try.sh 
Reading symbols from /home/infinity0/rustc-1.17.0+dfsg2/build/bootstrap/debug/rustc...done.
No source file named lib/MC/ELFObjectWriter.cpp.
Breakpoint 1 (lib/MC/ELFObjectWriter.cpp:802) pending.
(gdb) run
Starting program: /home/infinity0/rustc-1.17.0+dfsg2/build/bootstrap/debug/rustc [.. args, as above ..]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
process 29259 is executing new program: /usr/bin/rustc
warning: Invalid entry in .debug_gdb_scripts section
[..]
warning: Invalid entry in .debug_gdb_scripts section
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
warning: Invalid entry in .debug_gdb_scripts section
warning: Could not find DWO CU CMakeFiles/LLVMSupport.dir/APFloat.cpp.dwo(0xcc8616f704ca4880) referenced by CU at offset 0x0 [in module /usr/lib/debug/.build-id/03/660f3ebda2245fde1e9b2e0b3ffe0769f5c4c4.debug]
[..]
warning: Could not find DWO CU CMakeFiles/LLVMMC.dir/ELFObjectWriter.cpp.dwo(0xa0cb12fba13e4b88) referenced by CU at offset 0xf72e [in module /usr/lib/debug/.build-id/03/660f3ebda2245fde1e9b2e0b3ffe0769f5c4c4.debug]
[New Thread 0x3fffaf31eee0 (LWP 29268)]
[Switching to Thread 0x3fffaf31eee0 (LWP 29268)]

Thread 2 "rustc" hit Breakpoint 1, (anonymous namespace)::ELFObjectWriter::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> > > >&) ()
    at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/ELFObjectWriter.cpp:802
802           Ctx.reportError(SMLoc(), "Undefined temporary symbol");

(gdb) bt
#0  (anonymous namespace)::ELFObjectWriter::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> > > >&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/ELFObjectWriter.cpp:802
#1  0x00003fffb0d3c144 in (anonymous namespace)::ELFObjectWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/ELFObjectWriter.cpp:1291
#2  0x00003fffb0d52704 in llvm::MCAssembler::Finish() () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/MCAssembler.cpp:725
#3  0x00003fffb0d7b410 in llvm::MCObjectStreamer::FinishImpl() () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/MCObjectStreamer.cpp:546
#4  0x00003fffb0d6b06c in llvm::MCELFStreamer::FinishImpl() () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/MCELFStreamer.cpp:630
#5  0x00003fffb0d857f8 in llvm::MCStreamer::Finish() () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/MC/MCStreamer.cpp:678
#6  0x00003fffb058cc44 in llvm::AsmPrinter::doFinalization(llvm::Module&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1252
#7  0x00003fffb160cdd8 in (anonymous namespace)::PPCLinuxAsmPrinter::doFinalization(llvm::Module&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/Target/PowerPC/PPCAsmPrinter.cpp:1157
#8  0x00003fffb0063098 in llvm::FPPassManager::doFinalization(llvm::Module&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/IR/LegacyPassManager.cpp:1565
#9  0x00003fffb0073018 in llvm::legacy::PassManagerImpl::run(llvm::Module&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/IR/LegacyPassManager.cpp:1621
#10 0x00003fffb00731fc in llvm::legacy::PassManager::run(llvm::Module&) () at /build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1/lib/IR/LegacyPassManager.cpp:1737
#11 0x00003fffb33f3874 in LLVMRustWriteOutputFile () at ./src/rustllvm/PassWrapper.cpp:470
#12 0x00003fffb71e7d5c in rustc_trans::back::write::write_output_file () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:70
#13 0x00003fffb71ecc28 in rustc_trans::back::write::optimize_and_codegen::{{closure}}::{{closure}} () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:612
#14 0x00003fffb71ec754 in rustc_trans::back::write::optimize_and_codegen::with_codegen<closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:560
#15 0x00003fffb71ecf74 in rustc_trans::back::write::optimize_and_codegen::{{closure}} () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:611
#16 0x00003fffb704202c in rustc::util::common::time<(),closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc/util/common.rs:48
#17 0x00003fffb71eb648 in rustc_trans::back::write::optimize_and_codegen () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:580
#18 0x00003fffb71efc34 in rustc_trans::back::write::execute_work_item () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:972
#19 0x00003fffb71f0b98 in rustc_trans::back::write::run_work_singlethreaded () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:1014
#20 0x00003fffb71edb28 in rustc_trans::back::write::run_passes () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_trans/back/write.rs:762
#21 0x00003fffb7e0f410 in rustc_driver::driver::phase_5_run_llvm_passes::{{closure}} () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/driver.rs:1100
#22 0x00003fffb7b358e0 in rustc::util::common::time<(),closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc/util/common.rs:48
#23 0x00003fffb7e0f1d8 in rustc_driver::driver::phase_5_run_llvm_passes () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/driver.rs:1098
#24 0x00003fffb7df8e7c in rustc_driver::driver::compile_input () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/driver.rs:216
#25 0x00003fffb7e21254 in rustc_driver::run_compiler () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/lib.rs:220
#26 0x00003fffb7e2d468 in rustc_driver::main::{{closure}} () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/lib.rs:1129
#27 0x00003fffb7e1fd00 in rustc_driver::run::{{closure}}<closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/lib.rs:136
#28 0x00003fffb7e2d04c in rustc_driver::monitor::{{closure}}<closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/librustc_driver/lib.rs:1063
#29 0x00003fffb7db5374 in std::panic::{{impl}}::call_once<(),closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/panic.rs:296
#30 0x00003fffb7a1f2c4 in std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/panicking.rs:460
#31 0x00003fffb77c17f8 in __rust_try () from /usr/lib/rustlib/powerpc64le-unknown-linux-gnu/lib/libstd-63283ac5.so
#32 0x00003fffb77c1594 in panic_unwind::__rust_maybe_catch_panic () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libpanic_unwind/lib.rs:98
#33 0x00003fffb7a1ef64 in std::panicking::try<(),std::panic::AssertUnwindSafe<closure>> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/panicking.rs:436
#34 0x00003fffb7a1e1cc in std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/panic.rs:361
#35 0x00003fffb7a1eaf0 in std::thread::{{impl}}::spawn::{{closure}}<closure,()> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/thread/mod.rs:357
#36 0x00003fffb7ae7dd8 in alloc::boxed::{{impl}}::call_box<(),closure> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/liballoc/boxed.rs:614
#37 0x00003fffb76afc54 in alloc::boxed::{{impl}}::call_once<(),()> () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/liballoc/boxed.rs:624
#38 0x00003fffb776f5d8 in std::sys_common::thread::start_thread () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/sys_common/thread.rs:21
#39 0x00003fffb77a80e8 in std::sys::imp::thread::{{impl}}::new::thread_start () at /build/rustc-f82A_i/rustc-1.16.0+dfsg1/src/libstd/sys/unix/thread.rs:84
#40 0x00003fffb28280dc in start_thread (arg=0x3fffaf31eee0) at pthread_create.c:335
#41 0x00003fffb7581568 in clone () at ../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:85

For a full source listing see here.

@infinity0
Copy link
Contributor Author

I'm not familiar at all with LLVM, so it will be a while before I get around to investigating this further, but feel free to give me tips etc as I still have the gdb session open and can run things quickly.

Also here are specific instructions for reproducing it, for anyone else that wants to try it on Debian.

Install debugging symbols, download source code, start the build:

$ sudo apt-get install libllvm3.9-dbg llvm-3.9-dbgsym llvm-3.9-runtime-dbgsym llvm-3.9-tools-dbgsym llvm-3.9-dev-dbgsym rustc-dbgsym libstd-rust-1.16-dbgsym rust-gdb
$ apt-get source llvm-toolchain-3.9 rustc # rustc 1.16 from Debian unstable
$ apt-get source -t experimental rustc
$ cd rustc-1.17.0+dfsg2/
$ sudo apt-get build-dep ./
$ dpkg-buildpackage --no-sign
[..]

When the build (of 1.17, from Debian experimental) gets to the failure, it will say:

     Running `$PWD/build/bootstrap/debug/rustc --crate-name rustc src/librustc/lib.rs --crate-type dylib [.. etc more args ..]

If the build fails before you get a chance to notice this, run

$ debian/rules override_dh_auto_build-arch

to return to the "Running" part quickly. At this point, find its pid with pgrep -af rustc, then

tr '\0' '\n' < /proc/$pid/environ | grep -i 'rust\|cfg'

gives you the envvars you'll need to replicate. Put all of this into a shell script:

$ cat try.sh
#!/bin/sh
env \
[env vars, properly quoted] \
rust-gdb -q -d $HOME/debug \
 -ex "set breakpoint pending on" \
 -ex "break lib/MC/ELFObjectWriter.cpp:802" \
 -ex "set follow-fork-mode child" \
 -ex "set detach-on-fork off" \
 $PWD/build/bootstrap/debug/rustc --args $PWD/build/bootstrap/debug/rustc \
 [args, from the "Running" line above, they are already quoted]

then create $HOME/debug with this structure:

$ ls -gG debug/build/*/*
lrwxrwxrwx 1 40 Jun  6 21:46 debug/build/llvm-toolchain-3.9-XPkOIN/llvm-toolchain-3.9-3.9.1 -> $HOME/llvm-toolchain-3.9-3.9.1
lrwxrwxrwx 1 28 Jun  6 22:25 debug/build/rustc-f82A_i/rustc-1.16.0+dfsg1 -> $HOME/rustc-1.16.0+dfsg1

so that gdb can find the source files. Then run the script to easily reproduce the problem.

(I can also give alternative instructions for reproducing this when cross-compiling from amd64 to ppc64el, just ask.)

@cuviper
Copy link
Member

cuviper commented Jun 7, 2017

I don't have any further tips about debugging the issue at the moment. But just for reproducing the environment more easily, there's an --on-fail option that will probably help. It needs to get real documentation, but it's described in the commit message of 0e45a5e.

@infinity0
Copy link
Contributor Author

It looks like this is caused by me working around #39015 in Debian by disabling optimization on ppc64el. However, it's also reproducible for rust's own release builds of 1.17.0:

rustc-1.17.0-src$ ./configure --disable-optimize --disable-optimize-cxx --disable-optimize-llvm
[..]
rustc-1.17.0-src$ ./x.py build
[..]
   Compiling rustc v0.0.0 (file:///home/infinity0/upstream/rustc-1.17.0-src/src/librustc)
LLVM ERROR: Undefined temporary symbol
error: Could not compile `rustc`.

To learn more, run the command again with --verbose.


command did not execute successfully: "/home/infinity0/upstream/rustc-1.17.0-src/build/powerpc64le-unknown-linux-gnu/stage0/bin/cargo" "build" "-j" "16" "--target" "powerpc64le-unknown-linux-gnu" "--features" " jemalloc" "--manifest-path" "/home/infinity0/upstream/rustc-1.17.0-src/src/rustc/Cargo.toml"
expected success, got: exit code: 101


Build completed unsuccessfully in 0:13:15

@infinity0 infinity0 changed the title 1.17.0 powerpc64le Debian: LLVM ERROR: Undefined temporary symbol 1.17.0 powerpc64le: "LLVM ERROR: Undefined temporary symbol" after disabling optimisation Jun 7, 2017
@arielb1
Copy link
Contributor

arielb1 commented Jun 29, 2017

Does this still occur with LLVM 4.0/1.19.0?

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@workingjubilee workingjubilee added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Mar 4, 2023
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@workingjubilee
Copy link
Member

Hmm, this looks like it's related to #58516 perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-PowerPC Target: PowerPC processors T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants