[PATCH] Allow building with -flto on gcc-10 and newer.
Guillem Jover
guillem at hadrons.org
Thu Sep 30 02:21:11 UTC 2021
Hi!
On Sat, 2021-08-21 at 14:21:39 +0200, Alexander Miller wrote:
> Global asm statements (like .symver directives) do not work reliably
> in gcc with link time optimization. Use the symver attribute introduced
> with gcc-10 to set symbol versions instead, if available.
Thanks! I've merged this locally, will be included in my next push.
> --- a/src/local-link.h
> +++ b/src/local-link.h
> @@ -32,16 +32,35 @@
> __attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
>
> #ifdef __ELF__
> +
> +#ifdef __has_attribute
> +#if __has_attribute(symver)
> +#define libbsd_have_symver_attribute 1
> +#endif
> +#endif
Instead I've just included <sys/cdefs.h> and used its fallback handling
for __has_attribute(), so that it can be used below unconditionally.
> +#ifdef libbsd_have_symver_attribute
> +#define libbsd_symver_default(alias, symbol, version) \
> + extern __typeof(symbol) symbol \
> + __attribute__((__symver__(#alias "@@" #version)))
> +#define libbsd_symver_variant(alias, symbol, version) \
> + extern __typeof(symbol) symbol \
> + __attribute__((__symver__(#alias "@" #version)))
> +#else
Thanks,
Guillem
More information about the libbsd
mailing list