Update removal of C++ dep to follow upstream

Also backport linux/cyclades.h removal patch
This commit is contained in:
sergesanspaille 2021-05-21 20:15:54 +02:00
parent 7290573e79
commit cb993d10ad
7 changed files with 185 additions and 148 deletions

View File

@ -1,8 +1,7 @@
From f4d4ada2e920136870468f43e0f3c1efa265f2f7 Mon Sep 17 00:00:00 2001
From 8247295860b69fd379e282c3e6315df9f700e4d8 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@redhat.com>
Date: Thu, 25 Feb 2021 14:12:57 +0100
Subject: [PATCH] [PATCH][compiler-rt] Workaround libstdc++ limitation wrt.
thread copy
Subject: [PATCH][compiler-rt] Workaround libstdc++ limitation wrt. thread copy
---
compiler-rt/lib/fuzzer/FuzzerDefs.h | 6 ++++++

View File

@ -1,8 +1,7 @@
From c85d1e10cad1fea2c43f9ec5332761d2ca725721 Mon Sep 17 00:00:00 2001
From ffd0f69c375f12f081a1a5158a02a05000b7a93c Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka@google.com>
Date: Fri, 16 Apr 2021 09:50:24 -0700
Subject: [PATCH 2/2] [PATCH][compiler-rt] Sanitizer built against glibc 2.34
doesn't work
Subject: [PATCH][compiler-rt] Sanitizer built against glibc 2.34 doesn't work
As mentioned in https://gcc.gnu.org/PR100114 , glibc starting with the
https://sourceware.org/git/?p=glibc.git;a=commit;h=6c57d320484988e87e446e2e60ce42816bf51d53

View File

