DC-SWAT / DreamShell

Operating system for the Sega Dreamcast
http://www.dc-swat.ru
447 stars 56 forks source link

Fix building with recent HOST compilers (gcc 8 or higher) #15

Closed MastaG closed 4 years ago

MastaG commented 4 years ago

Also add buildscript for Fedora linux

Still I'm getting a configure error when building opus from kos-ports: configure:3531: checking whether the C compiler works configure:3553: kos-cc conftest.c >&5 /opt/toolchains/dc/sh-elf/lib/gcc/sh-elf/5.2.0/../../../../sh-elf/bin/ld: /usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(init.o): in function arch_shutdown': /usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:275: undefined reference to__fini' /opt/toolchains/dc/sh-elf/lib/gcc/sh-elf/5.2.0/../../../../sh-elf/bin/ld: /usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(init.o): in function arch_main': /usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:227: undefined reference to__init' collect2: error: ld returned 1 exit status configure:3557: $? = 1 configure:3595: result: no

Somehow static library libkallisti.a has a undefined reference to fini and init ? Any help would be nice!

DC-SWAT commented 4 years ago

https://github.com/KallistiOS/KallistiOS/commit/2b7068ff7221300a23d147d05893bcf4623be03a

https://github.com/KallistiOS/KallistiOS/commit/93175a99ec9211d7e1c6983be93547bb0c418fea

MastaG commented 4 years ago

Thanks @DC-SWAT I've reverted both commits by adding the reverts to patches/kos.diff /usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c now looks like:

`#if GNUC >= 4 void _init(void); void _fini(void); void __verify_newlib_patch();

endif

if GNUC == 4

define _init init

define _fini fini

endif`

Still the same error happens. configure: error: in /usr/local/dc/kos/kos-ports/opus/build/opus-1.1.1': configure: error: C compiler cannot create executables Seeconfig.log' for more details

configure:3553: kos-cc conftest.c >&5 /opt/toolchains/dc/sh-elf/lib/gcc/sh-elf/5.2.0/../../../../sh-elf/bin/ld: /usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(init.o): in functionarch_shutdown': /usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:275: undefined reference to __fini' /opt/toolchains/dc/sh-elf/lib/gcc/sh-elf/5.2.0/../../../../sh-elf/bin/ld: /usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(init.o): in functionarch_main': /usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:227: undefined reference to __init' collect2: error: ld returned 1 exit status

MastaG commented 4 years ago

Nevermind fixed it.. will push another fix to this PR and then you can merge it :)

megavolt85 commented 4 years ago

gcc 8 don't stable

MastaG commented 4 years ago

@megavolt85 I'm still building the toolchain with gcc 5. Please see my two commits.

It's just that I'm building the toolchain on a recent Linux distro (Fedora 31) which features gcc 9. Building gcc 5 cross-compiler with host gcc 9 requires a small patch.

The second commit is the fix for upstream KOS as pointed out bu @DC-SWAT

I've tested the toolchain build from a clean state from begin to end without problems now :)

MastaG commented 4 years ago

I've changed the title. I meant fix building the toolchain with recent HOST compilers :)

Please merge so everybody can benefit.