libretro / mupen64plus-libretro-nx

Improved mupen64plus libretro core reimplementation
GNU General Public License v2.0
233 stars 115 forks source link

Core doesn't build correctly on GNU/Linux #557

Open vanfanel opened 5 days ago

vanfanel commented 5 days ago

Hello there,

I have tried to build latest GIT code today and I get this:

custom/dependencies/libzlib/gzlib.c: In function ‘gz_open’:
custom/dependencies/libzlib/gzlib.c:14:17: error: implicit declaration of function ‘lseek’; did you mean ‘fseek’? [-Wimplicit-function-declaration]
   14 | #  define LSEEK lseek
      |                 ^~~~~
custom/dependencies/libzlib/gzlib.c:256:24: note: in expansion of macro ‘LSEEK’
  256 |         state->start = LSEEK(state->fd, 0, SEEK_CUR);
      |                        ^~~~~
make: *** [Makefile:694: custom/dependencies/libzlib/gzlib.o] Error 1

Was building working fine time ago.

m4xw commented 5 days ago

can u check why unistd isnt included for your case?

vanfanel commented 4 days ago

@m4xw I don't quite get the question. It was not included because it was not there.

I had to add #include <unistd.h to custom/dependencies/libzlib/gzlib.c, custom/dependencies/libzlib/gzread.c, and custom/dependencies/libzlib/gzwrite.c.

Still I don't get it, because as you can see the needed header file isn't present in those. The cause would be that.. it's not there :)

I am using gcc version 14.2.0 (Debian 14.2.0-6) on Debian Trixie. Maybe on older GCC or lib versions, unistd was indirectly included on another header or something.

m4xw commented 4 days ago

its in zconf.h and gzguts.h so why its not being included for you?

vanfanel commented 4 days ago

It's not in gzguts.h at all, and in zconf.h it's only included if certain conditions are met.

But even so, only gzguts.h is included in custom/dependencies/libzlib/gzlib.c, custom/dependencies/libzlib/gzread.c, and custom/dependencies/libzlib/gzwrite.c, not zconf.h.

vanfanel commented 4 days ago

What's more: in Makefile, -DHAVE_UNISTD_H=1 is only passed for OS X, not GNU/Linux, so the unistd.h inclusion in zconf.h could be compromised on GNU/Linux for the lack of -DHAVE_UNISTD_H=1 I guess.

m4xw commented 4 days ago

gzguts includes zlib which includes zconf

gzguts hides it behind emscripten so i guess we encountered it before, in your case it seems that largefile isnt defined and I think the have unistd define should be set via configure which we dont run.

solution is either define Z_HAVE_UNISTD_H via -DZ_HAVE_UNISTD_H or enable largefile support

m4xw commented 4 days ago

(or just HAVE_UNISTD_H but that just defines Z_HAVE_UNISTD_H)

m4xw commented 4 days ago

I am fine with including -DHAVE_UNISTD_H

What's more: in Makefile, -DHAVE_UNISTD_H=1 is only passed for OS X, not GNU/Linux, so the unistd.h inclusion in zconf.h could be compromised on GNU/Linux for the lack of -DHAVE_UNISTD_H=1 I guess.

Yea i think so far it has been implicitly declared and thats not happy on gcc14

m4xw commented 4 days ago

guess both #536 and #526 provide the solution, i will get them in by next week