Reputation: 616
I am trying to compile gcc 6.4.0 independently with gcc 7.2 in Archlinux.
Configuration is as follows:
../configure --prefix=${INSTALL_PREFIX} --enable-languages=c,c++,fortran \
--enable-threads=posix --enable-tls --enable-libgomp --enable-lto \
--enable-shared --enable-static --disable-nls --disable-multilib \
--with-fpmath=sse
While compiling, I got the following error in md-unwind-support.h
:
md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type 'struct ucontext'
I compared md-unwind-support.h
between defined in gcc 6.4.0 and gcc 7.2.0 and found that struct ucontext
is defined as ucontext_t
in gcc 7.2.0.
So, I made some changes in md-unwind-support.h
of gcc 6.4.0 source tree but got some kine of namespace issue as follows:
int std::uncaught_exceptions() should have been declared inside 'std'
I get stuck and have no idea about this issue.
Any help and advice will be helpful.
Upvotes: 11
Views: 7716
Reputation: 616
The follwing is a patch which summerizes what I did. In short, changes are made to struct ucontext to ucontext_t and struct sigaltstack pointer to void pointer, struct sigaltstack to stack_t.
diff -urN gcc-6.3.0/libgcc/config/i386/linux-unwind.h gcc-6.3.0.new/libgcc/config/i386/linux-unwind.h
--- gcc-6.3.0/libgcc/config/i386/linux-unwind.h 2016-01-04 23:30:50.000000000 +0900
+++ gcc-6.3.0.new/libgcc/config/i386/linux-unwind.h 2017-10-29 23:01:21.717240052 +0900
@@ -58,7 +58,7 @@
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 @@
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 -urN gcc-6.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cc gcc-6.3.0.new/libsanitizer/sanitizer_common/sanitizer_linux.cc
--- gcc-6.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cc 2015-11-23 18:07:18.000000000 +0900
+++ gcc-6.3.0.new/libsanitizer/sanitizer_common/sanitizer_linux.cc 2017-10-29 23:09:00.490577558 +0900
@@ -546,8 +546,7 @@
}
#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 -urN gcc-6.3.0/libsanitizer/sanitizer_common/sanitizer_linux.h gcc-6.3.0.new/libsanitizer/sanitizer_common/sanitizer_linux.h
--- gcc-6.3.0/libsanitizer/sanitizer_common/sanitizer_linux.h 2015-10-21 16:32:45.000000000 +0900
+++ gcc-6.3.0.new/libsanitizer/sanitizer_common/sanitizer_linux.h 2017-10-29 23:09:43.907244619 +0900
@@ -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 @@
// 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);
void internal_sigfillset(__sanitizer_sigset_t *set);
diff -urN gcc-6.3.0/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc gcc-6.3.0.new/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
--- gcc-6.3.0/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc 2015-10-21 16:32:45.000000000 +0900
+++ gcc-6.3.0.new/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc 2017-10-29 23:08:07.260577074 +0900
@@ -267,7 +267,7 @@
// 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 -urN gcc-6.3.0/libsanitizer/tsan/tsan_platform_linux.cc gcc-6.3.0.new/libsanitizer/tsan/tsan_platform_linux.cc
--- gcc-6.3.0/libsanitizer/tsan/tsan_platform_linux.cc 2016-08-12 17:53:46.000000000 +0900
+++ gcc-6.3.0.new/libsanitizer/tsan/tsan_platform_linux.cc 2017-10-29 23:10:38.817245120 +0900
@@ -291,7 +291,7 @@
int ExtractResolvFDs(void *state, int *fds, int nfd) {
#if SANITIZER_LINUX
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];
Upvotes: 11
Reputation: 721
In order to have make
to work you have to modify the file make_folder/libgcc/config/i386/linux_unwind.h
where make_folder
is the folder where you type the make
command.
In linux_unwind.h
you have to change struct ucontext *uc_ = context->cfa;
on line 61 to struct ucontext_t *uc_ = context->cfa;
Thanks to Seong that told us what file to modify.
Upvotes: 13
Reputation: 616
I finally resolved issue.
I should have modified libgcc/config/i386/linux_unwind.h
instead of directly md-unwind-support.h
Upvotes: 4