This matches the wasm lld and GNU ld behavior.
The ELF linker has special handling for bitcode archives but if that
doesn't kick in we probably want to error out rather than silently
ignore the library.
Differential D63781
[ELF] Error on archive with missing index sbc100 on Jun 25 2019, 11:41 AM. Authored by
Details This matches the wasm lld and GNU ld behavior. The ELF linker has special handling for bitcode archives but if that
Diff Detail
Event TimelineComment Actions I think this is a backward-incompatible change. Previously, you could create an archive containing both bitcode files and ELF files, and this patch disallow that combination, which seems a bit too risky change to me. Comment Actions This change only effects archives without an index. If you previously created an archive with both bitcode *and* ELF files *and* you didn't create and index, the previous behaviour was to completely ignore the archive. This seems bad to me. The new behaviour is to give an error. We could downgrade it to a warning but both GNU ld and wasm-ld give a hard error in this case. Are you saying that ignoring these hybrid archives is a behavior that you want to keep? Comment Actions The previous behaviour was also to ignore archives that contain only ELF files but no index. Comment Actions Is that true? If an archive has no index, each individual member is handled as if they were surrounded by --start-lib/--end-lib, so they wouldn't be ignored, I think. Comment Actions I'm pretty certain yes. The old code only loads archives one object at a time if all objects are bitcode. I didn't change that part. Comment Actions Can you take a closer look? I'm pretty sure this change is correct. At the very least an improvement, and not a regression.
Comment Actions LGTM Yeah, looks like I misunderstood the existing code. Thank you for pointing that out.
Comment Actions Just a note after the fact: this change broke linking in TinyGo. It used to manually build an archive (without index) with object files from compiler-rt and that worked just fine in LLVM 8 - it did read symbols from those archives even without a symbol table. In LLVM 9, ld.lld refuses to link those libraries. We'll work around it by manually building a symbol table for lld. For details: https://github.com/tinygo-org/tinygo/issues/595 Comment Actions I'm pretty sure this change went from silently ignoring the archive to erroring out. So I think your use case would have been broken even before this change. See the return statement on line 227. Perhaps there are no needed symbols in your archive? In that case maybe this would be a regression but that seems unlikely. |
/dev/null if you don't need the output file?