-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Linker error because -wL as-needed
conflicts with -C link-dead-code
#64685
Comments
Is there any idea about what it would take to fix this? I'm interested in helping out if someone can help guide me 😄 |
Getting a similar issue in suricata: https://github.com/OISF/suricata/tree/master/rust I tried removing the |
When compiling Rust binaries with After learning of this known bug, I discovered a workaround: Disabling link-dead-code, via It is an acceptable workaround for now, but I would prefer to enable Before learning of this workaround, I did some extensive investigation of the bug with |
After some sidebar discussions, I think the issue with |
@jonas-schievink @richkadel Just tagging you both as you seem to be the two contributors who have interacted with this issue 😉 I was considering attempting to tackle this one as it's been a proverbial thorn in my side for a while. As an approach I was considering looking for Just wanted to make sure it made sense as an approach and there's no linker things I'm oblivious too and if so a vague pointer towards where in the rust code to look to figure it out would be appreciated 😄 |
I'm afraid I don't really have enough depth-of-knowledge here to be of much help. |
A brief note for anyone reviewing this issue, as of PR #79109, This issue is no longer relevant to LLVM source code coverage, but may still be relevant to other use cases of course. |
@richkadel won't that impact the accuracy of the LLVM code coverage then? |
I implemented coverage for unused functions in a different way, which is actually more complete than anything I was getting from |
Oh that's great! How does it tackle things like unused generic code? Will it cover them or only cover them if instantiated with a type somewhere? |
Unused generics are covered too. Since I'm going back to MIR, the MIR is generated based on the parsed code, not used code, so I don't need it to be instantiated. That's one of the issues I was trying to solve with this new approach. |
When a project has the
[lib]
tag in theCargo.toml
the-wL as-needed
flag is added to the projects linker flags. However, if a project uses-C link-dead-code
the two flags conflict causing a linker error ofundefined reference
for any functions in the lib.This was discovered because link-dead-code is used for code coverage in tarpaulin. I spent some time seeing if there was a way around it as a user but I didn't manage to solve it myself. Issue that lead me to this for reference: xd009642/tarpaulin#126
Any solutions I could currently implement would be appreciated if this requires a PR I'm also happy to contribute (though may need some mentorship)
The text was updated successfully, but these errors were encountered: