[lld] r282633 - Warn on empty archive files.

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 09:09:05 PDT 2016


Are you sure we should be warning on empty archives? This comes up in
Chromium's build, which apparently has an archive with no symbols:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinuxLLD/builds/1596/steps/compile/logs/stdio

That build also doesn't involve LTO, so the long explanatory comment isn't
helpful.

On Wed, Sep 28, 2016 at 2:10 PM, Rui Ueyama via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: ruiu
> Date: Wed Sep 28 16:10:54 2016
> New Revision: 282633
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282633&view=rev
> Log:
> Warn on empty archive files.
>
> Differential Revision: https://reviews.llvm.org/D25044
>
> Modified:
>     lld/trunk/ELF/InputFiles.cpp
>     lld/trunk/test/ELF/empty-archive.s
>
> Modified: lld/trunk/ELF/InputFiles.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> InputFiles.cpp?rev=282633&r1=282632&r2=282633&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/InputFiles.cpp (original)
> +++ lld/trunk/ELF/InputFiles.cpp Wed Sep 28 16:10:54 2016
> @@ -427,8 +427,17 @@ template <class ELFT> void ArchiveFile::
>    File = check(Archive::create(MB), "failed to parse archive");
>
>    // Read the symbol table to construct Lazy objects.
> -  for (const Archive::Symbol &Sym : File->symbols())
> +  bool IsEmpty = true;
> +  for (const Archive::Symbol &Sym : File->symbols()) {
>      Symtab<ELFT>::X->addLazyArchive(this, Sym);
> +    IsEmpty = false;
> +  }
> +
> +  if (IsEmpty)
> +    warning(getName() + " has no symbol. Chances are you are doing "
> +            "an LTO build and forgot to use an ar command that can create
> "
> +            "a symbol table for LLVM bitcode files. If so, use llvm-ar or
> "
> +            "GNU ar + plugin.");
>  }
>
>  // Returns a buffer pointing to a member file containing a given symbol.
>
> Modified: lld/trunk/test/ELF/empty-archive.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> empty-archive.s?rev=282633&r1=282632&r2=282633&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/empty-archive.s (original)
> +++ lld/trunk/test/ELF/empty-archive.s Wed Sep 28 16:10:54 2016
> @@ -1,3 +1,5 @@
>  // RUN: llvm-ar rc %t.a
>  // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
> -// RUN: ld.lld -shared %t.o %t.a -o t
> +// RUN: ld.lld -shared %t.o %t.a -o t 2>&1 | FileCheck %s
> +
> +// CHECK: has no symbol.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/98d67a94/attachment.html>


More information about the llvm-commits mailing list