diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-12-30 14:51:44 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-12-31 07:02:29 +0900 |
commit | aac8071730bd0bca3c2289bda628b1ef7a2591d2 (patch) | |
tree | 6631bbdeadaa108a2021319fa7f08e35f442c92a | |
parent | af73d8bd83147d64f4bc262bc9eeef64f7ff51ff (diff) | |
download | systemd-aac8071730bd0bca3c2289bda628b1ef7a2591d2.tar.gz |
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.
-rw-r--r-- | meson.build | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/meson.build b/meson.build index 0d2faf720c..043be41115 100644 --- a/meson.build +++ b/meson.build @@ -1176,12 +1176,15 @@ if want_libcryptsetup != 'false' and not skip_deps required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true') have = libcryptsetup.found() - conf.set10('HAVE_CRYPT_SET_METADATA_SIZE', - have and cc.has_function('crypt_set_metadata_size', dependencies : libcryptsetup)) - conf.set10('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', - have and cc.has_function('crypt_activate_by_signed_key', dependencies : libcryptsetup)) - conf.set10('HAVE_CRYPT_TOKEN_MAX', - have and cc.has_function('crypt_token_max', dependencies : libcryptsetup)) + foreach ident : ['crypt_set_metadata_size', + 'crypt_activate_by_signed_key', + 'crypt_token_max'] + have_ident = have and cc.has_function( + ident, + prefix : '#include <libcryptsetup.h>', + dependencies : libcryptsetup) + conf.set10('HAVE_' + ident.to_upper(), have_ident) + endforeach else have = false libcryptsetup = [] @@ -1189,8 +1192,14 @@ endif conf.set10('HAVE_LIBCRYPTSETUP', have) if want_libcryptsetup_plugins != 'false' and not skip_deps - have = (cc.has_function('crypt_activate_by_token_pin', dependencies : libcryptsetup) and - cc.has_function('crypt_token_external_path', dependencies : libcryptsetup)) + have = (cc.has_function( + 'crypt_activate_by_token_pin', + prefix : '#include <libcryptsetup.h>', + dependencies : libcryptsetup) and + cc.has_function( + 'crypt_token_external_path', + prefix : '#include <libcryptsetup.h>', + dependencies : libcryptsetup)) else have = false endif |