diff --git a/meson.build b/meson.build index 3672005d75..c52f8e17c2 100644 --- a/meson.build +++ b/meson.build @@ -524,6 +524,12 @@ if cc.compiles(''' add_project_arguments('-Werror=shadow', language : 'c') endif +have = cc.compiles( + '__attribute__((__retain__)) int x;', + args : '-Werror=attributes', + name : '__attribute__((__retain__))') +conf.set10('HAVE_ATTRIBUTE_RETAIN', have) + if cxx_cmd != '' add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp') endif diff --git a/src/boot/meson.build b/src/boot/meson.build index 06c8146a9e..c51510e96f 100644 --- a/src/boot/meson.build +++ b/src/boot/meson.build @@ -80,8 +80,11 @@ endif efi_conf = configuration_data() # import several configs from userspace -foreach name : ['HAVE_WARNING_ZERO_LENGTH_BOUNDS', 'HAVE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT'] - efi_conf.set10(name, conf.get(name) == 1) +foreach name : ['HAVE_ATTRIBUTE_RETAIN', + 'HAVE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT', + 'HAVE_WARNING_ZERO_LENGTH_BOUNDS', + ] + efi_conf.set(name, conf.get(name)) endforeach efi_conf.set10('ENABLE_TPM', get_option('tpm')) diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index e8757b1fc3..39004183d9 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -88,7 +88,6 @@ #define _printf_(a, b) __attribute__((__format__(printf, a, b))) #define _public_ __attribute__((__visibility__("default"))) #define _pure_ __attribute__((__pure__)) -#define _retain_ __attribute__((__retain__)) #define _returns_nonnull_ __attribute__((__returns_nonnull__)) #define _section_(x) __attribute__((__section__(x))) #define _sentinel_ __attribute__((__sentinel__)) @@ -99,6 +98,12 @@ #define _weak_ __attribute__((__weak__)) #define _weakref_(x) __attribute__((__weakref__(#x))) +#if HAVE_ATTRIBUTE_RETAIN +# define _retain_ __attribute__((__retain__)) +#else +# define _retain_ +#endif + #ifdef __clang__ # define _alloc_(...) #else