diff mbox series

Predefine __STRICT_ALIGN__ if STRICT_ALIGNMENT

Message ID 20240317054631.848645-1-syq@gcc.gnu.org
State New
Headers show
Series Predefine __STRICT_ALIGN__ if STRICT_ALIGNMENT | expand

Commit Message

YunQiang Su March 17, 2024, 5:46 a.m. UTC
Arm32 predefines __ARM_FEATURE_UNALIGNED if -mno-unaligned-access,
and RISC-V predefines __riscv_misaligned_avoid, while other ports
that support -mstrict-align/-mno-unaligned-access don't have such
macro, and these backend macros are only avaiable for c-family.
Note: Arm64 always predefine __ARM_FEATURE_UNALIGNED: See #111555.

Let's add a generic one.

__STRICT_ALIGN__ is used instead of __STRICT_ALIGNMENT__, due to that
the later is used by some softwares, such as lzo2, syslinux etc.

gcc
	* cppbuiltin.cc: Predefine __STRICT_ALIGNMENT__ if
	STRICT_ALIGNMENT.
---
 gcc/cppbuiltin.cc | 3 +++
 1 file changed, 3 insertions(+)

Comments

Sam James March 17, 2024, 6:04 a.m. UTC | #1
YunQiang Su <syq@gcc.gnu.org> writes:

> Arm32 predefines __ARM_FEATURE_UNALIGNED if -mno-unaligned-access,
> and RISC-V predefines __riscv_misaligned_avoid, while other ports
> that support -mstrict-align/-mno-unaligned-access don't have such
> macro, and these backend macros are only avaiable for c-family.
> Note: Arm64 always predefine __ARM_FEATURE_UNALIGNED: See #111555.

I would say tag the bug even if you're not fixing it, as it was related
enough for you to cite it.

>
> Let's add a generic one.
>
> __STRICT_ALIGN__ is used instead of __STRICT_ALIGNMENT__, due to that
> the later is used by some softwares, such as lzo2, syslinux etc.
>
> gcc
> 	* cppbuiltin.cc: Predefine __STRICT_ALIGNMENT__ if
> 	STRICT_ALIGNMENT.
> ---
>  gcc/cppbuiltin.cc | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gcc/cppbuiltin.cc b/gcc/cppbuiltin.cc
> index c4bfc2917dc..d32efdf9a07 100644
> --- a/gcc/cppbuiltin.cc
> +++ b/gcc/cppbuiltin.cc
> @@ -123,6 +123,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
>  
>    cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d",
>  			flag_finite_math_only);
> +
> +  if (STRICT_ALIGNMENT)
> +    cpp_define (pfile, "__STRICT_ALIGNMENT__");
>  }
YunQiang Su March 17, 2024, 7:27 a.m. UTC | #2
Sam James <sam@gentoo.org> 于2024年3月17日周日 14:04写道:
>
> YunQiang Su <syq@gcc.gnu.org> writes:
>
> > Arm32 predefines __ARM_FEATURE_UNALIGNED if -mno-unaligned-access,
> > and RISC-V predefines __riscv_misaligned_avoid, while other ports
> > that support -mstrict-align/-mno-unaligned-access don't have such
> > macro, and these backend macros are only avaiable for c-family.
> > Note: Arm64 always predefine __ARM_FEATURE_UNALIGNED: See #111555.
>
> I would say tag the bug even if you're not fixing it, as it was related
> enough for you to cite it.
>

I am not sure that it is a bug for aarch64. This macro may be used to
determine whether hardware can support misaligned access, and
maybe all of Aarch64 CPUs can support it.

It should be determined by ARM people.
Richard Biener March 18, 2024, 7:32 a.m. UTC | #3
On Sun, 17 Mar 2024, YunQiang Su wrote:

> Arm32 predefines __ARM_FEATURE_UNALIGNED if -mno-unaligned-access,
> and RISC-V predefines __riscv_misaligned_avoid, while other ports
> that support -mstrict-align/-mno-unaligned-access don't have such
> macro, and these backend macros are only avaiable for c-family.
> Note: Arm64 always predefine __ARM_FEATURE_UNALIGNED: See #111555.
> 
> Let's add a generic one.

STRICT_ALIGNMENT is supposed to be gone, it doesn't tell the full
truth so exposing it will cause more confusion only.  Nak.

Richard.

> __STRICT_ALIGN__ is used instead of __STRICT_ALIGNMENT__, due to that
> the later is used by some softwares, such as lzo2, syslinux etc.
> 
> gcc
> 	* cppbuiltin.cc: Predefine __STRICT_ALIGNMENT__ if
> 	STRICT_ALIGNMENT.
> ---
>  gcc/cppbuiltin.cc | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gcc/cppbuiltin.cc b/gcc/cppbuiltin.cc
> index c4bfc2917dc..d32efdf9a07 100644
> --- a/gcc/cppbuiltin.cc
> +++ b/gcc/cppbuiltin.cc
> @@ -123,6 +123,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
>  
>    cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d",
>  			flag_finite_math_only);
> +
> +  if (STRICT_ALIGNMENT)
> +    cpp_define (pfile, "__STRICT_ALIGNMENT__");
>  }
>  
>  
>
diff mbox series

Patch

diff --git a/gcc/cppbuiltin.cc b/gcc/cppbuiltin.cc
index c4bfc2917dc..d32efdf9a07 100644
--- a/gcc/cppbuiltin.cc
+++ b/gcc/cppbuiltin.cc
@@ -123,6 +123,9 @@  define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
 
   cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d",
 			flag_finite_math_only);
+
+  if (STRICT_ALIGNMENT)
+    cpp_define (pfile, "__STRICT_ALIGNMENT__");
 }