non well-formed symbol mangling and bad symbol tracking issue #46552
Labels
A-linkage
Area: linking into static, shared libraries and binaries
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
So, here's my ultimate desire for this eventually so that stuff like this doesn't happen again:
You might be surprised to learn that 1 is not true in practice. So I've opened this issue for tracking various cases I've found, and what follows are the specimens:
Examples
As of rustc 1.22, on the following program compiled via
rustc hello.rs
:I am seeing the following issues:
Spurious thread locals
symbol:
.tdata._ZN3std10sys_common11thread_info11THREAD_INFO7__getit5__KEY17hc69464ef038d7e85E
Example source location: https://github.com//m4b/rust/blob/383e313d181eceb3155eb1089d448144f830ee23/src/libstd/sys_common/thread_info.rs#L21
Why incorrect
does not start with _ZN.
This looks like its meant to be the section name. The exact same TLS variable does occur later on, with the same address:
but correctly mangled.
This could be an llvm bug; I have verified this only seems to occur to variables generated via the
thread_local!
macro, and furthermore, is inside of the crate.rlib
static archive. (you can output this by something like:(your
libstd-<hash>
will vary of course tho)E.g. here is every symbol with either
.tdata
in its name or referencing that section in rust 1.22 libstd object file (inside.rlib
):The spurious symbols will never be gc'd by the linker, and they will never get referenced; so they're just taking up space (albeit not much).
backtrace.rs nested static
symbol:
_ZN3std10sys_common9backtrace11log_enabled7ENABLED17hc187c5b3618ccb2eE.0.0
Example source location: https://github.com//m4b/rust/blob/383e313d181eceb3155eb1089d448144f830ee23/src/libstd/sys_common/backtrace.rs#L148
Why Incorrect
No mangled symbol is allowed to have characters after the final
E
, but this has.0.0
I have definitely seen other examples of this, and with different numbers at the end; I think it has to do with nested statics somehow.
Nightly
On nightly it looks like there has been a pretty substantial regression w.r.t. valid symbol names being output:
This runs the whole gamut of functions, global memory, read only strings, all apparently (sometimes) having extra characters appended.
Special Mentions
{{closure}}
in symbols are useless, and very hard to print in debuggers.E.g.:
which is from the use of this closure:
https://github.com//m4b/rust/blob/383e313d181eceb3155eb1089d448144f830ee23/src/libcore/fmt/mod.rs#L1108
The compiler knows the line number (it will even omit this sometimes like
@[closure; mod.rs:1108]
or whatever); why not just output that instead of{{closure}}
?The text was updated successfully, but these errors were encountered: