Closed
Description
nightly-2017-10-24 contains a libtest with bad DWARF:
$ /usr/bin/dwarfdump -i ~/.rustup/toolchains/nightly-2017-10-24-x86_64-unknown-linux-gnu/lib/libtest-f00235123717627d.so > /dev/null
/usr/bin/dwarfdump ERROR: reference form with no valid local ref?!, offset=<0x00003085>: DW_DLE_ATTR_FORM_OFFSET_BAD (119)
I can reproduce this if I recompile libtest locally:
$ cd src/libtest
$ RUSTFLAGS="-g -Ccodegen-units=16 -Zthinlto" cargo +nightly-2017-10-24 build --release
Compiling term v0.0.0
Compiling getopts v0.2.15
Compiling test v0.0.0
Finished release [optimized] target(s) in 8.77 secs
$ /usr/bin/dwarfdump -i ../target/release/libtest.so > /dev/null
/usr/bin/dwarfdump ERROR: reference form with no valid local ref?!, offset=<0x0001b758>: DW_DLE_ATTR_FORM_OFFSET_BAD (119)
The problem can be fixed by disabling thinlto (and keeping the codegen units is ok).
I noticed this with nightly-2017-10-24 because it is the first nightly compiled with thinlto, but the problem also occurs if I compile libtest with thinlto enabled using earlier compilers (eg nightly-2017-10-17).
Inspecting the DWARF, a DIE at that local ref offset does exist in another codegen unit, so the problem seems to be that we should be using a global ref instead.