-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Unreachable post-monomorphization error triggered by -C link-dead-code
#131793
Labels
I-monomorphization
Issue: An error at monomorphization time.
link-dead-code
Linkage: using -Clink-dead-code
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
Comments
rustbot
added
the
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
label
Oct 16, 2024
jswrenn
added a commit
to google/zerocopy
that referenced
this issue
Oct 16, 2024
These are causing PMEs in the presence of `-C link-dead-code`, which casues them to be monomorphized for `Self = ()`, thus producing the problematic ZSTy DST `[()]`. Ref rust-lang/rust#131793 Fixes #1867
jswrenn
added a commit
to google/zerocopy
that referenced
this issue
Oct 16, 2024
These are causing PMEs in the presence of `-C link-dead-code`, which casues them to be monomorphized for `Self = ()`, thus producing the problematic ZSTy DST `[()]`. Also bumps version to 0.8.6. Ref rust-lang/rust#131793 Fixes #1867
jswrenn
added a commit
to google/zerocopy
that referenced
this issue
Oct 16, 2024
These are causing PMEs in the presence of `-C link-dead-code`, which casues them to be monomorphized for `Self = ()`, thus producing the problematic ZSTy DST `[()]`. Also bumps version to 0.8.6. Ref rust-lang/rust#131793 Fixes #1867
joshlf
pushed a commit
to google/zerocopy
that referenced
this issue
Oct 16, 2024
These are causing PMEs in the presence of `-C link-dead-code`, which casues them to be monomorphized for `Self = ()`, thus producing the problematic ZSTy DST `[()]`. Also bumps version to 0.8.6. Ref rust-lang/rust#131793 Fixes #1867
#122301 might be of interest here. Basically: by introducing a generic you can delay the instantiation of the const until it's used with some concrete T. This isn't a guaranteed language property yet but it seems like opinions are leaning towards that way. |
lolbinarycat
added
link-dead-code
Linkage: using -Clink-dead-code
I-monomorphization
Issue: An error at monomorphization time.
labels
Oct 24, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
I-monomorphization
Issue: An error at monomorphization time.
link-dead-code
Linkage: using -Clink-dead-code
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
I have the following code:
If I build normally (using
cargo build
), it succeeds. If I build passingRUSTFLAGS='-C link-dead-code'
, Rust attempts to monomorphizeFoo::baz
and fails despiteFoo::baz
never being used:Post-monomorphization errors (PMEs) are often used to detect error conditions at compile time that cannot be encoded in the type system proper. We do this in zerocopy 0.8 in certain APIs to ban dynamically-sized types whose trailing element type is zero-sized.
cargo fuzz
builds using-C link-dead-code
, and so it has been causing build failures for our users. In our specific case, it's possible to work around this because (for entirely coincidental reasons) the issue is only triggered by deprecated APIs that we can likely just remove. However, it's only luck that this hasn't caused more serious breakage for us.I'm not sure what the right thing to do here is. From our perspective, having
-C link-dead-code
be more permissive would be good, but I understand why that might not be desirable for other users.Miscellaneous
Cargo version 1.81.0.
The text was updated successfully, but these errors were encountered: