Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Properly detect Linux with glibc to detect what's not

Open illwieckz opened this issue 3 months ago • 7 comments

Properly detect Linux with glibc to detect what's not, no need to list everything else.

It makes it easier to build for something else we currently don't support, either being another operating system, or Linux with another libc.

I yet again faced the problem of assuming Glibc on Linux when toying with Fil-C that uses musl by default. I do remember having faced similar problems in the past with other stuff. Android? Zig? I don't remember precisely, but I knew that code was fragile, maybe it's better this way.

I'm curious to see if the CI will be happy or not.

If that works, then adding new operating systems would even require less code, not needing to list every of them.

illwieckz avatar Nov 13 '25 22:11 illwieckz

  • native_client: properly detect Linux with glibc to detect what's not LGTM
  • FileSystem: properly detect Linux with glibc to detect what's not seems dubious. The *64 family of functions/structs is apparently defined in POSIX; I get hits for various commercial Unices, including MacOS since 10.5. So I don't see the motivation to associate it with glibc.
  • FileSystem: let Native Client do open() like others hard to say since it appears to depend on the previous commit.

slipher avatar Nov 15 '25 10:11 slipher

I merged the first commit.

illwieckz avatar Nov 26 '25 22:11 illwieckz

  • FileSystem: properly detect Linux with glibc to detect what's not seems dubious. The *64 family of functions/structs is apparently defined in POSIX; I get hits for various commercial Unices, including MacOS since 10.5. So I don't see the motivation to associate it with glibc.

Possibly, but that doesn't prevent us to cleanup the code. We were already avoiding the *64 family outside of Linux, so that code changes nothing for other unices like macOS, etc. What this patch does is to avoid the *64 family on Linux when glibc isn't there.

In the future we can add more tests to enable *64 functions on more systems.

illwieckz avatar Nov 26 '25 22:11 illwieckz

I tested macOS and open64 and others don't exist. Actually we may avoid open64() on Linux.

illwieckz avatar Nov 27 '25 04:11 illwieckz

It looks like we don't need open64(), as glibc remaps open() as open64() and other symbols when _FILE_OFFSET_BITS 64 is set. Other libc (like musl) may only provide a 64-bit large file implementation anyway.

illwieckz avatar Nov 27 '25 04:11 illwieckz

The macOS manpage mentions things like fstat64() but as deprecated.

illwieckz avatar Nov 27 '25 04:11 illwieckz

LGTM

slipher avatar Dec 12 '25 15:12 slipher