mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.33k stars 1.53k forks source link

fts.h on Linux does not support _FILE_OFFSET_BITS=64 on glibc older than 2015 #3519

Open siteshwar opened 6 years ago

siteshwar commented 6 years ago

Copying my comment from #1455.

Support for 64-bit operations in fts functions was added only a few years ago in glibc through this commit and there are systems that still ship older versions glibc (for e.g. opensuse). Unconditionally enabling this macro on all systems will cause compilation failures. There should be a feature test before this macro is enabled.

siteshwar commented 6 years ago

For the reference, test case should be pretty simple:

> cat test.c
#include <fts.h>

int main() {
}

> cc -D_FILE_OFFSET_BITS=64 test.c
In file included from test.c:1:0:
/usr/include/fts.h:41:3: error: #error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
 # error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
#include <fts.h>

int main() {
}
nirbheek commented 6 years ago

See also: https://github.com/mesonbuild/meson/issues/3049. Unconditionally enabling this is broken on some platforms (Raspbian armhf) and hilariously broken on other platforms (Android 32-bit).

We do want to fix this properly, but no one has come along who is willing to investigate the edge cases involved. Would you like to work on this?

siteshwar commented 6 years ago

@nirbheek Is there a way to turn off this flag in builds ? If I am reading the docs correctly, it can not be turned off, so it should not be added to builds by default. I might look at it in my free time, but can not promise a fix at the moment.

nirbheek commented 6 years ago

@nirbheek Is there a way to turn off this flag in builds ?

Yes, if you pass -U_FILE_OFFSET_BITS in add_project_arguments() (or on the specific target with c_args:) that should do it.

siteshwar commented 6 years ago

@nirbheek Thanks for the quick fix.

nirbheek commented 6 years ago

Notes:

  1. This is a bug in glibc that we have to work around
  2. The Android NDK bug was fixed when targeting Android SDK >=15
  3. The raspbian armhf bug has not been reproduced yet
mid-kid commented 2 weeks ago

Bumping this, it bit my ass when converting a program from a different build system to meson. I think there should be a toggle at least - no other build system enforces it like that.