Closed RetroRevivalGames closed 1 year ago
lto needs to find the entry point. if there is none, there is no output.
I'll have to look into this further. Unfortunately adding an entry symbol to my linker script doesn't solve the problem. Still not outputting a .out.
this creates a file:
m68k-amigaos-gcc -flto -O3 -nostdlib main.c -Wl,-init,_main -o main
I gave that a try. There's no -fno-leading-underscore in your example though which is what's causing the problem for me.
please update and test
I've updated and tested. Looks like it's now producing a .out file with the contents I expect. But the symbols still have underscores even when using the -fno-leading-underscore option ONLY FOR LTO. When compiling without LTO the option works fine.
Guess it's now a pebcak.
main.c:
int foo();
int main() {
return foo() - 1;
}
foo.c:
int foo() {
return 1;
}
m68k-amigaos-gcc -flto -fno-leading-underscore -O3 -nostdlib main.c foo.c -o test
m68k-amigaos-objdump -x test
test: file format amiga
test
architecture: m68k:68000, flags 0x00000010:
HAS_SYMS
start address 0x00000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000008 00000000 00000000 00000020 2**2
CONTENTS, ALLOC, LOAD, CODE
SYMBOL TABLE:
00000008 g .text 0000 00 __etext
00008006 g .text 0000 00 ___a4_init
00000008 g .text 0000 00 ___datadata_relocs
00000008 g .text 0000 00 __end
00000008 g .text 0000 00 __edata
00000008 g .text 0000 00 __bss_start
00000000 g .text 0000 00 main
00000000 g .text 0000 00 __stext
00000008 g .text 0000 00 __sdata
00000004 g .text 0000 00 foo
no underscores
and using m68k-amigaos-gcc -flto -fwhole-program -fno-leading-underscore -O3 -nostdlib main.c foo.c -o test
gets rid of foo
too
I tested it again. Yes it works. Tested in Cygwin and WSL.
Just a quick bug report.
Using -flto doesn't work when using -fno-leading-underscore. I tested this on 64-bit Cygwin running on a 64-bit Windows 10 system. It compiles fine using LTO without -fno-leading-underscore. But using the flag causes no .out file to be produced. Note I've only tested this on Cygwin. I can't confirm if this happens on Linux.
Example Command (Doesn't produce .out):
m68k-amigaos-gcc -flto -fno-leading-underscore -O3 -nostdlib main.c
Example Command (Produces .out):
m68k-amigaos-gcc -flto -O3 -nostdlib main.c