Closed
Description
error: /home/rubic/Projects/Crates/syn/examples/heapsize2/example/target/debug/deps/libheapsize_derive-3ef99e9f83ff68d2.so: undefined symbol: __rustc_derive_registrar__59da0d2c3725c53af805cb0071a3b093_24
--> src/main.rs:2:1
|
2 | extern crate heapsize_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Disabling incremental compilation or deleting the build files fixes the issue.
$ rustc --version --verbose
rustc 1.25.0-nightly (b5392f545 2018-01-08)
binary: rustc
commit-hash: b5392f54503fdaf04df4b9578510b2baa944f4af
commit-date: 2018-01-08
host: x86_64-unknown-linux-gnu
release: 1.25.0-nightly
LLVM version: 4.0
Steps to reproduce
- git clone https://github.com/dtolnay/syn
- cd syn/examples/heapsize2/example/src/ && CARGO_INCREMENTAL=1 cargo run (build succeeds as expected)
- at syn/examples/heapsize2/heapsize_derive/src/lib.rs:20 insert a line "foo()"
- cd syn/examples/heapsize2/example/src/ && CARGO_INCREMENTAL=1 cargo run (build fails as expected)
- at syn/examples/heapsize2/heapsize_derive/src/lib.rs:16 insert a line "fn foo() { }"
- cd syn/examples/heapsize2/example/src/ && CARGO_INCREMENTAL=1 cargo run (build fails with error above)
In case the changes to source code above weren't clear, refer to the commits 1 & 2 https://github.com/rukai/syn/commits/bug
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
michaelwoerister commentedon Jan 9, 2018
Thanks for the bug report, @rukai!
michaelwoerister commentedon Jan 9, 2018
Let's see if #47181 fixes this...
dtolnay commentedon Jan 14, 2018
@michaelwoerister #47181 did not fix this. I am still seeing the same thing on rustc 1.25.0-nightly (e6072a7 2018-01-13) which contains that PR.
michaelwoerister commentedon Jan 15, 2018
Thanks a lot for verifying.
Nominating for priority assignment (I'd say P-High).
michaelwoerister commentedon Jan 15, 2018
A couple of questions for people knowing about proc-macros (@dtolnay, @jseyfried, @alexcrichton, maybe?):
macro_derive_registrar
function per crate?alexcrichton commentedon Jan 15, 2018
@michaelwoerister there should only be one per crate which is generated by the compiler, so we should have complete control over it.
alexcrichton commentedon Jan 15, 2018
Syntactically it's manufactured here
michaelwoerister commentedon Jan 15, 2018
Ok, so
generate_derive_registrar_symbol()
doesn't actually have to factor the registrar'sDefIndex
into the symbol name in order to make it unique in the crate graph. Removing theDefIndex
should fix this bug.michaelwoerister commentedon Jan 16, 2018
I know what's going on here now: The registrar function is generated in its own module, which means that it is not recompiled during incremental compilation unless its contents change. The symbol for the registrar contains the raw
DefIndex
though, so placing anything with aDefIndex
before the generated registrar will change theDefIndex
of the registrar and thus also change the symbol we expect it to have. But the object file has been cached, so the actual symbol name does not change. This leads to a mismatch between the actual symbol name and the symbol name that we write into crate metadata.I think the best solution is to just remove the
DefIndex
from the symbol name since it is redundant anyway. The same probably goes for regular plugins?10 remaining items