Skip to content

Commit ce44640

Browse files
[sanitizer] Add type __sanitizer::ssize (llvm#116957)
Since the sanitizer merge in commit r15-5164-gfa321004f3f628 of GCC which entails LLVM commit 61a6439, GCCs bootstrap is broken on s390 -m31. This is due to commit ec68dc1 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. ``` #if defined(__s390__) && !defined(__s390x__) typedef long ssize; #else typedef sptr ssize; #endif #define SSIZE_T __sanitizer::ssize ```
1 parent ae5fdae commit ce44640

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler-rt/lib/interception/interception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#endif
3838

3939
#define SIZE_T __sanitizer::usize
40-
#define SSIZE_T __sanitizer::sptr
40+
#define SSIZE_T __sanitizer::ssize
4141
typedef __sanitizer::sptr PTRDIFF_T;
4242
typedef __sanitizer::s64 INTMAX_T;
4343
typedef __sanitizer::u64 UINTMAX_T;

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ typedef __SIZE_TYPE__ usize;
203203
typedef uptr usize;
204204
#endif
205205

206+
#if defined(__s390__) && !defined(__s390x__)
207+
typedef long ssize;
208+
#else
209+
typedef sptr ssize;
210+
#endif
211+
206212
typedef u64 tid_t;
207213

208214
// ----------- ATTENTION -------------

0 commit comments

Comments
 (0)