libretro / swanstation

GNU General Public License v3.0
93 stars 21 forks source link

Build breaks on musl/alpine due to use of "stat64" #105

Closed oliverkwebb closed 1 day ago

oliverkwebb commented 2 months ago

When building swan-station under Alpine Linux, this error will occur and the build will fail:

 1531 |   struct stat64 sysStatData;
      |                 ^~~~~~~~~~~
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp:1532:7: error: 'fstat64' was not declared in this scope; did you mean 'stat64'?
 1532 |   if (fstat64(fd, &sysStatData) < 0)
      |       ^~~~~~~
      |       stat64
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp: In function 'bool FileSystem::FileExists(const char*)':
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp:1573:17: error: aggregate 'FileSystem::FileExists(const char*)::stat64 sysStatData' has incomplete type and cannot be defined
 1573 |   struct stat64 sysStatData;
      |                 ^~~~~~~~~~~
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp:1574:32: error: invalid use of incomplete type 'struct FileSystem::FileExists(const char*)::stat64'
 1574 |   if (stat64(Path, &sysStatData) < 0)
      |                                ^
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp:1573:10: note: forward declaration of 'struct FileSystem::FileExists(const char*)::stat64'
 1573 |   struct stat64 sysStatData;
      |          ^~~~~~
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp: In function 'bool FileSystem::DirectoryExists(const char*)':
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp:1602:17: error: aggregate 'FileSystem::DirectoryExists(const char*)::stat64 sysStatData' has incomplete type and cannot be defined
 1602 |   struct stat64 sysStatData;
      |                 ^~~~~~~~~~~
/home/oliver/src/libretro-super/libretro-swanstation/src/common/file_system.cpp:1603:32: error: invalid use of incomplete type 'struct FileSystem::DirectoryExists(const char*)::stat64'
 1603 |   if (stat64(Path, &sysStatData) < 0)
      |                                ^

This is because Alpine Linux uses the musl implementation of libc, which does not have "struct stat64".

I don't know much about the configuration system, But I'm assuming there's a "if linux" check that allows it if and only if swanstation is being built on linux. (Windows I don't think has stat64)

LibretroAdmin commented 2 months ago

One of the upcoming plans is to rip out a lot of the file I/O code in SwanStation and replace it with libretro VFS instead. This could take care of some of these portability issues here cross-linux distros.

LibretroAdmin commented 1 month ago

Hi, sorry this took some time.

https://github.com/libretro/swanstation/commit/130b79295c8442a6a60bf7a8cecffe20aff9c7cd

I got rid of the direct stat calls and it now goes through libretro-common's VFS abstraction. This should hopefully take care of your problems. Let me know if issues remain.

guijan commented 1 week ago

Still broken on musl for similar reasons. Complete build log of 7a27436 (too long for github): https://paste.debian.net/plainh/31e56ae6

The exact system is PostMarketOS v23.12 on armv7l.