diff mbox series

[for-next,03/11] package/gcc: disable libsanitizer for mips64{el} w/ n32 ABI

Message ID 20220529131811.481017-3-romain.naour@gmail.com
State Superseded
Headers show
Series [for-next,01/11] arch/Config.in.riscv: add Zicsr and Zifencei standalone extensions | expand

Commit Message

Romain Naour May 29, 2022, 1:18 p.m. UTC
libsanitizer has been enabled for mips64{el} in gcc 12 [1] but it
fail to build when n32 ABI is used:

In file included from output/mips64el-buildroot-linux-gnu/sysroot/usr/include/bits/stat.h:25,
                 from output/mips64el-buildroot-linux-gnu/sysroot/usr/include/fcntl.h:78,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_linux.cpp:55:
output/mips64el-buildroot-linux-gnu/sysroot/usr/include/bits/struct_stat.h:190:8: error: redefinition of ‘struct stat64’
  190 | struct stat64
      |        ^~~~~~

In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_linux.cpp:49:
output/mips64el-buildroot-linux-gnu/sysroot/usr/include/asm/stat.h:52:8: note: previous definition of ‘struct stat64’
   52 | struct stat64 {
      |        ^~~~~~

Disable libsanitizer for mips64 with n32 ABI.

Note: Only glibc toolchains are affected since libsanitizer is
disabled for musl and uClibc-ng toolchains [2].

Fixes:
https://gitlab.com/kubu93/toolchains-builder/-/jobs/2510178651

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=344e6f9f2abcff9b2bb4b26b693be4a599272f43
[2] https://git.buildroot.net/buildroot/commit/?id=5f4d658d888b539de9a6247ae5b1a0999de5d4ec

Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
 package/gcc/gcc.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Thomas Petazzoni July 23, 2022, 12:41 p.m. UTC | #1
On Sun, 29 May 2022 15:18:03 +0200
Romain Naour <romain.naour@gmail.com> wrote:

> libsanitizer has been enabled for mips64{el} in gcc 12 [1] but it
> fail to build when n32 ABI is used:
> 
> In file included from output/mips64el-buildroot-linux-gnu/sysroot/usr/include/bits/stat.h:25,
>                  from output/mips64el-buildroot-linux-gnu/sysroot/usr/include/fcntl.h:78,
>                  from ../../../../libsanitizer/sanitizer_common/sanitizer_linux.cpp:55:
> output/mips64el-buildroot-linux-gnu/sysroot/usr/include/bits/struct_stat.h:190:8: error: redefinition of ‘struct stat64’
>   190 | struct stat64
>       |        ^~~~~~
> 
> In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_linux.cpp:49:
> output/mips64el-buildroot-linux-gnu/sysroot/usr/include/asm/stat.h:52:8: note: previous definition of ‘struct stat64’
>    52 | struct stat64 {
>       |        ^~~~~~
> 
> Disable libsanitizer for mips64 with n32 ABI.
> 
> Note: Only glibc toolchains are affected since libsanitizer is
> disabled for musl and uClibc-ng toolchains [2].
> 
> Fixes:
> https://gitlab.com/kubu93/toolchains-builder/-/jobs/2510178651
> 
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=344e6f9f2abcff9b2bb4b26b693be4a599272f43
> [2] https://git.buildroot.net/buildroot/commit/?id=5f4d658d888b539de9a6247ae5b1a0999de5d4ec

Has this issue been reported to upstream gcc?

>  package/gcc/gcc.mk | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
> index b940327c83..e1f3935e56 100644
> --- a/package/gcc/gcc.mk
> +++ b/package/gcc/gcc.mk
> @@ -138,6 +138,13 @@ ifeq ($(BR2_sparc)$(BR2_sparc64),y)
>  HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
>  endif
>  
> +# libsanitizer is available for mips64{el} since gcc 12 but fail to build
> +# with n32 ABI due to struct stat64 definition clash due to mixing
> +# kernel and user headers.
> +ifeq ($(BR2_mips64)$(BR2_mips64el)$(BR2_MIPS_NABI32),yy)

Minor nit, perhaps:

ifeq ($(BR2_mips64)$(BR2_mips64el):$(BR2_MIPS_NABI32),y:y)

so it's absolutely clear how this works.

Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
index b940327c83..e1f3935e56 100644
--- a/package/gcc/gcc.mk
+++ b/package/gcc/gcc.mk
@@ -138,6 +138,13 @@  ifeq ($(BR2_sparc)$(BR2_sparc64),y)
 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
 endif
 
+# libsanitizer is available for mips64{el} since gcc 12 but fail to build
+# with n32 ABI due to struct stat64 definition clash due to mixing
+# kernel and user headers.
+ifeq ($(BR2_mips64)$(BR2_mips64el)$(BR2_MIPS_NABI32),yy)
+HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
+endif
+
 # The logic in libbacktrace/configure.ac to detect if __sync builtins
 # are available assumes they are as soon as target_subdir is not
 # empty, i.e when cross-compiling. However, some platforms do not have