0017-fix-gthr-weak-refs-for-libgcc.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 51a354a0fb54165d505bfed9819c0440027312d9 Mon Sep 17 00:00:00 2001
  2. From: Szabolcs Nagy <[email protected]>
  3. Date: Sun, 22 Sep 2019 23:04:48 +0000
  4. Subject: [PATCH] fix gthr weak refs for libgcc
  5. ideally gthr-posix.h should be fixed not to use weak refs for
  6. single thread detection by default since that's unsafe.
  7. currently we have to opt out explicitly from the unsafe behaviour
  8. in the configure machinery of each target lib that uses gthr and
  9. musl missed libgcc previously.
  10. related bugs and discussions
  11. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017
  12. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189
  13. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737
  14. https://sourceware.org/bugzilla/show_bug.cgi?id=5784
  15. https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html
  16. https://sourceware.org/ml/libc-alpha/2019-08/msg00438.html
  17. ---
  18. libgcc/config.host | 7 +++++++
  19. libgcc/config/t-gthr-noweak | 2 ++
  20. 2 files changed, 9 insertions(+)
  21. create mode 100644 libgcc/config/t-gthr-noweak
  22. diff --git a/libgcc/config.host b/libgcc/config.host
  23. index 122113fc519..fe1b9ab93d5 100644
  24. --- a/libgcc/config.host
  25. +++ b/libgcc/config.host
  26. @@ -1500,3 +1500,10 @@ aarch64*-*-*)
  27. tm_file="${tm_file} aarch64/value-unwind.h"
  28. ;;
  29. esac
  30. +
  31. +case ${host} in
  32. +*-*-musl*)
  33. + # The gthr weak references are unsafe with static linking
  34. + tmake_file="$tmake_file t-gthr-noweak"
  35. + ;;
  36. +esac
  37. diff --git a/libgcc/config/t-gthr-noweak b/libgcc/config/t-gthr-noweak
  38. new file mode 100644
  39. index 00000000000..45a21e9361d
  40. --- /dev/null
  41. +++ b/libgcc/config/t-gthr-noweak
  42. @@ -0,0 +1,2 @@
  43. +# Don't use weak references for single-thread detection
  44. +HOST_LIBGCC2_CFLAGS += -DGTHREAD_USE_WEAK=0
  45. --
  46. 2.17.1