chettrick / discobsd

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

get adventure to link #8

Closed omarandlorraine closed 1 year ago

omarandlorraine commented 1 year ago

I had difficulty building discobsd because of how a header file for the game adventure didn't use extern in the way modern gcc expects, so here's a commit that fixed it.

I'm having the same problem with another game, atc. From the output of gmake:

gmake[2]: Entering directory '/home/somebody/proj/discobsd/games/atc'
/usr/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mabi=aapcs -mlittle-endian -mthumb -mfloat-abi=soft -nostdinc -I/home/somebody/proj/discobsd/include  -N -nostartfiles -fno-dwarf2-cfi-asm -T/home/somebody/proj/discobsd/lib/elf32-arm.ld /home/somebody/proj/discobsd/lib/crt0.o -L/home/somebody/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/somebody/proj/discobsd/lib/libm.a(sqrt.o):(.bss+0x0): multiple definition of `errno'; /home/somebody/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/somebody/proj/discobsd/lib/libcurses.a(cr_put.o):(.bss+0x18): multiple definition of `_win'; /home/somebody/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/somebody/proj/discobsd/lib/libtermcap.a(tgoto.o):(.bss+0x50): multiple definition of `BC'; /home/somebody/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/somebody/proj/discobsd/lib/libtermcap.a(tgoto.o):(.bss+0x4c): multiple definition of `UP'; /home/somebody/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/somebody/proj/discobsd/lib/libtermcap.a(tputs.o):(.bss+0x2): multiple definition of `PC'; /home/somebody/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/somebody/proj/discobsd/lib/libtermcap.a(tputs.o):(.bss+0x0): multiple definition of `ospeed'; /home/somebody/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/somebody/proj/discobsd/lib/libc.a(exit.o):(.bss+0xc): multiple definition of `errno'; /home/somebody/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/somebody/proj/discobsd/games/atc'

I think what this means is that some of the libraries (libm, libcurses, libtermcap, libc) each one has the same symbol declared several times). But I am not sure (yet!) how to fix these up.

chettrick commented 1 year ago

Hey there,

What is your development environment? I am guessing it is a Linux distro, but to confirm, please give the output of uname -a and also the output of arm-none-eabi-gcc --version.

Also, please make a new issue for the /games/atc issue you've experienced, as it is cleaner to deal with each problem separately of each other.

I will look into your PR. Thanks again for the cooperation!

omarandlorraine commented 1 year ago

please give the output of uname -a

Linux [redacted] 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

and also the output of arm-none-eabi-gcc --version

arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I'll try and file an issue for the atc problem soon.

chettrick commented 1 year ago

@omarandlorraine Please update to the latest commit 97d57678f6d2dd48ecb893c4751ad7cc89347406 where -fcommon was enabled for arm, and report back if it fixes the linking issues you have experienced.

omarandlorraine commented 1 year ago

Please update to the latest commit https://github.com/chettrick/discobsd/commit/97d57678f6d2dd48ecb893c4751ad7cc89347406 where -fcommon was enabled for arm, and report back if it fixes the linking issues you have experienced.

I can confirm, that adventure builds and some other binaries build that previously didn't. This is using

arm-none-eabi-gcc (15:12.2.rel1-1) 12.2.1 20221205

My build does have some errors:

Created filesystem at partition 1 of distrib/stm32/sdcard.img - 102400 kbytes
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/crt0.o: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libc.a: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libm.a: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libcurses.a: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libgpanel.a: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libreadline.a: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libtermlib.a: No such file or directory
/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libwiznet.a: No such file or directory

but I believe this is an unrelated error

The commit message https://github.com/chettrick/discobsd/commit/97d57678f6d2dd48ecb893c4751ad7cc89347406 has the wording

Enable -fcommon for arm/stm32 until base is -fno-common clean.

which seems to imply that -fno-common cleanness is something we're aiming for; have I understood this correctly?

chettrick commented 1 year ago

My build does have some errors:


Created filesystem at partition 1 of distrib/stm32/sdcard.img - 102400 kbytes

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/crt0.o: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libc.a: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libm.a: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libcurses.a: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libgpanel.a: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libreadline.a: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libtermlib.a: No such file or directory

/home/somebody/discobsd/distrib/obj/destdir.stm32/usr/lib/libwiznet.a: No such file or directory

but I believe this is an unrelated error

Yes, this error is most likely due to an unresolved issue with FreeBSD's version of BSD make. Try with GNU make and see if your build completes without any errors.

Note also that the built in libraries (/usr/lib/lib*.a) aren't actually usable in DiscoBSD/stm32, as I haven't yet ported an assembler that handles Thumb-2. Those libraries work with DiscoBSD/pic32 though (same as RetroBSD for pic32) and can be used with /tools/virtualmips to compile and run the example code in /usr/share/examples.

The commit message https://github.com/chettrick/discobsd/commit/97d57678f6d2dd48ecb893c4751ad7cc89347406 has the wording

Enable -fcommon for arm/stm32 until base is -fno-common clean.

which seems to imply that -fno-common cleanness is something we're aiming for; have I understood this correctly?

Yes, eventually I would like to set -fno-common as the default. Most base utilities will need to be either fixed or updated to a more modern version from one of the BSDs. I will merge this pull request, as that makes one less program to update.

omarandlorraine commented 1 year ago

Yes, this error is most likely due to an unresolved issue with FreeBSD's version of BSD make. Try with GNU make and see if your build completes without any errors.

Oh yes, you're right.

omarandlorraine commented 1 year ago

I will merge this pull request, as that makes one less program to update.

Brilliant!

Shall I carry on with atc (separate pull request) and whatever else I find, or?