http://llvm.org/bugs/show_bug.cgi?id=8859
Summary: extern __inline__ causes multiple def'n errors
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Consider the two files:
== a ==
extern __inline__ void foo() { return; }
void test_a() { foo(); return; }
== b ==
extern __inline__ void foo() { return; }
void test_b() { foo(); return; }
compiled *without* optimization, so that inlining doesn't happen. For
reference, the GCC documentation on it is here:
http://gcc.gnu.org/onlinedocs/gcc/Inline.html and it pretty much states that
extern inline can't generate a definition.
Here's the real-world manifestation of the problem:
$ gcc a.c -c -o a.o
$ gcc b.c -c -o b.o
$ ld -r a.o b.o
$ clang a.c -c -o a.o
$ clang b.c -c -o b.o
$ ld -r a.o b.o
ld: error: multiple definition of `foo'
ld: a.o: previous definition here
What did GCC actually do with this declaration? The assembly makes no
declaration of foo at all, it just emits a "call foo" instruction in test_A.
Clang emitted:
.file "a.c"
.text
.globl foo
.align 16, 0x90
.type foo,@function
foo:
[...]
Which is clearly more than it needed to. But what about C++? Things are a
little bit different there: GCC *does* emit the function. Here's the relevant
portion of the assembly:
$ g++ a.cc -S -o -
.file "a.cc"
.section .text._Z3foov,"axG",@progbits,_Z3foov,comdat
.weak _Z3foov
.type _Z3foov, @function
_Z3foov:
[...]
Clang just emits a normal linkonce_odr function with:
.section .gnu.linkonce.t._Z3foov,"ax",@progbits
.weak _Z3foov
.align 16, 0x90
.type _Z3foov,@function
_Z3foov:
[...]
In either case, Clang is getting this wrong and it's causing multiple
definition errors where the GCC extension says they shouldn't be happening. I'm
not sure whether the problem is in the linkage type selected by clang when
lowering to llvm or whether the lowering of linkonce functions to elf .section
rules is wrong.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs