Issue 55499
Summary libsantizer static_assert when compiling for mips64
Labels new issue
Assignees
Reporter cpackham
    Hi

I've come over from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105614 and https://github.com/crosstool-ng/crosstool-ng/issues/1733.

We've had a bug report of GCCs libsanitizer triggering the following static_assert
```
[ALL  ]    In file included from /home/ctng/crosstool-ng/.build/mips64-unknown-linux-gnu/src/gcc/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp:21:                                                                                                         
[ERROR]    /home/ctng/crosstool-ng/.build/mips64-unknown-linux-gnu/src/gcc/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp:75:38: error: static assertion failed                                                                                             
[ALL  ]       75 | COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));                                                                                                                                                                                               
[ALL  ]          |                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~               
[ALL  ]    /home/ctng/crosstool-ng/.build/mips64-unknown-linux-gnu/src/gcc/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:332:44: note: in definition of macro 'COMPILER_CHECK'                                                                                       
[ALL  ]      332 | #define COMPILER_CHECK(pred) static_assert(pred, "")                           
[ALL  ]          |                                            ^~~~                                                                                                                                                                                                             
[ERROR]    make[5]: *** [Makefile:615: sanitizer_platform_limits_linux.lo] Error 1                                                                                                                                                                                             
[ERROR]    make[5]: *** Waiting for unfinished jobs....                                                                                
```
I reported it to GCC and was directed here

If I follow the Linux code correctly (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/mips/include/uapi/asm/stat.h) we end up with `sizeof(struct stat) == 144` for `_MIPS_SIM_NABI32`/`_MIPS_SIM_ABI32` and `sizeof(struct stat) == 104` for `_MIPS_SIM_ABI64`,

GCC's libsanitizer has 
```
#elif defined(__mips__)
const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID
                                           ? FIRST_32_SECOND_64(104, 128)
                                           : FIRST_32_SECOND_64(144, 216);
const unsigned struct_kernel_stat64_sz = 104;
```

LLVM's compiler-rt/lib/sanitizer_common has
```
#elif defined(__mips__)
const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID
                                           ? FIRST_32_SECOND_64(104, 128)
                                           : FIRST_32_SECOND_64(160, 216);
const unsigned struct_kernel_stat64_sz = 104;
```
Somewhere GCC and LLVM diverged. Both appear to be incorrect for mips64 and LLVM looks like it's incorrect for mips32.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to