There seem to be different, conflicting implementations of size_of_encoded_value(): dwarf2asm.c-int dwarf2asm.c:size_of_encoded_value (int encoding) unwind-pe.h-static unsigned int unwind-pe.h:size_of_encoded_value (unsigned char encoding) /scratch/obj.i686/gcc-4.3/./gcc/xgcc -B/scratch/obj.i686/gcc-4.3/./gcc/ -B/opt/i 686/gcc-4.3//i686-linux-gnu/bin/ -B/opt/i686/gcc-4.3//i686-linux-gnu/lib/ -isyst em /opt/i686/gcc-4.3//i686-linux-gnu/include -isystem /opt/i686/gcc-4.3//i686-li nux-gnu/sys-include -march=pentium4 -mtune=pentium4 -Os -fno-tree-loop-optimize -fno-tree-dominator-opts -fno-strength-reduce -fno-branch-count-reg -falign-func tions=1 -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=2 -pipe -g3 - ggdb3 -O2 -O2 -g -O0 -g3 -ggdb3 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict -prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fP IC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I../. ././gcc -I../../../../src/gcc-4.3/libgcc -I../../../../src/gcc-4.3/libgcc/. -I.. /../../../src/gcc-4.3/libgcc/../gcc -I../../../../src/gcc-4.3/libgcc/../include -I../../../../src/gcc-4.3/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAV E_CC_TLS -DUSE_TLS -o lib2addeh_static_onestep.o -MT lib2addeh_static_onestep.o -MD -MP -MF lib2addeh_static_onestep.dep -fexceptions -c -combine ../../../../sr c/gcc-4.3/libgcc/../gcc/emutls.c ../../../../src/gcc-4.3/libgcc/../gcc/gthr-gnat .c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-c.c ../../../../src/gcc-4.3/libg cc/../gcc/unwind-dw2-fde-glibc.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-dw 2.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-sjlj.c -fvisibility=hidden -DHI DE_EXPORTS {standard input}: Assembler messages: {standard input}:49634: Error: symbol `size_of_encoded_value' is already defined {standard input}:49785: Error: symbol `read_uleb128' is already defined {standard input}:49828: Error: symbol `read_sleb128' is already defined {standard input}:49885: Error: symbol `read_encoded_value_with_base' is already defined {standard input}:50121: Error: symbol `get_cie' is already defined {standard input}:50145: Error: symbol `next_fde' is already defined make[3]: *** [lib2addeh_static_onestep.o] Error 1
Works with -O2, fails with -O0, -O1, -O2 -fno-inline -O0: $ /scratch/obj.i686/gcc-4.3/./gcc/xgcc -B/scratch/obj.i686/gcc-4.3/./gcc/ -B/opt/i686/gcc-4.3//i686-linux-gnu/bin/ -B/opt/i686/gcc-4.3//i686-linux-gnu/lib/ -isystem /opt/i686/gcc-4.3//i686-linux-gnu/include -isystem /opt/i686/gcc-4.3//i686-linux-gnu/sys-include -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I../.././gcc -I../../../../src/gcc-4.3/libgcc -I../../../../src/gcc-4.3/libgcc/. -I../../../../src/gcc-4.3/libgcc/../gcc -I../../../../src/gcc-4.3/libgcc/../include -I../../../../src/gcc-4.3/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o lib2addeh_static_onestep.o -MT lib2addeh_static_onestep.o -MD -MP -MF lib2addeh_static_onestep.dep -fexceptions -combine ../../../../src/gcc-4.3/libgcc/../gcc/emutls.c ../../../../src/gcc-4.3/libgcc/../gcc/gthr-gnat.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-c.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-dw2-fde-glibc.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-dw2.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-sjlj.c -fvisibility=hidden -DHIDE_EXPORTS -c -O0 /tmp/ccidDTzT.s: Assembler messages: /tmp/ccidDTzT.s:5738: Error: symbol `size_of_encoded_value' is already defined /tmp/ccidDTzT.s:5889: Error: symbol `read_uleb128' is already defined /tmp/ccidDTzT.s:5932: Error: symbol `read_sleb128' is already defined /tmp/ccidDTzT.s:5989: Error: symbol `read_encoded_value_with_base' is already defined /tmp/ccidDTzT.s:6224: Error: symbol `get_cie' is already defined /tmp/ccidDTzT.s:6248: Error: symbol `next_fde' is already defined -O1: $ /scratch/obj.i686/gcc-4.3/./gcc/xgcc -B/scratch/obj.i686/gcc-4.3/./gcc/ -B/opt/i686/gcc-4.3//i686-linux-gnu/bin/ -B/opt/i686/gcc-4.3//i686-linux-gnu/lib/ -isystem /opt/i686/gcc-4.3//i686-linux-gnu/include -isystem /opt/i686/gcc-4.3//i686-linux-gnu/sys-include -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I../.././gcc -I../../../../src/gcc-4.3/libgcc -I../../../../src/gcc-4.3/libgcc/. -I../../../../src/gcc-4.3/libgcc/../gcc -I../../../../src/gcc-4.3/libgcc/../include -I../../../../src/gcc-4.3/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o lib2addeh_static_onestep.o -MT lib2addeh_static_onestep.o -MD -MP -MF lib2addeh_static_onestep.dep -fexceptions -combine ../../../../src/gcc-4.3/libgcc/../gcc/emutls.c ../../../../src/gcc-4.3/libgcc/../gcc/gthr-gnat.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-c.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-dw2-fde-glibc.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-dw2.c ../../../../src/gcc-4.3/libgcc/../gcc/unwind-sjlj.c -fvisibility=hidden -DHIDE_EXPORTS -c -O1 /tmp/ccNNdoTR.s: Assembler messages: /tmp/ccNNdoTR.s:5207: Error: symbol `read_uleb128' is already defined /tmp/ccNNdoTR.s:5260: Error: symbol `read_sleb128' is already defined /tmp/ccNNdoTR.s:5329: Error: symbol `read_encoded_value_with_base' is already defined
I suppose the static function static const unsigned char * read_uleb128 (const unsigned char *p, _uleb128_t *val) { in unwind-pe.h should be marked 'inline', otherwise it will be emitted multiple times to the asm file by -combine.
The static size_of_encoded_value's are supposed to be mangled when --combine, like size_of_encoded_value.12521 and on a simple testcase with --combine on x86_64-linux/trunk they are.
Smaller testcase: ----------------------------------- $ cat pr35034-1.c /* PR 35034 - fails to mangle function names for different TUs. */ /* { dg-do compile } */ /* { dg-options "-combine -O0" } */ /* { dg-additional-sources pr35034-2.c } */ typedef int int_t; static void size_of_encoded_value (void) { }; extern int pthread_once (int_t *__once_control, void (*__init_routine) (void)); static __typeof(pthread_once) __gthrw_pthread_once __attribute__ ((__weakref__("pthread_once"))); ----------------------------------- $ cat pr35034-2.c void size_of_encoded_value (void) { }; ----------------------------------- Gives with current trunk: $ gcc-4.3-HEAD pr35034-1.c pr35034-2.c -O0 -c -o foo.o -combine -pipe {standard input}: Assembler messages: {standard input}:12: Error: symbol `size_of_encoded_value' is already defined $ gcc-4.3-HEAD pr35034-1.c pr35034-2.c -O0 -S -o - -combine -pipe .file "pr35034-1.c" .text .type size_of_encoded_value, @function size_of_encoded_value: pushl %ebp movl %esp, %ebp popl %ebp ret .size size_of_encoded_value, .-size_of_encoded_value .globl size_of_encoded_value .type size_of_encoded_value, @function size_of_encoded_value: pushl %ebp movl %esp, %ebp popl %ebp ret .size size_of_encoded_value, .-size_of_encoded_value .weakref __gthrw_pthread_once,pthread_once .ident "GCC: (GNU) 4.3.0 20080131 (experimental)" .section .note.GNU-stack,"",@progbits
Works with gcc-4.1.2 (if one prunes the 'static' of the weakref; They were required to be public back then): $ gcc-4.1 pr35034-1.c pr35034-2.c -O0 -S -o - -combine -pipe .file "pr35034-1.c" .text .globl size_of_encoded_value .type size_of_encoded_value, @function size_of_encoded_value: pushl %ebp movl %esp, %ebp popl %ebp ret .size size_of_encoded_value, .-size_of_encoded_value .weakref __gthrw_pthread_once,pthread_once .ident "GCC: (GNU) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)" .section .note.GNU-stack,"",@progbits
Confirmed. The following also fails with optimization: t1.c: static void __attribute__((used)) size_of_encoded_value (void) { }; static int __gthrw_pthread_once __attribute__ ((__weakref__("pthread_once"))); t2.c: void size_of_encoded_value (void) { }; Not a regression.
Fails with 4.1.2 for me as well, with the static. w/o 4.1 complains t1.c:5: error: '__gthrw_pthread_once' defined both normally and as an alias
(In reply to comment #2) > I suppose the static function > > static const unsigned char * > read_uleb128 (const unsigned char *p, _uleb128_t *val) > { > > in unwind-pe.h should be marked 'inline', otherwise it will be emitted > multiple times to the asm file by -combine. unwind-pe.h as a header should provide an interface to and not implementations of the required functions. Apart from fixing the functions in IMA, unwind-pe.h should split it's implementations off into a e.g. unwind-pe.c that exports the common helpers. Does somebody know if it is really intended that dwarf2asm.c has grown (or kept) a different impl of size_of_encoded_value() than all the rest?
(In reply to comment #7) > Fails with 4.1.2 for me as well, with the static. w/o 4.1 complains > > t1.c:5: error: '__gthrw_pthread_once' defined both normally and as an alias > Works flawlessly for me (without the static, on debian with the debian-patched cc): $ gcc-4.1 pr35034-1.c pr35034-2.c -O0 -c -o foo.o -combine -pipe ; echo $? 0
That's a accepts-invalid problem on 4.1, try the same thing with the reduced testcase from comment #6.
*** Bug 38460 has been marked as a duplicate of this bug. ***
-combine has been removed from GCC 4.6 in favor of LTO, closing as WONTFIX.