GCCcore-6.4.0_fix-sanitizer_linux.patch 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. The following error was encountered when building GCCcore-6.4.0:
  2. ../../../../libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: In function ‘int __sanitizer::TracerThread(void*)’:
  3. ../../../../libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:270:22: error: aggregate ‘sigaltstack handler_stack’ has incomplete type and cannot be defined
  4. struct sigaltstack handler_stack;
  5. This happened due to a glibc patch: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=7553131847151d04d58a02300673f13d73861cbb
  6. The bug was been fixed upstream and was cherry picked in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066 back to 6.4.0.
  7. Patch taken from: https://github.com/gcc-mirror/gcc/commit/72edc2c02f8b4768ad660f46a1c7e2400c0a8e06.patch
  8. From 72edc2c02f8b4768ad660f46a1c7e2400c0a8e06 Mon Sep 17 00:00:00 2001
  9. From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
  10. Date: Mon, 17 Jul 2017 19:41:08 +0000
  11. Subject: [PATCH] Backported from mainline 2017-07-14 Jakub
  12. Jelinek <jakub@redhat.com>
  13. PR sanitizer/81066
  14. * sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969.
  15. * sanitizer_common/sanitizer_linux.cc: Likewise.
  16. * sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise.
  17. * tsan/tsan_platform_linux.cc: Likewise.
  18. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@250287 138bc75d-0d04-0410-961f-82ee72b054a4
  19. ---
  20. libsanitizer/ChangeLog | 11 +++++++++++
  21. libsanitizer/sanitizer_common/sanitizer_linux.cc | 3 +--
  22. libsanitizer/sanitizer_common/sanitizer_linux.h | 4 +---
  23. .../sanitizer_stoptheworld_linux_libcdep.cc | 2 +-
  24. libsanitizer/tsan/tsan_platform_linux.cc | 2 +-
  25. 5 files changed, 15 insertions(+), 7 deletions(-)
  26. diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc
  27. index 806fcd5e2847..5b6f18602e7d 100644
  28. --- a/libsanitizer/sanitizer_common/sanitizer_linux.cc
  29. +++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc
  30. @@ -605,8 +605,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
  31. }
  32. #endif
  33. -uptr internal_sigaltstack(const struct sigaltstack *ss,
  34. - struct sigaltstack *oss) {
  35. +uptr internal_sigaltstack(const void *ss, void *oss) {
  36. return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
  37. }
  38. diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.h b/libsanitizer/sanitizer_common/sanitizer_linux.h
  39. index 895bfc18195c..a42df5764052 100644
  40. --- a/libsanitizer/sanitizer_common/sanitizer_linux.h
  41. +++ b/libsanitizer/sanitizer_common/sanitizer_linux.h
  42. @@ -19,7 +19,6 @@
  43. #include "sanitizer_platform_limits_posix.h"
  44. struct link_map; // Opaque type returned by dlopen().
  45. -struct sigaltstack;
  46. namespace __sanitizer {
  47. // Dirent structure for getdents(). Note that this structure is different from
  48. @@ -28,8 +27,7 @@ struct linux_dirent;
  49. // Syscall wrappers.
  50. uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
  51. -uptr internal_sigaltstack(const struct sigaltstack* ss,
  52. - struct sigaltstack* oss);
  53. +uptr internal_sigaltstack(const void* ss, void* oss);
  54. uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
  55. __sanitizer_sigset_t *oldset);
  56. diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
  57. index 891386dc0ba7..234e8c652c67 100644
  58. --- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
  59. +++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
  60. @@ -273,7 +273,7 @@ static int TracerThread(void* argument) {
  61. // Alternate stack for signal handling.
  62. InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
  63. - struct sigaltstack handler_stack;
  64. + stack_t handler_stack;
  65. internal_memset(&handler_stack, 0, sizeof(handler_stack));
  66. handler_stack.ss_sp = handler_stack_memory.data();
  67. handler_stack.ss_size = kHandlerStackSize;
  68. diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc
  69. index 2ed5718a12e3..6f972ab0dd64 100644
  70. --- a/libsanitizer/tsan/tsan_platform_linux.cc
  71. +++ b/libsanitizer/tsan/tsan_platform_linux.cc
  72. @@ -287,7 +287,7 @@ void InitializePlatform() {
  73. int ExtractResolvFDs(void *state, int *fds, int nfd) {
  74. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  75. int cnt = 0;
  76. - __res_state *statp = (__res_state*)state;
  77. + struct __res_state *statp = (struct __res_state*)state;
  78. for (int i = 0; i < MAXNS && cnt < nfd; i++) {
  79. if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
  80. fds[cnt++] = statp->_u._ext.nssocks[i];