https://gcc.gnu.org/g:1bd03564f29dc31e67e67efd93137d50fa7bb8a4

commit r15-6606-g1bd03564f29dc31e67e67efd93137d50fa7bb8a4
Author: Stefan Schulze Frielinghaus <stefa...@gcc.gnu.org>
Date:   Mon Jan 6 19:17:09 2025 +0100

    Add type __sanitizer::ssize (#116957)
    
    Since the sanitizer merge in commit r15-5164-gfa321004f3f628 of GCC
    which entails LLVM commit 61a6439f35b6de28ff4aff4450d6fca970292fd5, GCCs
    bootstrap is broken on s390 -m31. This is due to commit
    ec68dc1ca4d967b599f1202855917d5ec9cae52f which introduces stricter type
    checking which is why GCC bootstrap fails with
    
    ```
    In file included from /gcc/src/libsanitizer/interception/interception.h:18,
                     from 
/gcc/src/libsanitizer/interception/interception_type_test.cpp:14:
    /gcc/src/libsanitizer/interception/interception_type_test.cpp:30:61: error: 
static assertion failed
       30 | COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value));
          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
    /gcc/src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:363:44: 
note: in definition of macro 'COMPILER_CHECK'
      363 | #define COMPILER_CHECK(pred) static_assert(pred, "")
          |                                            ^~~~
    make[8]: *** [Makefile:469: interception_type_test.lo] Error 1
    ```
    
    The culprit seems to be that we don't check for equality of type sizes
    anymore but rather whether the types are indeed the same. On s390 -m31
    we have that `sizeof(int)==sizeof(long)` holds which is why previously
    the checks succeeded. They fail now because
    
    ```
    size_t      => unsigned long
    ssize_t     => long
    ptrdiff_t   => int
    ::SSIZE_T   => __sanitizer::sptr => int
    ::PTRDIFF_T => __sanitizer::sptr => int
    ```
    
    This is fixed by mapping `SSIZE_T` to `long` in the end.
    
    ```
    typedef long ssize;
    typedef sptr ssize;
    
    ```
    
    Cherry picked from LLVM commit ce44640fe29550461120d22b0358e6cac4aed822.
    
    libsanitizer/ChangeLog:
    
            PR sanitizer/117725
            * interception/interception.h: Cherry picked from LLVM commit
            ce44640fe29550461120d22b0358e6cac4aed822.
            * sanitizer_common/sanitizer_internal_defs.h: Ditto.

Diff:
---
 libsanitizer/interception/interception.h                | 2 +-
 libsanitizer/sanitizer_common/sanitizer_internal_defs.h | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libsanitizer/interception/interception.h 
b/libsanitizer/interception/interception.h
index 0580d97edda6..3cb6b446638e 100644
--- a/libsanitizer/interception/interception.h
+++ b/libsanitizer/interception/interception.h
@@ -37,7 +37,7 @@
 #endif
 
 #define SIZE_T __sanitizer::usize
-#define SSIZE_T __sanitizer::sptr
+#define SSIZE_T __sanitizer::ssize
 typedef __sanitizer::sptr    PTRDIFF_T;
 typedef __sanitizer::s64     INTMAX_T;
 typedef __sanitizer::u64     UINTMAX_T;
diff --git a/libsanitizer/sanitizer_common/sanitizer_internal_defs.h 
b/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
index 9208b12552ff..fff60c96f632 100644
--- a/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
+++ b/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
@@ -203,6 +203,12 @@ typedef __SIZE_TYPE__ usize;
 typedef uptr usize;
 #endif
 
+#if defined(__s390__) && !defined(__s390x__)
+typedef long ssize;
+#else
+typedef sptr ssize;
+#endif
+
 typedef u64 tid_t;
 
 // ----------- ATTENTION -------------

Reply via email to