When the same bitcode object file is given multiple times from the Command-line as lazy object file, empty index is generated which overwrites the one from thinlink. This could cause undefined symbols during final link.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
For Bazel like build systems, it seems weird to have one object file in two modes, lazy and non-lazy. Do you know why it happens for your build system?
I think the change will improve robustness of lld's distributed ThinLTO usage so we probably need to make the change.
We've seen the case of 2 same lazy objects in buck, and the cause for that is still a mystery to us. @christylee may know more.
I listed the case of lazy and non-lazy just for the sake of test coverage.
Such a build system usually deduplicates linker input. I have seen duplicate archives but they are -lc, -lc++, etc, not from cc_library like targets.
Technically with linker scripts INPUT and GROUP an archive can be referenced by two cc_library, but that's a very rare case usually implying a user mistake but I feel the linker can guard against it, which will also help traditional build systems which don't do a great job deduplicating input.
I listed the case of lazy and non-lazy just for the sake of test coverage.
We've seen two cases:
- Older rust compilers will duplicate transitive dependencies, including C++ dependencies.
- Third-party prebuilt libraries that are wrapped with --start-group/--end-group and can be referenced by multiple cc_library. This is technically a user error but it's very hard to debug.
I listed the case of lazy and non-lazy just for the sake of test coverage.
DenseMap<StringRef>