> -----Original Message-----
> From: Matthieu Longo <[email protected]>
> Sent: 24 November 2025 16:09
> To: [email protected]
> Cc: Tamar Christina <[email protected]>; Richard Earnshaw
> <[email protected]>; Matthieu Longo
> <[email protected]>
> Subject: [PATCH v1 1/1] aarch64: Define __ARM_BUILDATTR64_FV
>
> Support for Build Attributes (BA) was originally added in [1]. To facilitate
> their
> use in customers codebases and avoid requiring a new Autotools test for BA
> support,
> the specification was later amended. Toolchains that generate BA sections and
> support the assembler directives should define the following preprocessor
> macro:
> __ARM_BUILDATTR64_FV <format-version>
> Where <format-version> is the same value as in [2]. Currently, only version
> 'A'
> (0x41) is defined.
>
> This patch also introduces two tests: one that verifies the macro definition
> for
> positive detection of BA support; and another that ensures that no such
> macro is
> defined when BA support is absent.
>
> [1]: 98f5547dce2503d9d0f0cd454184d6870a315538
> [2]: [Formal syntax of an ELF Attributes
> Section](https://github.com/smithp35/
> abi-aa/blob/build-attributes/buildattr64/buildattr64.rst#formal-syntax-of-
> an-elf
> -attributes-section)
>
Patch is OK.
Thanks,
Tamar
> gcc/ChangeLog:
>
> * config/aarch64/aarch64-c.cc
> (aarch64_define_unconditional_macros): Define
> __ARM_BUILDATTR64_FV when BA support is detected in GAS.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/aarch64/build-attributes/build-attribute-define-nok.c:
> New test.
> * gcc.target/aarch64/build-attributes/build-attribute-define-ok.c:
> New test.
> ---
> gcc/config/aarch64/aarch64-c.cc | 5 +++++
> .../aarch64/build-attributes/build-attribute-define-nok.c | 5 +++++
> .../aarch64/build-attributes/build-attribute-define-ok.c | 7 +++++++
> 3 files changed, 17 insertions(+)
> create mode 100644 gcc/testsuite/gcc.target/aarch64/build-attributes/build-
> attribute-define-nok.c
> create mode 100644 gcc/testsuite/gcc.target/aarch64/build-attributes/build-
> attribute-define-ok.c
>
> diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-
> c.cc
> index c3957c762ef..de4444bacb7 100644
> --- a/gcc/config/aarch64/aarch64-c.cc
> +++ b/gcc/config/aarch64/aarch64-c.cc
> @@ -65,6 +65,11 @@ aarch64_define_unconditional_macros (cpp_reader
> *pfile)
>
> builtin_define_with_int_value ("__ARM_ARCH_PROFILE",
> TARGET_V8R ? 'R' : 'A');
> +
> +#if HAVE_AS_AEABI_BUILD_ATTRIBUTES
> + builtin_define_with_int_value ("__ARM_BUILDATTR64_FV", 'A');
> +#endif
> +
> builtin_define ("__ARM_FEATURE_CLZ");
> builtin_define ("__ARM_FEATURE_IDIV");
> builtin_define ("__ARM_FEATURE_UNALIGNED");
> diff --git
> a/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-
> define-nok.c b/gcc/testsuite/gcc.target/aarch64/build-attributes/build-
> attribute-define-nok.c
> new file mode 100644
> index 00000000000..55b9de905d3
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-
> define-nok.c
> @@ -0,0 +1,5 @@
> +/* { dg-do compile { target { aarch64*-*-linux* && { !
> aarch64_gas_has_build_attributes } } } } */
> +
> +#if defined(__ARM_BUILDATTR64_FV)
> +#error "Support for build attributes should not be enabled in this
> toolchain."
> +#endif
> diff --git
> a/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-
> define-ok.c b/gcc/testsuite/gcc.target/aarch64/build-attributes/build-
> attribute-define-ok.c
> new file mode 100644
> index 00000000000..7ecb9297bae
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/build-attributes/build-attribute-
> define-ok.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile { target { aarch64*-*-linux* && {
> aarch64_gas_has_build_attributes } } } } */
> +
> +#if ! defined(__ARM_BUILDATTR64_FV)
> +#error "Support for build attributes should be enabled in this toolchain."
> +#elif __ARM_BUILDATTR64_FV != 'A'
> +#error "The current build attributes version does not match the expected
> one."
> +#endif
> --
> 2.52.0