@ -1,26 +0,0 @@
From d95be525ceceb5afeaa87f4de95c30ec664b17d3 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@redhat.com>
Date: Tue, 11 May 2021 14:38:21 +0200
Subject: [PATCH][compiler-rt] Do not introduce a dependency on c++ runtime
That's at the expense of a runtime overhead though.
---
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
index 2b10bdd..240e6b3e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -167,7 +167,7 @@ bool SupportsColoredOutput(fd_t fd) {
// TODO(glider): different tools may require different altstack size.
static uptr GetAltStackSize() {
// SIGSTKSZ is not enough.
- static const uptr kAltStackSize = SIGSTKSZ * 4;
+ const uptr kAltStackSize = SIGSTKSZ * 4;
return kAltStackSize;
}
--
1.8.3.1

View File

@ -0,0 +1,54 @@
From 96339090681ae1dd9afe186ea14a460b61794707 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@redhat.com>
Date: Tue, 11 May 2021 14:38:21 +0200
Subject: [PATCH][compiler-rt] Prevent introduction of a dependency of
libasan.a on libstdc++
This an attempt to fix an issue introduced by https://reviews.llvm.org/D70662
Function-scope static initialization are guarded in C++, so we should probably
not use it because it introduces a dependency on __cxa_guard* symbols.
In the context of clang, libasan is linked statically, and it currently needs to
the odd situation where compiling C code with clang and asan requires -lstdc++.
I'm unsure of the portability requirements, providing a potential solution in
this review.
Differential Revision: https://reviews.llvm.org/D102475
---
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
index 2b10bdd..818f1af 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -15,6 +15,7 @@
#if SANITIZER_POSIX
+#include "sanitizer_atomic.h"
#include "sanitizer_common.h"
#include "sanitizer_flags.h"
#include "sanitizer_platform_limits_netbsd.h"
@@ -166,9 +167,14 @@ bool SupportsColoredOutput(fd_t fd) {
#if !SANITIZER_GO
// TODO(glider): different tools may require different altstack size.
static uptr GetAltStackSize() {
- // SIGSTKSZ is not enough.
- static const uptr kAltStackSize = SIGSTKSZ * 4;
- return kAltStackSize;
+ static atomic_uintptr_t kAltStackSize{0};
+ uptr ret = atomic_load(&kAltStackSize, memory_order_relaxed);
+ if (ret == 0) {
+ // SIGSTKSZ is not enough.
+ ret = SIGSTKSZ * 4;
+ atomic_store(&kAltStackSize, ret, memory_order_relaxed);
+ }
+ return ret;
}
void SetAlternateSignalStack() {
--
1.8.3.1

View File

@ -0,0 +1,120 @@
From c9a8c70be89cfa62aa51862f4c8e0fa4c50134d2 Mon Sep 17 00:00:00 2001
From: Tamar Christina <tamar.christina@arm.com>
Date: Thu, 20 May 2021 18:55:11 +0100
Subject: [PATCH][compiler-rt] libsanitizer: Remove cyclades inclusion in
sanitizer
The Linux kernel has removed the interface to cyclades from
the latest kernel headers[1] due to them being orphaned for the
past 13 years.
libsanitizer uses this header when compiling against glibc, but
glibcs itself doesn't seem to have any references to cyclades.
Further more it seems that the driver is broken in the kernel and
the firmware doesn't seem to be available anymore.
As such since this is breaking the build of libsanitizer (and so the
GCC bootstrap[2]) I propose to remove this.
[1] https://lkml.org/lkml/2021/3/2/153
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100379
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D102059
(cherry picked from commit 68d5235cb58f988c71b403334cd9482d663841ab)
---
.../sanitizer_common/sanitizer_common_interceptors_ioctl.inc | 9 ---------
.../lib/sanitizer_common/sanitizer_platform_limits_posix.cpp | 11 -----------
.../lib/sanitizer_common/sanitizer_platform_limits_posix.h | 10 ----------
3 files changed, 30 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
index 7f18125..b7da659 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
@@ -370,15 +370,6 @@ static void ioctl_table_fill() {
#if SANITIZER_GLIBC
// _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
- _(CYGETDEFTHRESH, WRITE, sizeof(int));
- _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
- _(CYGETMON, WRITE, struct_cyclades_monitor_sz);
- _(CYGETTHRESH, WRITE, sizeof(int));
- _(CYGETTIMEOUT, WRITE, sizeof(int));
- _(CYSETDEFTHRESH, NONE, 0);
- _(CYSETDEFTIMEOUT, NONE, 0);
- _(CYSETTHRESH, NONE, 0);
- _(CYSETTIMEOUT, NONE, 0);
_(EQL_EMANCIPATE, WRITE, struct_ifreq_sz);
_(EQL_ENSLAVE, WRITE, struct_ifreq_sz);
_(EQL_GETMASTRCFG, WRITE, struct_ifreq_sz);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index 12dd39e..7abaeb8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -143,7 +143,6 @@ typedef struct user_fpregs elf_fpregset_t;
# include <sys/procfs.h>
#endif
#include <sys/user.h>
-#include <linux/cyclades.h>
#include <linux/if_eql.h>
#include <linux/if_plip.h>
#include <linux/lp.h>
@@ -459,7 +458,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
#if SANITIZER_GLIBC
unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
- unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
#if EV_VERSION > (0x010000)
unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
#else
@@ -823,15 +821,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
#endif // SANITIZER_LINUX
#if SANITIZER_LINUX && !SANITIZER_ANDROID
- unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
- unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
- unsigned IOCTL_CYGETMON = CYGETMON;
- unsigned IOCTL_CYGETTHRESH = CYGETTHRESH;
- unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT;
- unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH;
- unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT;
- unsigned IOCTL_CYSETTHRESH = CYSETTHRESH;
- unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT;
unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE;
unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE;
unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG;
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 836b178..8a156b7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -983,7 +983,6 @@ extern unsigned struct_vt_mode_sz;
#if SANITIZER_LINUX && !SANITIZER_ANDROID
extern unsigned struct_ax25_parms_struct_sz;
-extern unsigned struct_cyclades_monitor_sz;
extern unsigned struct_input_keymap_entry_sz;
extern unsigned struct_ipx_config_data_sz;
extern unsigned struct_kbdiacrs_sz;
@@ -1328,15 +1327,6 @@ extern unsigned IOCTL_VT_WAITACTIVE;
#endif // SANITIZER_LINUX
#if SANITIZER_LINUX && !SANITIZER_ANDROID
-extern unsigned IOCTL_CYGETDEFTHRESH;
-extern unsigned IOCTL_CYGETDEFTIMEOUT;
-extern unsigned IOCTL_CYGETMON;
-extern unsigned IOCTL_CYGETTHRESH;
-extern unsigned IOCTL_CYGETTIMEOUT;
-extern unsigned IOCTL_CYSETDEFTHRESH;
-extern unsigned IOCTL_CYSETDEFTIMEOUT;
-extern unsigned IOCTL_CYSETTHRESH;
-extern unsigned IOCTL_CYSETTIMEOUT;
extern unsigned IOCTL_EQL_EMANCIPATE;
extern unsigned IOCTL_EQL_ENSLAVE;
extern unsigned IOCTL_EQL_GETMASTRCFG;
--
1.8.3.1

View File

@ -1,113 +0,0 @@
Index: compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
===================================================================
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
@@ -370,6 +370,7 @@
#if SANITIZER_GLIBC
// _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
+#if SANITIZER_LINUX_CYCLADES
_(CYGETDEFTHRESH, WRITE, sizeof(int));
_(CYGETDEFTIMEOUT, WRITE, sizeof(int));
_(CYGETMON, WRITE, struct_cyclades_monitor_sz);
@@ -379,6 +380,7 @@
_(CYSETDEFTIMEOUT, NONE, 0);
_(CYSETTHRESH, NONE, 0);
_(CYSETTIMEOUT, NONE, 0);
+#endif
_(EQL_EMANCIPATE, WRITE, struct_ifreq_sz);
_(EQL_ENSLAVE, WRITE, struct_ifreq_sz);
_(EQL_GETMASTRCFG, WRITE, struct_ifreq_sz);
Index: compiler-rt/lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -390,4 +390,17 @@
#define SANITIZER_SUPPORTS_INIT_FOR_DLOPEN 0
#endif
+// Kernel has removed this header, as such check for it's existance
+// before trying to include defines from it.
+// https://lkml.org/lkml/2021/3/2/153
+#ifdef __has_include
+# if __has_include(<linux/cyclades.h>) && !SANITIZER_ANDROID
+# define SANITIZER_LINUX_CYCLADES 1
+# else
+# define SANITIZER_LINUX_CYCLADES 0
+# endif
+#else
+# define SANITIZER_LINUX_CYCLADES 0
+#endif
+
#endif // SANITIZER_PLATFORM_H
Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
===================================================================
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -983,7 +983,9 @@
#if SANITIZER_LINUX && !SANITIZER_ANDROID
extern unsigned struct_ax25_parms_struct_sz;
+#if SANITIZER_LINUX_CYCLADES
extern unsigned struct_cyclades_monitor_sz;
+#endif
extern unsigned struct_input_keymap_entry_sz;
extern unsigned struct_ipx_config_data_sz;
extern unsigned struct_kbdiacrs_sz;
@@ -1328,6 +1330,7 @@
#endif // SANITIZER_LINUX
#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX_CYCLADES
extern unsigned IOCTL_CYGETDEFTHRESH;
extern unsigned IOCTL_CYGETDEFTIMEOUT;
extern unsigned IOCTL_CYGETMON;
@@ -1337,6 +1340,7 @@
extern unsigned IOCTL_CYSETDEFTIMEOUT;
extern unsigned IOCTL_CYSETTHRESH;
extern unsigned IOCTL_CYSETTIMEOUT;
+#endif
extern unsigned IOCTL_EQL_EMANCIPATE;
extern unsigned IOCTL_EQL_ENSLAVE;
extern unsigned IOCTL_EQL_GETMASTRCFG;
Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
===================================================================
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -143,7 +143,9 @@
# include <sys/procfs.h>
#endif
#include <sys/user.h>
-#include <linux/cyclades.h>
+#if SANITIZER_LINUX_CYCLADES
+# include <linux/cyclades.h>
+#endif
#include <linux/if_eql.h>
#include <linux/if_plip.h>
#include <linux/lp.h>
@@ -460,7 +462,9 @@
#if SANITIZER_GLIBC
unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+#if SANITIZER_LINUX_CYCLADES
unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+#endif
#if EV_VERSION > (0x010000)
unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
#else
@@ -824,6 +828,7 @@
#endif // SANITIZER_LINUX
#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX_CYCLADES
unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
unsigned IOCTL_CYGETMON = CYGETMON;
@@ -833,6 +838,7 @@
unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT;
unsigned IOCTL_CYSETTHRESH = CYSETTHRESH;
unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT;
+#endif
unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE;
unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE;
unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG;

View File

@ -10,7 +10,7 @@
Name: compiler-rt
Version: 12.0.0%{?rc_ver:~rc%{rc_ver}}
Release: 2%{?dist}
Release: 3%{?dist}
Summary: LLVM "compiler-rt" runtime libraries
License: NCSA or MIT
@ -21,8 +21,8 @@ Source2: tstellar-gpg-key.asc
Patch0: 0001-PATCH-compiler-rt-Workaround-libstdc-limitation-wrt..patch
Patch1: 0002-PATCH-compiler-rt-Sanitizer-built-against-glibc-2.34.patch
Patch2: D102059.diff
Patch3: 0003-PATCH-compiler-rt-Do-not-introduce-a-dependency-on-c.patch
Patch3: 0003-PATCH-compiler-rt-Prevent-introduction-of-a-dependen.patch
Patch4: 0004-PATCH-compiler-rt-libsanitizer-Remove-cyclades-inclu.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -112,6 +112,10 @@ popd
%endif
%changelog
* Fri May 21 2021 sguelton@redhat.com - 12.0.0-3
- Update removal of C++ dep to follow upstream
- Backport linux/cyclade.h removal patch
* Mon May 10 2021 sguelton@redhat.com - 12.0.0-2
- Backport 82150606fb11d28813ae6