[PATCH] D17998: [ELF] implement --warn-common/--no-warn-common

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 12 18:42:38 PST 2016


On Sat, Mar 12, 2016 at 5:00 AM, Joerg Sonnenberger via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> On Sat, Mar 12, 2016 at 09:17:46AM +0000, George Rimar via llvm-commits
> wrote:
> > Yea, I answered already via llvm-mails, but will duplicate answer here
> for history of patch.
> > Current logic always warn about such symbols. I did that intentionaly
> because gold do the same,
> > consider 2 files:
> >
> > test.s:
> >
> >   .globl _start
> >   _start:
> >
> >   .type arr, at object
> >   .comm arr,4,4
> >
> > test2.s:
> >
> >   .type arr, at object
> >   .comm arr,4,4
> >
> > So 2 commons have the same size and gold produces a warning in that case:
> > ++ /home/LLVM/build/bin/llvm-mc -filetype=obj test.s -o test.o
> > ++ /home/LLVM/build/bin/llvm-mc -filetype=obj test2.s -o test2.o
> > ++ gold -warn-common test.o test2.o -o test
> > gold: warning: test2.o: multiple common of 'arr'
> > gold: test.o: previous definition here
>
> This is explicitly going to break Fortran programs and I don't think it
> generally adds much value.
>

Looking into it and I found that this patch seems desirable. I think the
use case of this option is to catch any programmer's error to forget to add
"extern" to uninitialized global variables. They are usually silently
merged by the linker because they are common symbols, but you often want to
avoid that default behavior and do rigorous error checking. This option is
useful for that. In that case you want to find any common duplicate common
symbols regardless of their sizes.

For Fortran programs, don't use this option.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160312/0480ca8e/attachment.html>


More information about the llvm-commits mailing list