shared-mime-info-2.3-fsync-detection.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. https://gitlab.freedesktop.org/xdg/shared-mime-info/-/commit/7499ac1a85b2487b94e315e6b55c34bcf220295f
  2. From 7499ac1a85b2487b94e315e6b55c34bcf220295f Mon Sep 17 00:00:00 2001
  3. From: Tobias Mayer <tobim@fastmail.fm>
  4. Date: Sat, 7 Oct 2023 23:45:47 +0200
  5. Subject: [PATCH] Fix false positive fdatasync detection on darwin
  6. The `has_function` feature in meson uses different detection methods
  7. depending on the contents of the `prefix` kwarg [1]:
  8. * if it contains `#include` directives it will copy the prefix into
  9. the test code and check if it compiles
  10. * if it doesn't contain an include or isn't specified, `has_function`
  11. will forward declare the function and test for it's existence by
  12. trying to link it to the default libraries
  13. The latter approach wrongly succeeds for `fdatasync` on darwin because
  14. the linker binds the function to a system call of the same name. Note
  15. that this result really is wrong because that system call has not
  16. the expected semantics of `fdatasync`.
  17. By adding an include for `unistd.h` we can get meson to use the
  18. first approach and the detection fails.
  19. Note that this has gone unnoticed so far because only recent versions
  20. of clang (the default compiler on darwin) started to treat implicit
  21. function declarations as an error.
  22. [1] https://github.com/mesonbuild/meson/blob/583d2815d1a130227f0f4db47e4ab2e80ebb6a61/mesonbuild/compilers/mixins/clike.py#L839-L846
  23. Fixes #211
  24. ---
  25. meson.build | 7 +------
  26. 1 file changed, 1 insertion(+), 6 deletions(-)
  27. diff --git a/meson.build b/meson.build
  28. index 1780c443..7998a51b 100644
  29. --- a/meson.build
  30. +++ b/meson.build
  31. @@ -49,12 +49,7 @@ endif
  32. ###############################################################################
  33. # Dependencies
  34. -check_functions = [
  35. - 'fdatasync',
  36. -]
  37. -foreach function : check_functions
  38. - config.set('HAVE_'+function.to_upper(), cc.has_function(function))
  39. -endforeach
  40. +config.set('HAVE_FDATASYNC', cc.has_function('fdatasync', prefix: '#include <unistd.h>'))
  41. if get_option('build-translations')
  42. --
  43. GitLab