Here are the bits I have from my original 6.5 diffs.

- Sync kprintf implementation with base gcc. Copied over from GCC 4.9.
- Roll in an ABI issue fix.


It's mentioned in the release notes for 6.5..

The GCC 6.5 release has an accidental ABI incompatibility for nested std::pair
objects, for more details see PR 87822. The bug causes a layout change for pairs
where the first member is also a pair, e.g. std::pair<std::pair<X, Y>, Z>. The
GCC 6 release series is closed so the bug in GCC 6.5 will not be fixed upstream,
but there is a patch in the bug report to allow it to be fixed by anybody
packaging GCC 6.5 or installing it themselves.


Index: patches/patch-gcc_c-family_c-format_c
===================================================================
RCS file: /home/cvs/ports/lang/gcc/6/patches/patch-gcc_c-family_c-format_c,v
retrieving revision 1.1.1.1
diff -u -p -u -p -r1.1.1.1 patch-gcc_c-family_c-format_c
--- patches/patch-gcc_c-family_c-format_c       4 Sep 2016 16:20:16 -0000       
1.1.1.1
+++ patches/patch-gcc_c-family_c-format_c       25 Nov 2018 23:21:49 -0000
@@ -1,6 +1,7 @@
 $OpenBSD: patch-gcc_c-family_c-format_c,v 1.1.1.1 2016/09/04 16:20:16 pascal 
Exp $
---- gcc/c-family/c-format.c.orig       Mon Jan  4 15:30:50 2016
-+++ gcc/c-family/c-format.c    Tue Aug 23 15:48:16 2016
+Index: gcc/c-family/c-format.c
+--- gcc/c-family/c-format.c.orig
++++ gcc/c-family/c-format.c
 @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3.  If not see
     format_type_error.  Target-specific format types do not have
     matching enum values.  */
@@ -9,15 +10,7 @@ $OpenBSD: patch-gcc_c-family_c-format_c,
                   gcc_diag_format_type, gcc_tdiag_format_type,
                   gcc_cdiag_format_type,
                   gcc_cxxdiag_format_type, gcc_gfc_format_type,
-@@ -49,6 +50,7 @@ struct function_format_info
-   unsigned HOST_WIDE_INT first_arg_num;       /* number of first arg (zero 
for varargs) */
- };
- 
-+
- static bool decode_format_attr (tree, function_format_info *, int);
- static int decode_format_type (const char *);
- 
-@@ -492,6 +494,15 @@ static const format_length_info gcc_diag_length_specs[
+@@ -492,6 +493,16 @@ static const format_length_info gcc_diag_length_specs[
    { NO_FMT, NO_FMT, 0 }
  };
  
@@ -26,31 +19,24 @@ $OpenBSD: patch-gcc_c-family_c-format_c,
 +  { "h", FMT_LEN_h, STD_C89, NO_FMT, 0 },
 +  { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C9L, 0 },
 +  { "q", FMT_LEN_ll, STD_EXT, NO_FMT, 0 },
-+  { "L", FMT_LEN_L, STD_C89, NO_FMT, 0 },
++  { "z", FMT_LEN_z, STD_C99, NO_FMT, 0 },
++  { "t", FMT_LEN_t, STD_C99, NO_FMT, 0 },
 +  { NO_FMT, NO_FMT, 0 }
 +};
 +
  /* The custom diagnostics all accept the same length specifiers.  */
  #define gcc_tdiag_length_specs gcc_diag_length_specs
  #define gcc_cdiag_length_specs gcc_diag_length_specs
