On Wed, Mar 4, 2026 at 7:42 AM Alice Carlotti <[email protected]> wrote:
>
> Make __aarch64_cpu_features unconditionally available. This permits the
> unconditional use of this global inside __arm_get_current_vg, which was
> introduced in r16-7637-g41b4a73f370116.
>
> For now this global is only initialised when <sys/auxv.h> is available,
> but we can extend this in future to support other ways of initialising
> the bits used for SME support, and use this remove __aarch64_have_sme.
> This approach was recently adopted by LLVM.
>
> This patch does introduce an inconsistency with __aarch64_have_sme when
> <sys/auxv.h> is unavailable. However, this doesn't introduce any
> regressions, because one of the following conditions will hold:
>
> 1. SVE is enabled at compile time whenever we use a streaming or
> streaming compatible function. In this case the compiler won't need to
> use __arm_get_current_vg, so it doesn't matter if it gives the wrong
> answer.
>
> 2. There is a use of a streaming or streaming compatible function when
> we don't know whether SVE is enabled. In order to get correct DWARF
> unwind information, we then have to be able to test for SVE availability
> at runtime. This isn't possible until a working __arm_get_current_vg
> implementation is available, so the configuration has never (yet) been
> supported.
>
> libgcc/ChangeLog:
>
> PR target/124333
> * config/aarch64/cpuinfo.c: Define __aarch64_cpu_features
> unconditionally.
>
> ---
>
> Evgeny/Saurabh: Can you confirm that this does fix the mingw build?
>
> Is this ok for master?
Ok.
>
> Thanks, and sorry for the breakage,
> Alice
>
>
>
> diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c
> index
> 849c67fdc3b97d77079b1930429e730f0f50ed05..93d9491f7a488e7da890d9f3f942e1c5cc4bf834
> 100644
> --- a/libgcc/config/aarch64/cpuinfo.c
> +++ b/libgcc/config/aarch64/cpuinfo.c
> @@ -24,6 +24,13 @@
>
> #include "common/config/aarch64/cpuinfo.h"
>
> +/* Architecture features used in Function Multi Versioning, and also in some
> + SME support routines. */
> +struct {
> + unsigned long long features;
> + /* As features grows new fields could be added. */
> +} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon));
> +
> #if __has_include(<sys/auxv.h>)
> #include <sys/auxv.h>
>
> @@ -40,12 +47,6 @@ typedef struct __ifunc_arg_t {
> unsigned long _hwcap4;
> } __ifunc_arg_t;
>
> -/* Architecture features used in Function Multi Versioning. */
> -struct {
> - unsigned long long features;
> - /* As features grows new fields could be added. */
> -} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon));
> -
> #define _IFUNC_ARG_HWCAP (1ULL << 62)
> #define AT_HWCAP 16
> #define AT_HWCAP2 26