From 6c43c6be2aa90f7ed0248e0c19e319b9cebb5af6 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 21 Dec 2019 18:18:54 -0800 Subject: compiler-rt: Fix build with glibc 2.31 Signed-off-by: Khem Raj --- ...ix-sanitizer-common-build-with-glibc-2.31.patch | 81 ++++++++++++++++++++++ recipes-devtools/clang/common.inc | 1 + 2 files changed, 82 insertions(+) create mode 100644 recipes-devtools/clang/clang/0027-Fix-sanitizer-common-build-with-glibc-2.31.patch (limited to 'recipes-devtools') diff --git a/recipes-devtools/clang/clang/0027-Fix-sanitizer-common-build-with-glibc-2.31.patch b/recipes-devtools/clang/clang/0027-Fix-sanitizer-common-build-with-glibc-2.31.patch new file mode 100644 index 0000000..4c05fc6 --- /dev/null +++ b/recipes-devtools/clang/clang/0027-Fix-sanitizer-common-build-with-glibc-2.31.patch @@ -0,0 +1,81 @@ +From 322766bb272ca8f818fe26a74ac1254a3d2b0201 Mon Sep 17 00:00:00 2001 +From: Evgenii Stepanov +Date: Mon, 25 Nov 2019 13:52:17 -0800 +Subject: [PATCH] Fix sanitizer-common build with glibc 2.31 + +Summary: +As mentioned in D69104, glibc changed ABI recently with the [[ https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2f959dfe849e0646e27403f2e4091536496ac0f0| 2f959dfe ]] change. +D69104 dealt with just 32-bit ARM, but that is just one of the many affected architectures. +E.g. x86_64, i?86, riscv64, sparc 32-bit, s390 31-bit are affected too (and various others). + +This patch instead of adding a long list of further architectures that wouldn't be checked ever next to arm 32-bit changes the structures to match the 2.31 layout and performs the checking on Linux for ipc_perm mode position/size only on non-Linux or on Linux with glibc 2.31 or later. I think this matches what is done for aarch64 already. +If needed, we could list architectures that haven't changed ABI (e.g. powerpc), so that they would be checked even with older glibcs. AFAIK sanitizers don't actually use ipc_perm.mode and +so all they care about is the size and alignment of the whole structure. + +Note, s390 31-bit and arm 32-bit big-endian changed ABI even further, there will now be shmctl with old symbol version and shmctl@@GLIBC_2.31 which will be incompatible. I'm afraid this isn't really solvable unless the sanitizer libraries are symbol versioned and use matching symbol versions to glibc symbols for stuff they intercept, plus use dlvsym. +This patch doesn't try to address that. + +Patch by Jakub Jelinek. + +Reviewers: kcc, eugenis, dvyukov + +Reviewed By: eugenis + +Subscribers: jyknight, kristof.beyls, fedor.sergeev, simoncook, PkmX, s.egerton, steven.zhang, #sanitizers, llvm-commits + +Tags: #sanitizers, #llvm + +Differential Revision: https://reviews.llvm.org/D70662 +--- + .../sanitizer_platform_limits_posix.cc | 5 +++-- + .../sanitizer_platform_limits_posix.h | 15 +-------------- + 2 files changed, 4 insertions(+), 16 deletions(-) + +diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index b7fa6e8f7e0..abdf7941b5c 100644 +--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -1126,8 +1126,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid); + CHECK_SIZE_AND_OFFSET(ipc_perm, gid); + CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); + CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); +-#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21) +-/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */ ++#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) ++/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit ++ on many architectures. */ + CHECK_SIZE_AND_OFFSET(ipc_perm, mode); + #endif + +diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +index f1a4fd7d370..029a209fc03 100644 +--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h ++++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +@@ -203,26 +203,13 @@ namespace __sanitizer { + u64 __unused1; + u64 __unused2; + #elif defined(__sparc__) +-#if defined(__arch64__) + unsigned mode; +- unsigned short __pad1; +-#else +- unsigned short __pad1; +- unsigned short mode; + unsigned short __pad2; +-#endif + unsigned short __seq; + unsigned long long __unused1; + unsigned long long __unused2; +-#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__) +- unsigned int mode; +- unsigned short __seq; +- unsigned short __pad1; +- unsigned long __unused1; +- unsigned long __unused2; + #else +- unsigned short mode; +- unsigned short __pad1; ++ unsigned int mode; + unsigned short __seq; + unsigned short __pad2; + #if defined(__x86_64__) && !defined(_LP64) diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index 0f632f8..044a9ab 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc @@ -34,6 +34,7 @@ SRC_URI = "\ file://0024-Check-for-atomic-double-intrinsics.patch \ file://0025-llvm-Let-llvm-ar-name-contain-lib.patch \ file://0026-libclang-Use-CMAKE_DL_LIBS-for-deducing-libdl.patch \ + file://0027-Fix-sanitizer-common-build-with-glibc-2.31.patch \ " # Fallback to no-PIE if not set -- cgit v1.2.3-54-g00ecf