chettrick / discobsd

2.11BSD-based UNIX-like OS for STM32 and PIC32 Microcontrollers
http://www.DiscoBSD.org
BSD 3-Clause "New" or "Revised" License
171 stars 15 forks source link

atc won't build #9

Closed omarandlorraine closed 11 months ago

omarandlorraine commented 1 year ago

Hi,

I'm having difficulty building DiscoBSD because this builds /games/atc, which fails on my system.

Here is the some of the output of gmake

gmake -C atc -w
gmake[2]: Entering directory '/home/sam/proj/discobsd/games/atc'
/usr/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mabi=aapcs -mlittle-endian -mthumb -mfloat-abi=soft -nostdinc -I/home/sam/proj/discobsd/include  -N -nostartfiles -fno-dwarf2-cfi-asm -T/home/sam/proj/discobsd/lib/elf32-arm.ld /home/sam/proj/discobsd/lib/crt0.o -L/home/sam/proj/discobsd/lib -o atc.elf extern.o grammar.o input.o lex.o list.o log.o main.o tunable.o graphics.o update.o -lm -lcurses -ltermcap -lc
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libm.a(sqrt.o):(.bss+0x0): multiple definition of `errno'; /home/sam/proj/discobsd/lib/libm.a(asin.o):(.bss+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libcurses.a(cr_put.o):(.bss+0x18): multiple definition of `_win'; /home/sam/proj/discobsd/lib/libcurses.a(refresh.o):(.bss+0x4): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tgoto.o):(.bss+0x50): multiple definition of `BC'; /home/sam/proj/discobsd/lib/libcurses.a(curses.o):(.bss+0x104): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tgoto.o):(.bss+0x4c): multiple definition of `UP'; /home/sam/proj/discobsd/lib/libcurses.a(curses.o):(.bss+0x3c): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tputs.o):(.bss+0x2): multiple definition of `PC'; /home/sam/proj/discobsd/lib/libcurses.a(curses.o):(.bss+0x10): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tputs.o):(.bss+0x0): multiple definition of `ospeed'; /home/sam/proj/discobsd/lib/libcurses.a(cr_tty.o):(.data+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libc.a(exit.o):(.bss+0xc): multiple definition of `errno'; /home/sam/proj/discobsd/lib/libm.a(asin.o):(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
gmake[2]: *** [Makefile:25: atc] Error 1
gmake[2]: Leaving directory '/home/sam/proj/discobsd/games/atc'
gmake[1]: *** [Makefile:19: atc] Error 2
gmake[1]: Leaving directory '/home/sam/proj/discobsd/games'
gmake: *** [Makefile:52: all] Error 2

I can see that /sbin/fsck is having a similar problem. But I can't paste the full output of gmake here since there's a 64K limit.

I imagine this means that linking works a little differently on my system. As you know I fixed another game on that pull request.

Maybe atc and others need to be fixed in the same way, or maybe there's a flag or something I can set. I'd be interested to know what to do! I'm happy to file more pull requests as and when I figure it out if that's what you'd like.

omarandlorraine commented 1 year ago

Maybe when we know what the cause is, we can rename the issue to something better

chettrick commented 11 months ago

This particular issue is remedied with commit 97d57678f6d2dd48ecb893c4751ad7cc89347406 and so this issue will be closed. The specific cause of this issue is that GCC 10+ enables -fno-common by default, which triggers many multiple definition errors in legacy codebases. The older behavior is retained via using -fcommon.

Separate issues/pull requests can handle making the codebase -fno-common clean.