This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/56533] Linker problem on avr with lto and main function inside archive


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56533

--- Comment #3 from Matthijs Kooijman <matthijs at stdin dot nl> 2013-03-05 13:06:18 UTC ---
Seems I made a wrong observation in my original report: When I link main.o
instead of main.a, the problem does _not_ go away. In fact, I can remove a few
more flags then, while still keeping the problem around:

$ ./do
    + rm -f main.a main.o realmain.o
    + /usr/bin/avr-gcc -c main.c -o main.o
    + /usr/bin/avr-gcc -c -flto realmain.c -o realmain.o
    + /usr/bin/avr-gcc -flto -fwhole-program realmain.o main.o
    main.o: In function `main':
    main.c:(.text+0x8): undefined reference to `realmain'
    collect2: error: ld returned 1 exit status

main.c and realmain.c are the same as before.

However, adding -flto to the main.c compilation makes the problem disappear
again. I suspect that this means that without -flto, main.o is passed straight
to the linker and with -flto it is included in link-time optimization, which
would mean your previous analysis still holds.

$ ./do
    + rm -f *.a main.o realmain.o
    + /usr/bin/avr-gcc -c -flto main.c -o main.o
    + /usr/bin/avr-gcc -c -flto realmain.c -o realmain.o
    + /usr/bin/avr-gcc -flto -fwhole-program realmain.o main.o


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]