-@@ -669,7 +680,6 @@ static const format_flag_pair strfmon_flag_pairs[] =
-   { 0, 0, 0, 0 }
- };
- 
--
- static const format_char_info print_char_table[] =
- {
-   /* C89 conversion specifiers.  */
-@@ -713,6 +723,44 @@ static const format_char_info asm_fprintf_char_table[]
+@@ -713,6 +724,44 @@ static const format_char_info asm_fprintf_char_table[]
    { NULL,  0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
  };
  
 +static const format_char_info kprint_char_table[] =
 +{
 +  /* C89 conversion specifiers.  */
-+  { "di",  0, STD_C89, { T89_I,   BADLEN,  T89_S,   T89_L,   T9L_LL,  BADLEN, 
 T99_SST, BADLEN,  BADLEN, BADLEN,  BADLEN,  BADLEN  }, "-wp0 +'I", "i", NULL },
-+  { "oxX", 0, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, BADLEN, 
T99_ST,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-wp0#",    "i", NULL },
-+  { "u",   0, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, BADLEN, 
T99_ST,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-wp0'I",   "i", NULL },
++  { "di",  0, STD_C89, { T89_I,   BADLEN,  T89_S,   T89_L,   T9L_LL,  BADLEN, 
 T99_SST, T99_PD,  BADLEN, BADLEN,  BADLEN,  BADLEN  }, "-wp0 +'I", "i", NULL },
++  { "oxX", 0, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, BADLEN, 
T99_ST,  T99_UPD,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-wp0#",    "i", NULL },
++  { "u",   0, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, BADLEN, 
T99_ST,  T99_UPD,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-wp0'I",   "i", NULL },
 +  { "c",   0, STD_C89, { T89_I,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN, 
 BADLEN,  BADLEN,  BADLEN, BADLEN,  BADLEN,  BADLEN  }, "-w",       "", NULL },
 +  { "s",   1, STD_C89, { T89_C,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN, 
 BADLEN, BADLEN, BADLEN,  BADLEN,   BADLEN,  BADLEN  }, "-wp",      "cR", NULL 
},
 +  { "p",   1, STD_C89, { T89_V,   BADLEN,  BADLEN,  T89_UL,  T9L_LL,  BADLEN, 
 BADLEN, BADLEN, BADLEN,  BADLEN,   BADLEN,  BADLEN  }, "-wp0",      "c", NULL 
},
@@ -86,14 +72,14 @@ $OpenBSD: patch-gcc_c-family_c-format_c,
  static const format_char_info gcc_diag_char_table[] =
  {
    /* C89 conversion specifiers.  */
-@@ -894,6 +942,18 @@ static const format_kind_info format_types_orig[] =
+@@ -894,6 +943,18 @@ static const format_kind_info format_types_orig[] =
      FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK,
      'w', 0, 'p', 0, 'L', 0,
      NULL, NULL
 +  },
 +  { "kprintf", kprintf_length_specs, kprint_char_table, " +#0-'I", NULL,
 +    printf_flag_specs, printf_flag_pairs,
-+    
FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
++    FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK,
 +    'w', 0, 'p', 0, 'L', 0,
 +    &integer_type_node, &integer_type_node
 +  },
Index: patches/patch-libstdc++-v3_include_bits_stl_pair_h
===================================================================
RCS file: patches/patch-libstdc++-v3_include_bits_stl_pair_h
diff -N patches/patch-libstdc++-v3_include_bits_stl_pair_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-libstdc++-v3_include_bits_stl_pair_h  25 Nov 2018 04:36:41 
-0000
@@ -0,0 +1,36 @@
+$OpenBSD$
+
+PR libstdc++/87822 fix layout change for nested std::pair
+
+The introduction of the empty __pair_base base class for PR 86751
+changed the layout of std::pair<std::pair<...>, ...>. The outer pair and
+its first member both have a base class of the same type, which cannot
+exist at the same address. This causes the first member to be at a
+non-zero offset.
+
+The solution is to make the base class depend on the template
+parameters, so that each pair type has a different base class type,
+which allows the base classes of the outer pair and its first member to
+have the same address.
+
+Index: libstdc++-v3/include/bits/stl_pair.h
+--- libstdc++-v3/include/bits/stl_pair.h.orig
++++ libstdc++-v3/include/bits/stl_pair.h
+@@ -183,7 +183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+   };
+ #endif // C++11
+ 
+-  class __pair_base
++  template<typename _U1, typename _U2> class __pair_base
+   {
+ #if __cplusplus >= 201103L
+     template<typename _T1, typename _T2> friend struct pair;
+@@ -202,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+    */
+   template<typename _T1, typename _T2>
+     struct pair
+-    : private __pair_base
++    : private __pair_base<_T1, _T2>
+     {
+       typedef _T1 first_type;    /// @c first_type is the first bound type
+       typedef _T2 second_type;   /// @c second_type is the second bound type

Reply via email to