[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#578831: link failure with LTO: ???invalid DSO for symbol `pthread_cancel@@GLIBC_2.0' definition???



On Sun, Aug 08, 2010 at 12:24:58PM +0200, Steinar H. Gunderson wrote:
>> Though I may suggest to try latest upstream binutils and gcc-4.5 to see
>> whether it works there, and if not, try harder to still disentangle the
>> testcase.
> I'll give probably give it a shot, eventually.

OK, I think I've spotted the problem -- it doesn't like that .a files
reference variables in .o files.

fugl:~/dev/lto> cat a.cpp
int var;                 
fugl:~/dev/lto> cat b.cpp
#include <stdio.h>

extern int var;

int main(void)
{
	printf("hello: %d\n", var);
}
fugl:~/dev/lto> g++-4.5 -flto -o a.o -c a.cpp                    
fugl:~/dev/lto> g++-4.5 -flto -o b.o -c b.cpp 
fugl:~/dev/lto> ar rc libwhatever.a b.o
fugl:~/dev/lto> ranlib libwhatever.a 
fugl:~/dev/lto> g++-4.5 -flto -fwhole-program -Wl,--gc-sections -o prog -Wl,--start-group a.o libwhatever.a -Wl,--end-group
libwhatever.a(b.o): In function `main':
b.cpp:(.text+0xa): undefined reference to `var'
collect2: ld returned 1 exit status

If I put a.o into an .a file, it works. The order of a.o and libwhatever.a
doess not matter. Removing -fwhole-program fixes it.

This is a bug, right?

/* Steinar */
-- 
Homepage: http://www.sesse.net/




Reply to: