]> git.ipfire.org Git - thirdparty/systemd.git/commit
meson: fix detection of libcryptsetup functions
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Dec 2021 13:51:44 +0000 (14:51 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 30 Dec 2021 22:02:29 +0000 (07:02 +0900)
commitaac8071730bd0bca3c2289bda628b1ef7a2591d2
tree6631bbdeadaa108a2021319fa7f08e35f442c92a
parentaf73d8bd83147d64f4bc262bc9eeef64f7ff51ff
meson: fix detection of libcryptsetup functions

Meson would generate the following compile test:

  #define crypt_set_metadata_size meson_disable_define_of_crypt_set_metadata_size

  #include <limits.h>
  #undef crypt_set_metadata_size

  #ifdef __cplusplus
  extern "C"
  #endif
  char crypt_set_metadata_size (void);

  #if defined __stub_crypt_set_metadata_size || defined __stub___crypt_set_metadata_size
  fail fail fail this function is not going to work
  #endif

  int main(void) {
    return crypt_set_metadata_size ();
  }

This works fine when the identifier being queried is an actual function. But
crypt_token_max() is an inline function, so getting the address would fail,
leading to a false negative result. Complation would fail because the function
would be defined twice.

With this patch, the check is changed to include the header:

  #include <libcryptsetup.h>
  #include <limits.h>

  #if defined __stub_crypt_set_metadata_size || defined __stub___crypt_set_metadata_size
  fail fail fail this function is not going to work
  #endif

  int main(void) {
    void *a = (void*) &crypt_set_metadata_size;
    long long b = (long long) a;
    return (int) b;
  }

which seems to work correctly.
meson.build