https://gcc.gnu.org/g:6247a9086ca7a29ba1db9680010a319769717150
commit r16-5678-g6247a9086ca7a29ba1db9680010a319769717150 Author: Matthieu Longo <[email protected]> Date: Mon Nov 24 14:56:19 2025 +0000 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) 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. Diff: --- 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(+) diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc index c3957c762eff..de4444bacb79 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 000000000000..55b9de905d38 --- /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 000000000000..7ecb9297baed --- /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
