Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparent issue with using -D_FILE_OFFSET_BITS=64 #286

Open
ell1e opened this issue Jan 17, 2025 · 1 comment
Open

Apparent issue with using -D_FILE_OFFSET_BITS=64 #286

ell1e opened this issue Jan 17, 2025 · 1 comment

Comments

@ell1e
Copy link

ell1e commented Jan 17, 2025

Describe the bug

Currently, PCem doesn't seem to build with musl libc. Based on https://stackoverflow.com/questions/14184031/what-is-the-difference-between-largefile-source-and-file-offset-bits-64 and on https://gitlab.alpinelinux.org/alpine/aports/-/issues/16851#note_474717 when compiling with -D_FILE_OFFSET_BITS=64 but without -D_LARGEFILE64_SOURCE, C/C++ code is apparently expected to use ftell(), fopen() etc. and not ftell64()/fopen64() which PCem v17 seems to be doing. This seems to cause issues compiling with musl libc. The solution seems to be to either stop using the 64 prefix, or to define -D_LARGEFILE64_SOURCE as well.

Here is the error when building PCem v17 with musl libc:

$ make
Making all in src
make[1]: Entering directory '/home/ellie/pcem/src'
gcc -DPACKAGE_NAME=\"PCem\" -DPACKAGE_TARNAME=\"pcem\" -DPACKAGE_VERSION=\"v17\" -DPACKAGE_STRING=\"PCem\ v17\" -DPACKAGE_BUGREPORT=\"Sarah\ Walker\ \<[email protected]\>\" -DPACKAGE_URL=\"\" -DPACKAGE=\"pcem\" -DVERSION=\"v17\" -DHAVE_LIBPTHREAD=1 -DHAVE_LIBGL=1 -DHAVE_LIBOPENAL=1 -I.    -I/usr/lib/wx/include/gtk3-unicode-3.2 -I/usr/include/wx-3.2 -DWXUSINGDLL -D__WXGTK3__ -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -pthread -I/usr/include/SDL2 -D_REENTRANT     -O3 -fcommon -MT pcem-wx-config.o -MD -MP -MF .deps/pcem-wx-config.Tpo -c -o pcem-wx-config.o `test -f 'wx-config.c' || echo './'`wx-config.c
wx-config.c:1465:39: error: unknown type name 'off64_t'; did you mean 'off_t'?
 1465 | static void check_hd_type(void* hdlg, off64_t sz)
      |                                       ^~~~~~~
      |                                       off_t
wx-config.c: In function 'hdnew_dlgproc':
wx-config.c:1810:37: error: implicit declaration of function 'fopen64'; did you mean 'fopen'? [-Wimplicit-function-declaration]
 1810 |                                 f = fopen64(hd_new_name, "wb");
      |                                     ^~~~~~~
      |                                     fopen
wx-config.c:1810:35: error: assignment to 'FILE *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
 1810 |                                 f = fopen64(hd_new_name, "wb");
      |                                   ^
wx-config.c: In function 'hd_file':
wx-config.c:2221:17: error: unknown type name 'off64_t'; did you mean 'off_t'?
 2221 |                 off64_t sz;
      |                 ^~~~~~~
      |                 off_t
wx-config.c:2222:27: error: initialization of 'FILE *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
 2222 |                 FILE *f = fopen64(openfilestring, "rb");
      |                           ^~~~~~~
wx-config.c:2274:25: error: implicit declaration of function 'fseeko64'; did you mean 'fseeko'? [-Wimplicit-function-declaration]
 2274 |                         fseeko64(f, -1, SEEK_END);
      |                         ^~~~~~~~
      |                         fseeko
wx-config.c:2275:30: error: implicit declaration of function 'ftello64'; did you mean 'ftello'? [-Wimplicit-function-declaration]
 2275 |                         sz = ftello64(f) + 1;
      |                              ^~~~~~~~
      |                              ftello
wx-config.c:2277:25: error: implicit declaration of function 'check_hd_type' [-Wimplicit-function-declaration]
 2277 |                         check_hd_type(hdlg, sz);
      |                         ^~~~~~~~~~~~~
make[1]: *** [Makefile:5123: pcem-wx-config.o] Error 1
make[1]: Leaving directory '/home/ellie/pcem/src'
make: *** [Makefile:365: all-recursive] Error 1

To Reproduce
Steps to reproduce the behavior:

  1. Set up any musl libc Linux, e.g. Alpine. A container or a VM should work as well.
  2. Build PCem 17 with configure and make as usual.

Expected behavior
The build works, which doesn't seem to be the case. This seems to be due to a problem with how the 64-bit file access functions are used.

Screenshots
If applicable, add screenshots to help explain your problem.

Emulator configuration

I didn't get that far.

Host machine

  • OS: Alpine
  • Emulator version: PCem v17

Additional context

@sertonix
Copy link

When switching to then non *64 variants some compat code can also be avoided:

add_compile_definitions(fseeko64=fseeko off64_t=off_t fopen64=fopen ftello64=ftell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants