Bug 96540 - gcc fails to build on Darwin 19.6.0
Summary: gcc fails to build on Darwin 19.6.0
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 96541 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-09 10:59 UTC by Jürgen Reuter
Modified: 2020-08-10 13:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jürgen Reuter 2020-08-09 10:59:54 UTC
I am using the following setup:
Darwin 19.6.0, macOS Catalina 10.15.6, XCode v11.6, with clang
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

g++ -std=c++11  -fno-PIE -c  -DIN_GCC_FRONTEND -g  -DIN_GCC    -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -I. -Ic -I../../gcc -I../../gcc/c -I../../gcc/../include -I./../intl -I../../gcc/../libcpp/include -I/usr/local//include -I/usr/local//include  -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace -I/usr/local//include  -o c/gimple-parser.o -MT c/gimple-parser.o -MMD -MP -MF c/.deps/gimple-parser.TPo ../../gcc/c/gimple-parser.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: unknown warning option '-Werror=format-diag' [-Wunknown-warning-option]
In file included from ../../gcc/c/gimple-parser.c:22:
In file included from ../../gcc/coretypes.h:476:
In file included from ../../gcc/hash-table.h:248:
../../gcc/vec.h:543:13: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add
      'const' to avoid a change in behavior [-Wconstexpr-not-const]
  CONSTEXPR operator vec<T, A, L> () { return vec<T, A, L>(); }
            ^
                                     const
In file included from ../../gcc/c/gimple-parser.c:28:
../../gcc/cgraph.h:1741:1: warning: 'cgraph_edge' defined as a class here but previously declared as a struct; this is
      valid, but may result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
class GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
^
../../gcc/cgraph.h:903:1: note: did you mean class here?
struct cgraph_edge;
^~~~~~
class
../../gcc/coretypes.h:144:1: note: did you mean class here?
struct cgraph_edge;
^~~~~~
class
In file included from ../../gcc/c/gimple-parser.c:28:
../../gcc/cgraph.h:2254:10: warning: struct 'cgraph_edge' was previously declared as a class; this is valid, but may
      result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
  friend struct cgraph_edge;
         ^
../../gcc/cgraph.h:1742:16: note: previous use is here
           for_user)) cgraph_edge
                      ^
../../gcc/cgraph.h:2254:10: note: did you mean class here?
  friend struct cgraph_edge;
         ^~~~~~
         class
../../gcc/cgraph.h:2662:32: warning: struct 'cgraph_edge' was previously declared as a class; this is valid, but may
      result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
void initialize_inline_failed (struct cgraph_edge *);
                               ^
../../gcc/cgraph.h:1742:16: note: previous use is here
           for_user)) cgraph_edge
                      ^
../../gcc/cgraph.h:2662:32: note: did you mean class here?
void initialize_inline_failed (struct cgraph_edge *);
                               ^~~~~~
                               class
../../gcc/cgraph.h:2663:28: warning: struct 'cgraph_edge' was previously declared as a class; this is valid, but may
      result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining);
                           ^
../../gcc/cgraph.h:1742:16: note: previous use is here
           for_user)) cgraph_edge
                      ^
../../gcc/cgraph.h:2663:28: note: did you mean class here?
bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining);
                           ^~~~~~
                           class
In file included from ../../gcc/c/gimple-parser.c:44:
In file included from ../../gcc/tree-vrp.h:23:
../../gcc/value-range.h:347:1: error: static declaration of 'gt_ggc_mx' follows non-static declaration
gt_ggc_mx (int_range<N> *x)
^
../../gcc/value-range.h:150:37: note: previous declaration is here
  template <unsigned X> friend void gt_ggc_mx (int_range<X> *);
                                    ^
../../gcc/value-range.h:358:1: error: static declaration of 'gt_pch_nx' follows non-static declaration
gt_pch_nx (int_range<N> *x)
^
../../gcc/value-range.h:151:37: note: previous declaration is here
  template <unsigned X> friend void gt_pch_nx (int_range<X> *);
                                    ^
../../gcc/value-range.h:369:1: error: static declaration of 'gt_pch_nx' follows non-static declaration
gt_pch_nx (int_range<N> *x, gt_pointer_operator op, void *cookie)
^
../../gcc/value-range.h:152:37: note: previous declaration is here
  template <unsigned X> friend void gt_pch_nx (int_range<X> *,
                                    ^
In file included from ../../gcc/c/gimple-parser.c:49:
../../gcc/gimple.h:2599:10: warning: array index 1 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
  return gs->op[1];
         ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2631:3: warning: array index 1 is past the end of the array (which contains 1 element) [-Warray-bounds]
  gs->op[1] = rhs;
  ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2649:12: warning: array index 2 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
    return gs->op[2];
           ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2669:11: warning: array index 2 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
  return &gs->op[2];
          ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2686:3: warning: array index 2 is past the end of the array (which contains 1 element) [-Warray-bounds]
  gs->op[2] = rhs;
  ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2703:12: warning: array index 3 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
    return gs->op[3];
           ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2723:11: warning: array index 3 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
  return &ass->op[3];
          ^       ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:2733:3: warning: array index 3 is past the end of the array (which contains 1 element) [-Warray-bounds]
  gs->op[3] = rhs;
  ^      ~
../../gcc/gimple.h:337:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:3095:10: warning: array index 1 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
  return gs->op[1];
         ^      ~
../../gcc/gimple.h:362:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:3128:3: warning: array index 1 is past the end of the array (which contains 1 element) [-Warray-bounds]
  gs->op[1] = fn;
  ^      ~
../../gcc/gimple.h:362:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:3138:3: warning: array index 1 is past the end of the array (which contains 1 element) [-Warray-bounds]
  gs->op[1] = build1_loc (gimple_location (gs), ADDR_EXPR,
  ^      ~
../../gcc/gimple.h:362:3: note: array 'op' declared here
  tree GTY((length ("%h.num_ops"))) op[1];
  ^
../../gcc/gimple.h:3199:10: warning: array index 2 is past the end of the array (which contains 1 element)
      [-Warray-bounds]
  return gs->op[2];
Comment 1 Jürgen Reuter 2020-08-10 07:14:00 UTC
It seems that the problem is in the declaration of the following variables in value_range.h:
  template <unsigned X> friend void gt_ggc_mx (int_range<X> *);
  template <unsigned X> friend void gt_pch_nx (int_range<X> *);
  template <unsigned X> friend void gt_pch_nx (int_range<X> *,
                                               gt_pointer_operator, void *);
  // ?? hash-traits.h has its own extern for these, which is causing                                                      
  // them to never be picked up by the templates.  For now, define                                                        
  // elsewhere.                                                                                                           
  //template<unsigned X> friend void gt_ggc_mx (int_range<X> *&);                                                         
  //template<unsigned X> friend void gt_pch_nx (int_range<X> *&);            

This declaration is commented out, but above it is set, which looks suspicious. If I comment out the three declarations for friend void gt_ggc_mx, then the code seems to compile.
Comment 2 Jürgen Reuter 2020-08-10 07:16:25 UTC
Most likely this was that commit:
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 150)   template <unsigned X> friend void gt_ggc_mx (int_range<X> *);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 151)   template <unsigned X> friend void gt_pch_nx (int_range<X> *);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 152)   template <unsigned X> friend void gt_pch_nx (int_range<X> *,
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 153)                                         gt_pointer_operator, void *);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 154)   // ?? hash-traits.h has its own extern for these, which is causing
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 155)   // them to never be picked up by the templates.  For now, define
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 156)   // elsewhere.
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 157)   //template<unsigned X> friend void gt_ggc_mx (int_range<X> *&);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 158)   //template<unsigned X> friend void gt_pch_nx (int_range<X> *&);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 159)   friend void gt_ggc_mx (int_range<1> *&);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 160)   friend void gt_pch_nx (int_range<1> *&);
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 161) 
4ba9fb0a3e65 (Aldy Hernandez    2020-07-30 11:30:18 +0200 162)   tree m_ranges[N*2];
Comment 3 Jürgen Reuter 2020-08-10 07:41:58 UTC
Just uncommenting the declarations doesn't help because later on compilation fails with
n file included from gtype-desc.c:52:
../../gcc/value-range.h:352:21: error: 'm_ranges' is a private member of 'int_range<1>'
      gt_ggc_mx (x->m_ranges[i * 2]);
                    ^

because the friend declaration is missing. :(
Comment 4 Aldy Hernandez 2020-08-10 08:03:41 UTC
Does this patch fix the problem?

https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551660.html
Comment 5 Jürgen Reuter 2020-08-10 08:10:40 UTC
(In reply to Aldy Hernandez from comment #4)
> Does this patch fix the problem?
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551660.html

It looks like, still compiling. In the meantime I changed this in the same way, as the error message clearly showed that there is both a dynamic and a static declaration present. I'm waiting for the build to complete and report back.
Comment 6 Martin Liška 2020-08-10 08:50:46 UTC
*** Bug 96541 has been marked as a duplicate of this bug. ***
Comment 7 Jürgen Reuter 2020-08-10 12:33:45 UTC
(In reply to Aldy Hernandez from comment #4)
> Does this patch fix the problem?
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551660.html

Yes, with that fix (as anticipated by you) build and bootstrap work.
Comment 8 Aldy Hernandez 2020-08-10 13:01:16 UTC
Fixed upstream.