[PATCH] D30544: [lld] - Ignore non-elf files in archives with --whole-archive

Sean Silva via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 00:18:54 PST 2017


silvas added a comment.

In https://reviews.llvm.org/D30544#692075, @ruiu wrote:

> I'd think we should continue handling it as an error. There are a few reasons:
>
> 1. The GNU linkers don't allow that (thank you George for investigating!). That means almost all Unix projects don't add non-object files to .a files, so in practice the current behavior is desirable for most people.


It sounds like this would be for compatibility with the PlayStation proprietary Unix linker, not with the GNU linkers. Last I heard, PlayStation has officially committed to LLD, so we should take their concerns seriously (as with any platform that wants to use LLD as their system linker).

That being said, it's not clear just how critical this is. Owen, can you quantify or otherwise clarify the impact of this feature on your customers? For example, would an excellent error diagnostic be acceptable instead of a warning?

> 2. Assume that foo.a contains x.o, y.o and z.o. The current semantics of `--whole-archive foo.a --no-whole-archive` is the same as `x.o y.o z.o`, which is a pretty simple rule. This patch changes that semantics. I think that's not a good thing to do.

I think this would be a really good reason to keep the current behavior. However, it does not appear to be the case:

  sean:~/pg/llvm/release % ./bin/llvm-ar rcs foo.a build.ninja                  
  sean:~/pg/llvm/release % ./bin/ld.lld --whole-archive foo.a --no-whole-archive
  ./bin/ld.lld: error: build.ninja: invalid data encoding
  zsh: exit 1     ./bin/ld.lld --whole-archive foo.a --no-whole-archive
  sean:~/pg/llvm/release % ./bin/ld.lld build.ninja                             
  ./bin/ld.lld: error: build.ninja:21: malformed number: 1.5
  ./bin/ld.lld: error: build.ninja:21: ninja_required_version = 1.5
  ./bin/ld.lld: error: build.ninja:21:                          ^
  ./bin/ld.lld: error: target emulation unknown: -m or at least one .o file required
  zsh: exit 1     ./bin/ld.lld build.ninja



> 3. It is easy to relax this error check, but tightening it later is hard. I don't want to relax this unless a strong reason to do is presented.

This is a good reason. I think the providing an excellent diagnostic might be a good middleground.


https://reviews.llvm.org/D30544





More information about the llvm-commits mailing list