Skip to content

Commit

Permalink
gcc6: fix build with new glibc, by upstream patches
Browse files Browse the repository at this point in the history
  • Loading branch information
vcunat committed Aug 27, 2017
1 parent 5cdf7ee commit d5b65a9
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkgs/development/compilers/gcc/6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ let version = "6.4.0";
# The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
# target libraries and tools.
++ optional langAda ../gnat-cflags.patch
++ optional langFortran ../gfortran-driving.patch;
++ optional langFortran ../gfortran-driving.patch
++ [ ../struct-ucontext.patch ../struct-sigaltstack.patch ] # glibc-2.26
;

javaEcj = fetchurl {
# The `$(top_srcdir)/ecj.jar' file is automatically picked up at
Expand Down
87 changes: 87 additions & 0 deletions pkgs/development/compilers/gcc/struct-sigaltstack.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
From 72edc2c02f8b4768ad660f46a1c7e2400c0a8e06 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 17 Jul 2017 19:41:08 +0000
Subject: [PATCH] Backported from mainline 2017-07-14 Jakub
Jelinek <jakub@redhat.com>

PR sanitizer/81066
* sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969.
* sanitizer_common/sanitizer_linux.cc: Likewise.
* sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise.
* tsan/tsan_platform_linux.cc: Likewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@250287 138bc75d-0d04-0410-961f-82ee72b054a4
---
libsanitizer/ChangeLog (REMOVED) | 11 +++++++++++
libsanitizer/sanitizer_common/sanitizer_linux.cc | 3 +--
libsanitizer/sanitizer_common/sanitizer_linux.h | 4 +---
.../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc | 2 +-
libsanitizer/tsan/tsan_platform_linux.cc | 2 +-
5 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc
index 806fcd5..5b6f186 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc
@@ -605,8 +605,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
}
#endif

-uptr internal_sigaltstack(const struct sigaltstack *ss,
- struct sigaltstack *oss) {
+uptr internal_sigaltstack(const void *ss, void *oss) {
return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
}

diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.h b/libsanitizer/sanitizer_common/sanitizer_linux.h
index 895bfc1..a42df57 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux.h
+++ b/libsanitizer/sanitizer_common/sanitizer_linux.h
@@ -19,7 +19,6 @@
#include "sanitizer_platform_limits_posix.h"

struct link_map; // Opaque type returned by dlopen().
-struct sigaltstack;

namespace __sanitizer {
// Dirent structure for getdents(). Note that this structure is different from
@@ -28,8 +27,7 @@ struct linux_dirent;

// Syscall wrappers.
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
- struct sigaltstack* oss);
+uptr internal_sigaltstack(const void* ss, void* oss);
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
__sanitizer_sigset_t *oldset);

diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
index 891386dc..234e8c6 100644
--- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -273,7 +273,7 @@ static int TracerThread(void* argument) {

// Alternate stack for signal handling.
InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
- struct sigaltstack handler_stack;
+ stack_t handler_stack;
internal_memset(&handler_stack, 0, sizeof(handler_stack));
handler_stack.ss_sp = handler_stack_memory.data();
handler_stack.ss_size = kHandlerStackSize;
diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc
index 2ed5718..6f972ab 100644
--- a/libsanitizer/tsan/tsan_platform_linux.cc
+++ b/libsanitizer/tsan/tsan_platform_linux.cc
@@ -287,7 +287,7 @@ void InitializePlatform() {
int ExtractResolvFDs(void *state, int *fds, int nfd) {
#if SANITIZER_LINUX && !SANITIZER_ANDROID
int cnt = 0;
- __res_state *statp = (__res_state*)state;
+ struct __res_state *statp = (struct __res_state*)state;
for (int i = 0; i < MAXNS && cnt < nfd; i++) {
if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
fds[cnt++] = statp->_u._ext.nssocks[i];
--
2.9.3

190 changes: 190 additions & 0 deletions pkgs/development/compilers/gcc/struct-ucontext.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
From b685411208e0aaa79190d54faf945763514706b8 Mon Sep 17 00:00:00 2001
From: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 4 Jul 2017 10:23:57 +0000
Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files.

Current glibc no longer gives the ucontext_t type the tag struct
ucontext, to conform with POSIX namespace rules. This requires
various linux-unwind.h files in libgcc, that were previously using
struct ucontext, to be fixed to use ucontext_t instead. This is
similar to the removal of the struct siginfo tag from siginfo_t some
years ago.

This patch changes those files to use ucontext_t instead. As the
standard name that should be unconditionally safe, so this is not
restricted to architectures supported by glibc, or conditioned on the
glibc version.

Tested compilation together with current glibc with glibc's
build-many-glibcs.py.

* config/aarch64/linux-unwind.h (aarch64_fallback_frame_state),
config/alpha/linux-unwind.h (alpha_fallback_frame_state),
config/bfin/linux-unwind.h (bfin_fallback_frame_state),
config/i386/linux-unwind.h (x86_64_fallback_frame_state,
x86_fallback_frame_state), config/m68k/linux-unwind.h (struct
uw_ucontext), config/nios2/linux-unwind.h (struct nios2_ucontext),
config/pa/linux-unwind.h (pa32_fallback_frame_state),
config/sh/linux-unwind.h (sh_fallback_frame_state),
config/tilepro/linux-unwind.h (tile_fallback_frame_state),
config/xtensa/linux-unwind.h (xtensa_fallback_frame_state): Use
ucontext_t instead of struct ucontext.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@249957 138bc75d-0d04-0410-961f-82ee72b054a4
---
libgcc/ChangeLog (REMOVED) | 14 ++++++++++++++
libgcc/config/aarch64/linux-unwind.h | 2 +-
libgcc/config/alpha/linux-unwind.h | 2 +-
libgcc/config/bfin/linux-unwind.h | 2 +-
libgcc/config/i386/linux-unwind.h | 4 ++--
libgcc/config/m68k/linux-unwind.h | 2 +-
libgcc/config/nios2/linux-unwind.h | 2 +-
libgcc/config/pa/linux-unwind.h | 2 +-
libgcc/config/sh/linux-unwind.h | 2 +-
libgcc/config/tilepro/linux-unwind.h | 2 +-
libgcc/config/xtensa/linux-unwind.h | 2 +-
11 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h
index 4512efb..06de45a 100644
--- a/libgcc/config/aarch64/linux-unwind.h
+++ b/libgcc/config/aarch64/linux-unwind.h
@@ -52,7 +52,7 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context,
struct rt_sigframe
{
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
};

struct rt_sigframe *rt_;
diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h
index bdbba4a..e84812e 100644
--- a/libgcc/config/alpha/linux-unwind.h
+++ b/libgcc/config/alpha/linux-unwind.h
@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context,
{
struct rt_sigframe {
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *rt_ = context->cfa;
sc = &rt_->uc.uc_mcontext;
}
diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h
index 77b7c23..8bf5e82 100644
--- a/libgcc/config/bfin/linux-unwind.h
+++ b/libgcc/config/bfin/linux-unwind.h
@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context,
void *puc;
char retcode[8];
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *rt_ = context->cfa;

/* The void * cast is necessary to avoid an aliasing warning.
diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h
index 540a0a2..29efbe3 100644
--- a/libgcc/config/i386/linux-unwind.h
+++ b/libgcc/config/i386/linux-unwind.h
@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context,
if (*(unsigned char *)(pc+0) == 0x48
&& *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
{
- struct ucontext *uc_ = context->cfa;
+ ucontext_t *uc_ = context->cfa;
/* The void * cast is necessary to avoid an aliasing warning.
The aliasing warning is correct, but should not be a problem
because it does not alias anything. */
@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context,
siginfo_t *pinfo;
void *puc;
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *rt_ = context->cfa;
/* The void * cast is necessary to avoid an aliasing warning.
The aliasing warning is correct, but should not be a problem
diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h
index 75b7cf7..f964e24 100644
--- a/libgcc/config/m68k/linux-unwind.h
+++ b/libgcc/config/m68k/linux-unwind.h
@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* <sys/ucontext.h> is unfortunately broken right now. */
struct uw_ucontext {
unsigned long uc_flags;
- struct ucontext *uc_link;
+ ucontext_t *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
unsigned long uc_filler[80];
diff --git a/libgcc/config/nios2/linux-unwind.h b/libgcc/config/nios2/linux-unwind.h
index 2304142..30f25ea 100644
--- a/libgcc/config/nios2/linux-unwind.h
+++ b/libgcc/config/nios2/linux-unwind.h
@@ -38,7 +38,7 @@ struct nios2_mcontext {

struct nios2_ucontext {
unsigned long uc_flags;
- struct ucontext *uc_link;
+ ucontext_t *uc_link;
stack_t uc_stack;
struct nios2_mcontext uc_mcontext;
sigset_t uc_sigmask; /* mask last for extensibility */
diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h
index 9a2657f..e47493d 100644
--- a/libgcc/config/pa/linux-unwind.h
+++ b/libgcc/config/pa/linux-unwind.h
@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context,
struct sigcontext *sc;
struct rt_sigframe {
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *frame;

/* rt_sigreturn trampoline:
diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h
index e389cac..0bf43ba 100644
--- a/libgcc/config/sh/linux-unwind.h
+++ b/libgcc/config/sh/linux-unwind.h
@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context,
{
struct rt_sigframe {
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *rt_ = context->cfa;
/* The void * cast is necessary to avoid an aliasing warning.
The aliasing warning is correct, but should not be a problem
diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h
index 796e976..75f8890 100644
--- a/libgcc/config/tilepro/linux-unwind.h
+++ b/libgcc/config/tilepro/linux-unwind.h
@@ -61,7 +61,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context,
struct rt_sigframe {
unsigned char save_area[C_ABI_SAVE_AREA_SIZE];
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *rt_;

/* Return if this is not a signal handler. */
diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h
index 9872492..586a9d4 100644
--- a/libgcc/config/xtensa/linux-unwind.h
+++ b/libgcc/config/xtensa/linux-unwind.h
@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context,

struct rt_sigframe {
siginfo_t info;
- struct ucontext uc;
+ ucontext_t uc;
} *rt_;

/* movi a2, __NR_rt_sigreturn; syscall */
--
2.9.3

0 comments on commit d5b65a9

Please sign in to comment.