mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
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.
This commit is contained in:
parent
af73d8bd83
commit
aac8071730
25
meson.build
25
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user