Ticket #54215: gcc7-buildfix+abi-variants+safepatches-p3.diff

File gcc7-buildfix+abi-variants+safepatches-p3.diff, 13.9 KB (added by ccorn, 7 years ago)

gcc7 build fix, ABI-related variants, plus another couple of Darwin-specific patches which look like they cannot break anything.

  • lang/gcc7/Portfile

    diff --git a/lang/gcc7/Portfile b/lang/gcc7/Portfile
    index e8d81c71a4..3fd39c1fb9 100644
    a b license_noconflict gmp mpfr ppl libmpc 
    4646
    4747set major           [lindex [split ${version} .-] 0]
    4848
     49platform darwin powerpc {
     50    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80865
     51    # https://gcc.gnu.org/ml/gcc-testresults/2017-01/msg02971.html
     52    patchfiles-append         patch-darwin-ppc-2017-01-msg02971.diff
     53}
     54
    4955platform darwin {
    5056    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
    5157
    5258    # see https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00672.html
    5359    patchfiles-append         patch-float128.diff
     60    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81033
     61    patchfiles-append         patch-249926conservative-darwin.c.diff
     62    patchfiles-append         patch-81033-8-darwin.c.diff
    5463}
    5564
    5665configure.dir       ${workpath}/build
    select.file ${filespath}/mp-${name} 
    254263
    255264}
    256265
     266# There may be incompatibilities between the native C++ runtime
     267# and the newer g++ runtimes, particularly related to exception handling.
     268# Use one or both of +defaultabi4 and +staticlibgcc.
     269# The first tries to establish compatibility with older ABIs,
     270# the second tries to make both ABIs coexist peacefully.
     271variant defaultabi4 description "Use gcc4 compatible ABI" {
     272    configure.args-append --with-default-libstdcxx-abi=gcc4-compatible
     273}
     274variant staticlibgcc description {Always use -static-libgcc to prevent ABI clashes} {
     275    patchfiles-append   force-static-gcc.patch
     276}
     277platform darwin {
     278    if {${os.major} < 13} {
     279        if {![variant_isset staticlibgcc]} {
     280            default_variants +defaultabi4
     281        }
     282    }
     283}
    257284platform powerpc {
    258285    configure.universal_archs ppc ppc64
    259286}
  • new file lang/gcc7/files/force-static-gcc.patch

    diff --git a/lang/gcc7/files/force-static-gcc.patch b/lang/gcc7/files/force-static-gcc.patch
    new file mode 100644
    index 0000000000..af4d4b7901
    - +  
     1--- gcc/config/darwin.h.orig    2012-09-13 20:20:33.000000000 -0700
     2+++ gcc/config/darwin.h 2012-09-13 20:23:03.000000000 -0700
     3@@ -343,17 +343,6 @@ extern GTY(()) int darwin_ms_struct;
     4 #undef REAL_LIBGCC_SPEC
     5 #define REAL_LIBGCC_SPEC                                                  \
     6-   "%{static-libgcc|static: -lgcc_eh -lgcc;                               \
     7-      shared-libgcc|fexceptions|fgnu-runtime:                             \
     8-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)       \
     9-       %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
     10-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)     \
     11-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)     \
     12-       -lgcc ;                                                            \
     13-      :%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
     14-       %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
     15-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)     \
     16-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)     \
     17-       -lgcc }"
     18+   "-lgcc_eh -lgcc"
     19 
     20 /* We specify crt0.o as -lcrt0.o so that ld will search the library path.
     21 
  • new file lang/gcc7/files/patch-249926conservative-darwin.c.diff

    diff --git a/lang/gcc7/files/patch-249926conservative-darwin.c.diff b/lang/gcc7/files/patch-249926conservative-darwin.c.diff
    new file mode 100644
    index 0000000000..831e5b9e1c
    - +  
     1--- gcc/config/darwin.c 2017/07/03 15:06:02     249925
     2+++ gcc/config/darwin.c 2017/07/03 15:53:56     249926
     3@@ -3683,11 +3683,9 @@
     4 void
     5 darwin_function_switched_text_sections (FILE *fp, tree decl, bool new_is_cold)
     6 {
     7-  char buf[128];
     8-  snprintf (buf, 128, "%s%s",new_is_cold?"__cold_sect_of_":"__hot_sect_of_",
     9-           IDENTIFIER_POINTER (DECL_NAME (decl)));
     10   /* Make sure we pick up all the relevant quotes etc.  */
     11-  assemble_name_raw (fp, (const char *) buf);
     12+  assemble_name_raw (fp, new_is_cold ? "__cold_sect_of_" : "__hot_sect_of_");
     13+  assemble_name_raw (fp, IDENTIFIER_POINTER (DECL_NAME (decl)));
     14   fputs (":\n", fp);
     15 }
     16 
  • new file lang/gcc7/files/patch-81033-8-darwin.c.diff

    diff --git a/lang/gcc7/files/patch-81033-8-darwin.c.diff b/lang/gcc7/files/patch-81033-8-darwin.c.diff
    new file mode 100644
    index 0000000000..796e6d455a
    - +  
     1--- gcc/config/darwin.c (revision 249872)
     2+++ gcc/config/darwin.c (working copy)
     3@@ -3146,29 +3146,9 @@
     4       && !TARGET_64BIT)
     5     global_options.x_flag_asynchronous_unwind_tables = 0;
     6 
     7-   /* Disable -freorder-blocks-and-partition when unwind tables are being
     8-      emitted for Darwin < 9 (OSX 10.5).
     9-      The strategy is, "Unless the User has specifically set/unset an unwind
     10-      flag we will switch off -freorder-blocks-and-partition when unwind tables
     11-      will be generated".  If the User specifically sets flags... we assume
     12-      (s)he knows why...  */
     13-   if (generating_for_darwin_version < 9
     14-       && global_options_set.x_flag_reorder_blocks_and_partition
     15-       && ((global_options.x_flag_exceptions           /* User, c++, java */
     16-           && !global_options_set.x_flag_exceptions)   /* User specified... */
     17-          || (global_options.x_flag_unwind_tables
     18-              && !global_options_set.x_flag_unwind_tables)
     19-          || (global_options.x_flag_non_call_exceptions
     20-              && !global_options_set.x_flag_non_call_exceptions)
     21-          || (global_options.x_flag_asynchronous_unwind_tables
     22-              && !global_options_set.x_flag_asynchronous_unwind_tables)))
     23-    {
     24-      inform (input_location,
     25-             "-freorder-blocks-and-partition does not work with exceptions "
     26-             "on this architecture");
     27-      flag_reorder_blocks_and_partition = 0;
     28-      flag_reorder_blocks = 1;
     29-    }
     30+  /* Disable flag_reorder_blocks_and_partition as it is broken on Darwin.
     31+     See PR 81033.  */
     32+  flag_reorder_blocks_and_partition = 0;
     33 
     34     /* FIXME: flag_objc_sjlj_exceptions is no longer needed since there is only
     35        one valid choice of exception scheme for each runtime.  */
  • new file lang/gcc7/files/patch-darwin-ppc-2017-01-msg02971.diff

    diff --git a/lang/gcc7/files/patch-darwin-ppc-2017-01-msg02971.diff b/lang/gcc7/files/patch-darwin-ppc-2017-01-msg02971.diff
    new file mode 100644
    index 0000000000..e9ec101c2e
    - +  
     1https://gcc.gnu.org/ml/gcc-testresults/2017-01/msg02971.html
     2
     3From e28e7068641a9ef7d1899b474fa3ddf898edc4c2 Mon Sep 17 00:00:00 2001
     4From: Iain Sandoe <iain@codesourcery.com>
     5Date: Fri, 2 Dec 2016 12:29:23 +0000
     6Subject: [PATCH 1/4] [Darwin, powerpc] Fix bootstrap (PR77359) by copying AIX
     7 amendment.
     8
     9PowerPC Darwin also requires 128b stack alignment (for all versions I currently have access to).  It's quite possible that it would be suitable to #define STACK_BOUNDARY 128, but for now I've left it as defined in rs6000.h.
     10---
     11 gcc/config/rs6000/darwin.h | 31 ++++++++++++++++++++++++++-----
     12 1 file changed, 26 insertions(+), 5 deletions(-)
     13
     14diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h
     15index 397ab1c..72c71f6 100644
     16--- gcc/config/rs6000/darwin.h
     17+++ gcc/config/rs6000/darwin.h
     18@@ -146,19 +146,40 @@ extern int darwin_emit_branch_islands;
     19 #undef  RS6000_PIC_OFFSET_TABLE_REGNUM
     20 #define RS6000_PIC_OFFSET_TABLE_REGNUM 31
     21 
     22-/* Pad the outgoing args area to 16 bytes instead of the usual 8.  */
     23+/* Offset within stack frame to start allocating local variables at.
     24+   If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
     25+   first local allocated.  Otherwise, it is the offset to the BEGINNING
     26+   of the first local allocated.
     27+
     28+   On the RS/6000, the frame pointer is the same as the stack pointer,
     29+   except for dynamic allocations.  So we start after the fixed area and
     30+   outgoing parameter area.
     31+
     32+   If the function uses dynamic stack space (CALLS_ALLOCA is set), that
     33+   space needs to be aligned to STACK_BOUNDARY, i.e. the sum of the
     34+   sizes of the fixed area and the parameter area must be a multiple of
     35+   STACK_BOUNDARY.  */
     36 
     37 #undef STARTING_FRAME_OFFSET
     38 #define STARTING_FRAME_OFFSET                                          \
     39   (FRAME_GROWS_DOWNWARD                                                        \
     40    ? 0                                                                 \
     41-   : (RS6000_ALIGN (crtl->outgoing_args_size, 16)              \
     42-      + RS6000_SAVE_AREA))
     43+   : (cfun->calls_alloca                                               \
     44+      ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \
     45+      : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA)))
     46+
     47+/* Offset from the stack pointer register to an item dynamically
     48+   allocated on the stack, e.g., by `alloca'.
     49+
     50+   The default value for this macro is `STACK_POINTER_OFFSET' plus the
     51+   length of the outgoing arguments.  The default is correct for most
     52+   machines.  See `function.c' for details.
     53 
     54+   This value must be a multiple of STACK_BOUNDARY (hard coded in
     55+   `emit-rtl.c').  */
     56 #undef STACK_DYNAMIC_OFFSET
     57 #define STACK_DYNAMIC_OFFSET(FUNDECL)                                  \
     58-  (RS6000_ALIGN (crtl->outgoing_args_size, 16)         \
     59-   + (STACK_POINTER_OFFSET))
     60+   RS6000_ALIGN (crtl->outgoing_args_size + STACK_POINTER_OFFSET, 16)
     61 
     62 /* Darwin uses a function call if everything needs to be saved/restored.  */
     63 
     64--
     652.8.1
     66
     67From 8bcf01a06f997580088a8a7d69ce16b881187dfb Mon Sep 17 00:00:00 2001
     68From: Iain Sandoe <iain@codesourcery.com>
     69Date: Wed, 31 Aug 2016 19:45:18 +0100
     70Subject: [PATCH 2/4] [Darwin,PPC] Remove uses of LR in restore_world.
     71
     72r 239866 removed most of the uses of LR in returns and subclass
     73
     74Darwin had an additional use of LR in the restore_world machinery.  This patch removes it from the pattern in altivec.md and the relevant predicate.
     75
     762016-12-11  Iain Sandoe  <iain@codesourcery.com>
     77
     78        * config/rs6000/altivec.md (*restore_world): Remove LR use.
     79        * config/rs6000/predicates.md (restore_world_operation): Adjust op
     80        count, remove one USE.
     81---
     82 gcc/config/rs6000/altivec.md    | 1 -
     83 gcc/config/rs6000/predicates.md | 3 +--
     84 2 files changed, 1 insertion(+), 3 deletions(-)
     85
     86diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
     87index 8af7ac5..60fc983 100644
     88--- gcc/config/rs6000/altivec.md
     89+++ gcc/config/rs6000/altivec.md
     90@@ -414,7 +414,6 @@
     91 (define_insn "*restore_world"
     92  [(match_parallel 0 "restore_world_operation"
     93                   [(return)
     94-                  (use (reg:SI LR_REGNO))
     95                    (use (match_operand:SI 1 "call_operand" "s"))
     96                    (clobber (match_operand:SI 2 "gpc_reg_operand" "=r"))])]
     97  "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
     98diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
     99index 3d69fc8..8f568a7 100644
     100--- gcc/config/rs6000/predicates.md
     101+++ gcc/config/rs6000/predicates.md
     102@@ -1468,13 +1468,12 @@
     103   rtx elt;
     104   int count = XVECLEN (op, 0);
     105 
     106-  if (count != 59)
     107+  if (count != 58)
     108     return 0;
     109 
     110   index = 0;
     111   if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
     112       || GET_CODE (XVECEXP (op, 0, index++)) != USE
     113-      || GET_CODE (XVECEXP (op, 0, index++)) != USE
     114       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
     115     return 0;
     116 
     117--
     1182.8.1
     119
     120From 7abddda25c5d3ee568cd72477cfca89a1b3baceb Mon Sep 17 00:00:00 2001
     121From: Iain Sandoe <iain@codesourcery.com>
     122Date: Sun, 27 Nov 2016 15:48:23 +0000
     123Subject: [PATCH 3/4] [Darwin PPC] Fix Fortran bootstrap by fixing ppc/setjmp.h
     124
     125Earlier Darwin headers do not declare longjmp as noreturn, this was
     126already fixed for i386, but also affects the powerpc port.
     127
     1282016-11-27  Iain Sandoe  <iain@codesourcery.com>
     129
     130        PR bootstrap/72833
     131        * inclhack.def (darwin_longjmp_noreturn): Amend to add ppc.
     132        * fixincl.x: Regenerated.
     133---
     134 fixincludes/fixincl.x    | 10 +++++-----
     135 fixincludes/inclhack.def |  3 ++-
     136 2 files changed, 7 insertions(+), 6 deletions(-)
     137
     138diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
     139index 6a010d6..8567828 100644
     140--- fixincludes/fixincl.x
     141+++ fixincludes/fixincl.x
     142@@ -2753,7 +2753,7 @@ tSCC zDarwin_Longjmp_NoreturnName[] =
     143  *  File name selection pattern
     144  */
     145 tSCC zDarwin_Longjmp_NoreturnList[] =
     146-  "i386/setjmp.h\0";
     147+  "i386/setjmp.h\0ppc/setjmp.h\0";
     148 /*
     149  *  Machine/OS name selection pattern
     150  */
     151diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
     152index 03a267b..6cf056c 100644
     153--- fixincludes/inclhack.def
     154+++ fixincludes/inclhack.def
     155@@ -1421,12 +1421,13 @@ fix = {
     156 };
     157 
     158 /*
     159- *  Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
     160+ *  Before Mac OS X 10.8 <{i386,ppc}/setjmp.h> don't mark longjump noreturn.
     161  */
     162 fix = {
     163     hackname  = darwin_longjmp_noreturn;
     164     mach      = "*-*-darwin*";
     165     files     = "i386/setjmp.h";
     166+    files     = "ppc/setjmp.h";
     167     bypass    = "__dead2";
     168     select    = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
     169     c_fix     = format;
     170--
     1712.8.1
     172
     173From de5187a1258e4ac036f5b787d921d5e69c4fc476 Mon Sep 17 00:00:00 2001
     174From: Iain Sandoe <iain@codesourcery.com>
     175Date: Sat, 18 Jun 2016 14:39:50 +0100
     176Subject: [PATCH 4/4] Update of __gnat_lwp_self(), with fixes for Darwin9.
     177
     178---
     179 gcc/ada/adaint.c | 14 +++++++++++---
     180 1 file changed, 11 insertions(+), 3 deletions(-)
     181
     182diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
     183index 54a1d6e..0af8ca4 100644
     184--- gcc/ada/adaint.c
     185+++ gcc/ada/adaint.c
     186@@ -3174,9 +3174,13 @@ __gnat_lwp_self (void)
     187 #endif
     188 
     189 #if defined (__APPLE__)
     190-#include <mach/thread_info.h>
     191-#include <mach/mach_init.h>
     192-#include <mach/thread_act.h>
     193+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
     194+#  include <mach/thread_info.h>
     195+#  include <mach/mach_init.h>
     196+#  include <mach/thread_act.h>
     197+# else
     198+#  include <pthread.h>
     199+# endif
     200 
     201 /* System-wide thread identifier.  Note it could be truncated on 32 bit
     202    hosts.
     203@@ -3184,6 +3188,7 @@ __gnat_lwp_self (void)
     204 void *
     205 __gnat_lwp_self (void)
     206 {
     207+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
     208   thread_identifier_info_data_t data;
     209   mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
     210   kern_return_t kret;
     211@@ -3194,6 +3199,9 @@ __gnat_lwp_self (void)
     212     return (void *)(uintptr_t)data.thread_id;
     213   else
     214     return 0;
     215+#else
     216+    return (void *)pthread_mach_thread_np (pthread_self ());
     217+#endif
     218 }
     219 #endif
     220 
     221--
     2222.8.1
     223