From 5fd2126e13024f3fa8a3c21f7fab087422b262b0 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 24 Sep 2019 19:19:23 -0400 Subject: [PATCH] add patches fixing broken libgcc multi-thread detection via weak refs tested to apply successfully to all supported gcc versions except possibly 4.2.1, for which it is not added yet. --- .../0017-fix-gthr-weak-refs-for-libgcc.patch | 51 +++++++++++++++++++ .../0017-fix-gthr-weak-refs-for-libgcc.patch | 51 +++++++++++++++++++ .../0021-fix-gthr-weak-refs-for-libgcc.patch | 51 +++++++++++++++++++ .../0015-fix-gthr-weak-refs-for-libgcc.patch | 51 +++++++++++++++++++ .../0017-fix-gthr-weak-refs-for-libgcc.patch | 51 +++++++++++++++++++ .../0013-fix-gthr-weak-refs-for-libgcc.patch | 51 +++++++++++++++++++ 6 files changed, 306 insertions(+) create mode 100644 patches/gcc-5.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch create mode 100644 patches/gcc-6.4.0/0017-fix-gthr-weak-refs-for-libgcc.patch create mode 100644 patches/gcc-6.5.0/0021-fix-gthr-weak-refs-for-libgcc.patch create mode 100644 patches/gcc-7.2.0/0015-fix-gthr-weak-refs-for-libgcc.patch create mode 100644 patches/gcc-7.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch create mode 100644 patches/gcc-8.3.0/0013-fix-gthr-weak-refs-for-libgcc.patch diff --git a/patches/gcc-5.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch b/patches/gcc-5.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch new file mode 100644 index 0000000..56291a2 --- /dev/null +++ b/patches/gcc-5.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch @@ -0,0 +1,51 @@ +From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sun, 22 Sep 2019 23:04:48 +0000 +Subject: [PATCH] fix gthr weak refs for libgcc + +ideally gthr-posix.h should be fixed not to use weak refs for +single thread detection by default since that's unsafe. + +currently we have to opt out explicitly from the unsafe behaviour +in the configure machinery of each target lib that uses gthr and +musl missed libgcc previously. + +related bugs and discussions +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 +https://sourceware.org/bugzilla/show_bug.cgi?id=5784 +https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html +https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html +--- + libgcc/config.host | 7 +++++++ + libgcc/config/t-gthr-noweak | 2 ++ + 2 files changed, 9 insertions(+) + create mode 100644 libgcc/config/t-gthr-noweak + +diff --git a/libgcc/config.host b/libgcc/config.host +index 122113fc519..fe1b9ab93d5 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1500,3 +1500,10 @@ aarch64*-*-*) + tm_file="${tm_file} aarch64/value-unwind.h" + ;; + esac ++ ++case ${host} in ++*-*-musl*) ++ # The gthr weak references are unsafe with static linking ++ tmake_file="$tmake_file t-gthr-noweak" ++ ;; ++esac +diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak +new file mode 100644 +index 00000000000..45a21e9361d +--- /dev/null ++++ b/libgcc/config/t-gthr-noweak +@@ -0,0 +1,2 @@ ++# Don't use weak references for single-thread detection ++HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0 +-- +2.17.1 + diff --git a/patches/gcc-6.4.0/0017-fix-gthr-weak-refs-for-libgcc.patch b/patches/gcc-6.4.0/0017-fix-gthr-weak-refs-for-libgcc.patch new file mode 100644 index 0000000..56291a2 --- /dev/null +++ b/patches/gcc-6.4.0/0017-fix-gthr-weak-refs-for-libgcc.patch @@ -0,0 +1,51 @@ +From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sun, 22 Sep 2019 23:04:48 +0000 +Subject: [PATCH] fix gthr weak refs for libgcc + +ideally gthr-posix.h should be fixed not to use weak refs for +single thread detection by default since that's unsafe. + +currently we have to opt out explicitly from the unsafe behaviour +in the configure machinery of each target lib that uses gthr and +musl missed libgcc previously. + +related bugs and discussions +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 +https://sourceware.org/bugzilla/show_bug.cgi?id=5784 +https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html +https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html +--- + libgcc/config.host | 7 +++++++ + libgcc/config/t-gthr-noweak | 2 ++ + 2 files changed, 9 insertions(+) + create mode 100644 libgcc/config/t-gthr-noweak + +diff --git a/libgcc/config.host b/libgcc/config.host +index 122113fc519..fe1b9ab93d5 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1500,3 +1500,10 @@ aarch64*-*-*) + tm_file="${tm_file} aarch64/value-unwind.h" + ;; + esac ++ ++case ${host} in ++*-*-musl*) ++ # The gthr weak references are unsafe with static linking ++ tmake_file="$tmake_file t-gthr-noweak" ++ ;; ++esac +diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak +new file mode 100644 +index 00000000000..45a21e9361d +--- /dev/null ++++ b/libgcc/config/t-gthr-noweak +@@ -0,0 +1,2 @@ ++# Don't use weak references for single-thread detection ++HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0 +-- +2.17.1 + diff --git a/patches/gcc-6.5.0/0021-fix-gthr-weak-refs-for-libgcc.patch b/patches/gcc-6.5.0/0021-fix-gthr-weak-refs-for-libgcc.patch new file mode 100644 index 0000000..56291a2 --- /dev/null +++ b/patches/gcc-6.5.0/0021-fix-gthr-weak-refs-for-libgcc.patch @@ -0,0 +1,51 @@ +From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sun, 22 Sep 2019 23:04:48 +0000 +Subject: [PATCH] fix gthr weak refs for libgcc + +ideally gthr-posix.h should be fixed not to use weak refs for +single thread detection by default since that's unsafe. + +currently we have to opt out explicitly from the unsafe behaviour +in the configure machinery of each target lib that uses gthr and +musl missed libgcc previously. + +related bugs and discussions +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 +https://sourceware.org/bugzilla/show_bug.cgi?id=5784 +https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html +https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html +--- + libgcc/config.host | 7 +++++++ + libgcc/config/t-gthr-noweak | 2 ++ + 2 files changed, 9 insertions(+) + create mode 100644 libgcc/config/t-gthr-noweak + +diff --git a/libgcc/config.host b/libgcc/config.host +index 122113fc519..fe1b9ab93d5 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1500,3 +1500,10 @@ aarch64*-*-*) + tm_file="${tm_file} aarch64/value-unwind.h" + ;; + esac ++ ++case ${host} in ++*-*-musl*) ++ # The gthr weak references are unsafe with static linking ++ tmake_file="$tmake_file t-gthr-noweak" ++ ;; ++esac +diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak +new file mode 100644 +index 00000000000..45a21e9361d +--- /dev/null ++++ b/libgcc/config/t-gthr-noweak +@@ -0,0 +1,2 @@ ++# Don't use weak references for single-thread detection ++HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0 +-- +2.17.1 + diff --git a/patches/gcc-7.2.0/0015-fix-gthr-weak-refs-for-libgcc.patch b/patches/gcc-7.2.0/0015-fix-gthr-weak-refs-for-libgcc.patch new file mode 100644 index 0000000..56291a2 --- /dev/null +++ b/patches/gcc-7.2.0/0015-fix-gthr-weak-refs-for-libgcc.patch @@ -0,0 +1,51 @@ +From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sun, 22 Sep 2019 23:04:48 +0000 +Subject: [PATCH] fix gthr weak refs for libgcc + +ideally gthr-posix.h should be fixed not to use weak refs for +single thread detection by default since that's unsafe. + +currently we have to opt out explicitly from the unsafe behaviour +in the configure machinery of each target lib that uses gthr and +musl missed libgcc previously. + +related bugs and discussions +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 +https://sourceware.org/bugzilla/show_bug.cgi?id=5784 +https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html +https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html +--- + libgcc/config.host | 7 +++++++ + libgcc/config/t-gthr-noweak | 2 ++ + 2 files changed, 9 insertions(+) + create mode 100644 libgcc/config/t-gthr-noweak + +diff --git a/libgcc/config.host b/libgcc/config.host +index 122113fc519..fe1b9ab93d5 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1500,3 +1500,10 @@ aarch64*-*-*) + tm_file="${tm_file} aarch64/value-unwind.h" + ;; + esac ++ ++case ${host} in ++*-*-musl*) ++ # The gthr weak references are unsafe with static linking ++ tmake_file="$tmake_file t-gthr-noweak" ++ ;; ++esac +diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak +new file mode 100644 +index 00000000000..45a21e9361d +--- /dev/null ++++ b/libgcc/config/t-gthr-noweak +@@ -0,0 +1,2 @@ ++# Don't use weak references for single-thread detection ++HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0 +-- +2.17.1 + diff --git a/patches/gcc-7.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch b/patches/gcc-7.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch new file mode 100644 index 0000000..56291a2 --- /dev/null +++ b/patches/gcc-7.3.0/0017-fix-gthr-weak-refs-for-libgcc.patch @@ -0,0 +1,51 @@ +From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sun, 22 Sep 2019 23:04:48 +0000 +Subject: [PATCH] fix gthr weak refs for libgcc + +ideally gthr-posix.h should be fixed not to use weak refs for +single thread detection by default since that's unsafe. + +currently we have to opt out explicitly from the unsafe behaviour +in the configure machinery of each target lib that uses gthr and +musl missed libgcc previously. + +related bugs and discussions +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 +https://sourceware.org/bugzilla/show_bug.cgi?id=5784 +https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html +https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html +--- + libgcc/config.host | 7 +++++++ + libgcc/config/t-gthr-noweak | 2 ++ + 2 files changed, 9 insertions(+) + create mode 100644 libgcc/config/t-gthr-noweak + +diff --git a/libgcc/config.host b/libgcc/config.host +index 122113fc519..fe1b9ab93d5 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1500,3 +1500,10 @@ aarch64*-*-*) + tm_file="${tm_file} aarch64/value-unwind.h" + ;; + esac ++ ++case ${host} in ++*-*-musl*) ++ # The gthr weak references are unsafe with static linking ++ tmake_file="$tmake_file t-gthr-noweak" ++ ;; ++esac +diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak +new file mode 100644 +index 00000000000..45a21e9361d +--- /dev/null ++++ b/libgcc/config/t-gthr-noweak +@@ -0,0 +1,2 @@ ++# Don't use weak references for single-thread detection ++HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0 +-- +2.17.1 + diff --git a/patches/gcc-8.3.0/0013-fix-gthr-weak-refs-for-libgcc.patch b/patches/gcc-8.3.0/0013-fix-gthr-weak-refs-for-libgcc.patch new file mode 100644 index 0000000..56291a2 --- /dev/null +++ b/patches/gcc-8.3.0/0013-fix-gthr-weak-refs-for-libgcc.patch @@ -0,0 +1,51 @@ +From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sun, 22 Sep 2019 23:04:48 +0000 +Subject: [PATCH] fix gthr weak refs for libgcc + +ideally gthr-posix.h should be fixed not to use weak refs for +single thread detection by default since that's unsafe. + +currently we have to opt out explicitly from the unsafe behaviour +in the configure machinery of each target lib that uses gthr and +musl missed libgcc previously. + +related bugs and discussions +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 +https://sourceware.org/bugzilla/show_bug.cgi?id=5784 +https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html +https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html +--- + libgcc/config.host | 7 +++++++ + libgcc/config/t-gthr-noweak | 2 ++ + 2 files changed, 9 insertions(+) + create mode 100644 libgcc/config/t-gthr-noweak + +diff --git a/libgcc/config.host b/libgcc/config.host +index 122113fc519..fe1b9ab93d5 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1500,3 +1500,10 @@ aarch64*-*-*) + tm_file="${tm_file} aarch64/value-unwind.h" + ;; + esac ++ ++case ${host} in ++*-*-musl*) ++ # The gthr weak references are unsafe with static linking ++ tmake_file="$tmake_file t-gthr-noweak" ++ ;; ++esac +diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak +new file mode 100644 +index 00000000000..45a21e9361d +--- /dev/null ++++ b/libgcc/config/t-gthr-noweak +@@ -0,0 +1,2 @@ ++# Don't use weak references for single-thread detection ++HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0 +-- +2.17.1 +