[v1,1/1] AArch64: Fix ODR warning for NEON intrinsics [PR126744]

Message ID 20260930145738.399070-1-karl.meakin@arm.com
State Accepted
Headers
Series [v1,1/1] AArch64: Fix ODR warning for NEON intrinsics [PR126744] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed

Commit Message

Karl Meakin Sept. 30, 2026, 2:57 p.m. UTC
  The `_shape` objects were declared in `aarch64-neon-builtins-shapes.h`
as pointer-to-const, but were defined in
`aarch64-neon-builtins-shapes.cc` as pointer-to-non-const. This
triggered an `-Wodr` warning when building with LTO, which broke
bootstrap when compiling with `-Werror`. Fix by const-qualifying the
pointer at the definition site.

Fixes PR126744.

gcc/ChangeLog:

	PR target/126744
	* config/aarch64/aarch64-neon-builtins-shapes.cc
	(DEF_NEON_FUNCTION): Include `aarch64-neon-builtins-shapes.h`
	and const-qualify the pointer types of the `_shape` objects.
---
 gcc/config/aarch64/aarch64-neon-builtins-shapes.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.51.0
  

Comments

Kyrylo Tkachov Sept. 30, 2026, 3:23 p.m. UTC | #1
> On 30 Sep 2026, at 16:57, Karl Meakin <karl.meakin@arm.com> wrote:
> 
> The `_shape` objects were declared in `aarch64-neon-builtins-shapes.h`
> as pointer-to-const, but were defined in
> `aarch64-neon-builtins-shapes.cc` as pointer-to-non-const. This
> triggered an `-Wodr` warning when building with LTO, which broke
> bootstrap when compiling with `-Werror`. Fix by const-qualifying the
> pointer at the definition site.
> 
> Fixes PR126744.

Ok. Simple patches to fix bootstrap are usually considered obvious.
Thanks,
Kyrill

> 
> gcc/ChangeLog:
> 
> PR target/126744
> * config/aarch64/aarch64-neon-builtins-shapes.cc
> (DEF_NEON_FUNCTION): Include `aarch64-neon-builtins-shapes.h`
> and const-qualify the pointer types of the `_shape` objects.
> ---
> gcc/config/aarch64/aarch64-neon-builtins-shapes.cc | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc b/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc
> index c50fb4d4f8c..d4aa352f13e 100644
> --- a/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc
> +++ b/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc
> @@ -32,6 +32,7 @@
> #include "insn-codes.h"
> #include "optabs.h"
> #include "aarch64-acle-builtins.h"
> +#include "aarch64-neon-builtins-shapes.h"
> #include "aarch64-sve-builtins-shapes.h"
> #include "aarch64-builtins.h"
> 
> @@ -129,7 +130,7 @@ namespace aarch64_acle {
>   namespace shapes {
> #define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) \
>     static constexpr const neon_shape OBJ_NAME (NAME, TYPES) SHAPE_ARGS;\
> -    const aarch64_acle::function_shape *SHAPE_NAME (NAME, TYPES) \
> +    const aarch64_acle::function_shape *const SHAPE_NAME (NAME, TYPES) \
>       = &OBJ_NAME (NAME, TYPES);
> #include "aarch64-neon-builtins.def"
>   }
> --
> 2.51.0
  

Patch

diff --git a/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc b/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc
index c50fb4d4f8c..d4aa352f13e 100644
--- a/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc
+++ b/gcc/config/aarch64/aarch64-neon-builtins-shapes.cc
@@ -32,6 +32,7 @@ 
 #include "insn-codes.h"
 #include "optabs.h"
 #include "aarch64-acle-builtins.h"
+#include "aarch64-neon-builtins-shapes.h"
 #include "aarch64-sve-builtins-shapes.h"
 #include "aarch64-builtins.h"

@@ -129,7 +130,7 @@  namespace aarch64_acle {
   namespace shapes {
 #define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS)			\
     static constexpr const neon_shape OBJ_NAME (NAME, TYPES) SHAPE_ARGS;\
-    const aarch64_acle::function_shape *SHAPE_NAME (NAME, TYPES)	\
+    const aarch64_acle::function_shape *const SHAPE_NAME (NAME, TYPES)	\
       = &OBJ_NAME (NAME, TYPES);
 #include "aarch64-neon-builtins.def"
   }