Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[coverage] linker failure with dead code stripping #39854

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR40884
Status NEW
Importance P normal
Reported by Stefan Schmidt-Bilkenroth (stefan.schmidt-bilkenroth@gemalto.com)
Reported on 2019-02-27 06:14:11 -0800
Last modified on 2019-03-01 01:02:49 -0800
Version trunk
Hardware PC Windows XP
CC llvm-bugs@lists.llvm.org, mariusguggenmos@gmail.com, rnk@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also PR37561

This is related to Bug 37561. The bug is fixed now, but I get linker errors (lld-link) when building teh project with optimizer (for release).

lld-link reports about an error with relocation against "symbol" in discarded section. This was triggered by a global function calling sprintf(), which was not referenced. After I removed the function or replaced sprintf() with snprintf(), linker did not complain, but the unit test was failing.

When building for Debug, the linker also did not complain, the unit test was passing and I was able to create the coverage report.

Looks to me like dead code stripping is leading to dangling references and also the Optimizer may cause code corruptions.

I hope Marius can reproduce the issue with his project, as I can hardly share mine and it comes with a lot of references in our repository.

SSB

Quuxplusone commented 5 years ago

I don't think it's dead stripping, I think it's just misuse of comdats interacting badly with inlining, which happens when you enable inlining. I think https://reviews.llvm.org/D58737 will address this.

I actually introduced this bug in https://reviews.llvm.org/D57929. Two steps forward, one step backward.

Quuxplusone commented 5 years ago

Try after r355044, see if the "relocation against discarded section" errors go away.

Quuxplusone commented 5 years ago
Works for me with the latest master.
clang version 9.0.0 (https://github.com/llvm/llvm-project.git
9bf43b5c261b4df6c855231905d14608687c7633)

Thanks for the quick fix