[all-commits] [llvm/llvm-project] 03c825: [ELF] --warn-backrefs: don't warn for linking sand...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Apr 7 10:25:33 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 03c825c224420c498f3f7aef8ad4fb005d62b8ec
      https://github.com/llvm/llvm-project/commit/03c825c224420c498f3f7aef8ad4fb005d62b8ec
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M lld/ELF/Driver.cpp
    M lld/ELF/Symbols.cpp
    M lld/ELF/Symbols.h
    M lld/test/ELF/warn-backrefs.s

  Log Message:
  -----------
  [ELF] --warn-backrefs: don't warn for linking sandwich problems

This is an alternative design to D77512.

D45195 added --warn-backrefs to detect

* A. certain input orders which GNU ld either errors ("undefined reference")
  or has different resolution semantics
* B. (byproduct) some latent multiple definition problems (-ldef1 -lref -ldef2) which I
  call "linking sandwich problems". def2 may or may not be the same as def1.

When an archive appears more than once (-ldef -lref -ldef), lld and GNU
ld may have the same resolution but --warn-backrefs may warn. This is
not uncommon. For example, currently lld itself has such a problem:

```
liblldCommon.a liblldCOFF.a ... liblldCommon.a
  _ZN3lld10DWARFCache13getDILineInfoEmm in liblldCOFF.a refers to liblldCommon.a(DWARF.cpp.o)
libLLVMSupport.a also appears twice and has a similar warning
```

glibc has such problems. It is somewhat destined because of its separate
libc/libpthread/... and arbitrary grouping. The situation is getting
improved over time but I have seen:
```
-lc __isnanl references -lm
-lc _IO_funlockfile references -lpthread
```

There are also various issues in interaction with other runtime
libraries such as libgcc_eh and libunwind:
```
-lc __gcc_personality_v0 references -lgcc_eh
-lpthread __gcc_personality_v0 references -lgcc_eh
-lpthread _Unwind_GetCFA references -lunwind
```

These problems are actually benign. We want --warn-backrefs to focus on
its main task A and defer task B (which is also useful) to a more
specific future feature (see gold --detect-odr-violations and
https://bugs.llvm.org/show_bug.cgi?id=43110).

Instead of warning immediately, we store the message and only report it
if no subsequent lazy definition exists.

The use of the static variable `backrefDiags` is similar to `undefs` in
Relocations.cpp

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D77522




More information about the All-commits mailing list