Linking two external linkage GlobalValues

Hello, Bram.

My question: does this change break certain design decisions,
optimisations, ...?

This is bug in the source code. You have two symbols with the same name
in the different object files, which is definite redefinition. At least
one of them should be declared with "extern".

Hi Anton,

This is bug in the source code. You have two symbols with the same
name in the different object files, which is definite redefinition. At
least one of them should be declared with "extern".

C allows this.

    $ head foo.c bar.c
    ==> foo.c <==
    void bar();
    int foo;

    int main()
    {
        bar();
        return foo;
    }

    ==> bar.c <==
    int foo;

    void bar()
    {
        foo = 42;
        return;
    }
    $ gcc -Wall foo.c bar.c && ./a.out; echo $?
    42
    $

Better practice to have one definition I agree, but it's valid C.

Cheers,

Ralph.

Shouldn't these symbols get "common" linkage, aka llvm weak linkage?

Are you building the source with -fno-common? If not, it could be an llvm bug.

-Chris

Hi,

-fno-common is a performance win on some targets, but it disallows merging of global variables that are defined with no initializers (like your example). Please remove -fno-common, if it builds correctly, then it is not an llvm bug.

-Chris

Hi,