Bug 255546

Summary: games/libretro-mame2000 : fails to build on FreeBSD 13.0-RELEASE powerpc 32 bit: [Makefile:579: src/cpu/tms9900/tms9980a.o] Error 1
Product: Ports & Packages Reporter: canardo <canardo909>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: New ---    
Severity: Affects Only Me CC: bdragon, fernape, menelkir, powerpc
Priority: --- Flags: bugzilla: maintainer-feedback? (menelkir)
Version: Latest   
Hardware: powerpc   
OS: Any   
Description Flags
FreeBSD.13.bug.255546--games_libretro-mame2000--full-log none

Description canardo 2021-05-02 14:21:54 UTC
Problem found when building games/libretro-mame2000 on FreeBSD 13.0-RELEASE powerpc 32 bit running on Apple Powerbook 17".

# uname -a
FreeBSD g41713 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:40:01 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/powerpc.powerpc/sys/GENERIC  powerpc

# cd /usr/ports/games/libretro-mame2000
root@g41713:/usr/ports/games/libretro-mame2000 # make clean
===>  Cleaning for libretro-mame2000-0.20210214
root@g41713:/usr/ports/games/libretro-mame2000 # make -DBATCH install clean
===>  License GPLv2 accepted by the user
===>   libretro-mame2000-0.20210214 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by libretro-mame2000-0.20210214 for building
===>  Extracting for libretro-mame2000-0.20210214
=> SHA256 Checksum OK for libretro-mame2000-libretro-0.20210214-e364a15_GH0.tar.gz.
===>  Patching for libretro-mame2000-0.20210214
===>   Converting DOS text files to UNIX text files
===>  Applying FreeBSD patches for libretro-mame2000-0.20210214 from /usr/ports/games/libretro-mame2000/files
===>   libretro-mame2000-0.20210214 depends on package: gmake>=4.3 - found
===>  Configuring for libretro-mame2000-0.20210214
===>  Building for libretro-mame2000-0.20210214
src/cpu/tms9900/99xxcore.h:444:49: note: expanded from macro 'readword'
        #define readword(addr)        ( TMS99XX_ICOUNT -= 2, (cpu_readmem14(addr) << 8) + cpu_readmem14((addr)+1) )
src/cpu/tms9900/99xxcore.h:3121:11: warning: implicit declaration of function 'setst_subbyte_laecop' is invalid in C99 [-Wimplicit-function-declaration]
                value = setst_subbyte_laecop(readbyte(dest), readbyte(src));
src/cpu/tms9900/99xxcore.h:3136:11: warning: implicit declaration of function 'setst_addbyte_laecop' is invalid in C99 [-Wimplicit-function-declaration]
                value = setst_addbyte_laecop(readbyte(dest), readbyte(src));
16 warnings and 6 errors generated.
gmake[1]: *** [Makefile:579: src/cpu/tms9900/tms9980a.o] Error 1
gmake[1]: Leaving directory '/usr/ports/games/libretro-mame2000/work/mame2000-libretro-e364a15'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1
Comment 1 canardo 2021-05-02 14:28:23 UTC
Created attachment 224611 [details]
Comment 2 Fernando Apesteguía freebsd_committer 2021-05-05 09:27:38 UTC
It builds fine in poudriere in a pretty updated current.

14.0-CURRENT 1400013 50d31dbc6 amd64 git+https 2021-05-02 17:11:19

Would you try updating?

Comment 3 canardo 2021-05-05 16:11:18 UTC
(In reply to Fernando Apesteguía from comment #2)

I tried again after portsnap fetch, update and make clean and the error is still present in version
# uname -a
FreeBSD g41713 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f

Unfortunately I don't have any spare machine to test in version 14.0.

Would it help if I provide a more detailed log ?
If yes, please tell me how to generate one (I'm no developer and need step by step instructions)
Comment 4 Brandon Bergren freebsd_committer 2021-05-05 18:34:49 UTC
FWIW, src/cpu/tms9900/99xxstat.h contains PPC32 specific assembly.

If you want to try the generic C version of those functions, change the

`#if defined(__POWERPC__) && !defined(__powerpc64__)`

line to `#if 0`.

Not sure why it's failing to build though. I suspect that it's using GCC specific bits in the assembly, as I really don't recognize the way it's doing asm functions.
Comment 5 canardo 2021-05-05 19:53:00 UTC
(In reply to Brandon Bergren from comment #4)

Following the change you proposed, build is now successful

# pkg info libretro-mame2000
Name           : libretro-mame2000
Version        : 0.20210214
Installed on   : Wed May  5 21:27:40 2021 CEST
Origin         : games/libretro-mame2000
Architecture   : FreeBSD:13:powerpc

I don't know if this change should be committed, I let you decide.

Should I close the ticket ?
Comment 6 Brandon Bergren freebsd_committer 2021-05-06 00:31:01 UTC
Nah, please leave open for the time being.

While disabling the PPC32 asm is one solution, I think it might be better to do a test build with gcc to see if that fixes the build. Tossing it onto my PPC32 poudriere now to see what happens.
Comment 7 Fernando Apesteguía freebsd_committer 2021-05-06 11:30:56 UTC
By the way, my comment was bogus. I did not test in PowerPC.

It fails in the builders too: https://docs.freebsd.org/mail/current/freebsd-pkg-fallout.html
Comment 8 Brandon Bergren freebsd_committer 2021-05-06 16:05:17 UTC
FWIW I ended up getting the same build failure as ppc64 was getting.

I think maybe what happened here is that the ppc32 code hasn't been built for a while in upstream and it got out of sync with reality.
Comment 9 Daniel Menelkir 2021-06-10 05:15:23 UTC
(In reply to Brandon Bergren from comment #8)
Maybe you're right. I'm not sure how to deal with this. You can try building with https://github.com/libretro/libretro-super to see if works, as it gets from HEAD. Maybe it's possible to send a PR to upstream but I have no idea how to fix it since I don't have the knowledge nor a ppc machine myself by years.
Comment 10 Daniel Menelkir 2021-06-21 12:57:44 UTC
There's not much happening in the main repository (and they'll probably will not touch further since is a relative old mame version). Should I just mark as broken for those ARCHs?