Skip to content

Fix false positive fdatasync detection on darwin

David Faure requested to merge work/dfaure/clang_fix_1 into master

The has_function feature in meson uses different detection methods depending on the contents of the prefix kwarg [1]:

  • if it contains #include directives it will copy the prefix into the test code and check if it compiles
  • if it doesn't contain an include or isn't specified, has_function will forward declare the function and test for it's existence by trying to link it to the default libraries

The latter approach wrongly succeeds for fdatasync on darwin because the linker binds the function to a system call of the same name. Note that this result really is wrong because that system call has not the expected semantics of fdatasync.

By adding an include for unistd.h we can get meson to use the first approach and the detection fails.

Note that this has gone unnoticed so far because only recent versions of clang (the default compiler on darwin) started to treat implicit function declarations as an error.


Merge request reports