如何在Archlinux中使用gcc 7.2编译gcc 6.4.0

Seo*_*ong 6 gcc archlinux

我正在尝试使用Archlinux中的gcc 7.2独立编译gcc 6.4.0.

配置如下:

../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
Run Code Online (Sandbox Code Playgroud)

在编译时,我收到以下错误md-unwind-support.h:

md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type 'struct ucontext'
Run Code Online (Sandbox Code Playgroud)

我比较md-unwind-support.h了gcc 6.4.0和gcc 7.2.0中struct ucontext的定义,发现它定义为ucontext_tgcc 7.2.0.

所以,我md-unwind-support.h对gcc 6.4.0源代码树进行了一些更改,但得到了一些命名空间问题,如下所示:

int std::uncaught_exceptions() should have been declared inside 'std'
Run Code Online (Sandbox Code Playgroud)

我卡住了,不知道这个问题.

任何帮助和建议都会有所帮助.

小智 10

为了必须make工作,您必须修改文件make_folder/libgcc/config/i386/linux_unwind.hmake_folder哪里键入make命令的文件夹.

linux_unwind.h你必须改变struct ucontext *uc_ = context->cfa;第61行struct ucontext_t *uc_ = context->cfa;

感谢Seong告诉我们要修改哪个文件.


Seo*_*ong 6

以下是一个补丁,总结了我所做的事情。简而言之,将ucontext的结构更改为ucontext_t,将sigaltstack的结构指针更改为void指针,将sigaltstack的结构更改为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];
Run Code Online (Sandbox Code Playgroud)


Seo*_*ong 3

我终于解决了问题。我应该修改libgcc/config/i386/linux_unwind.h而不是直接md-unwind-support.h