Bug 245511

Summary: lang/gcc9: build with base GCC on powerpc64 elfv1
Product: Ports & Packages Reporter: Piotr Kubaj <pkubaj>
Component: Individual Port(s)Assignee: Gerald Pfeifer <gerald>
Status: Closed FIXED    
Severity: Affects Only Me CC: gerald, jhibbits, powerpc
Priority: --- Keywords: buildisok
Version: LatestFlags: gerald: maintainer-feedback-
Hardware: powerpc   
OS: Any   
Attachments:
Description Flags
patch
pkubaj: maintainer-approval? (gerald)
Suggested patch none

Description Piotr Kubaj freebsd_committer freebsd_triage 2020-04-10 17:04:34 UTC
Created attachment 213252 [details]
patch

To build on any platform (be it powerpc or powerpc64, probably also others) with base GCC, a patch by Gustavo is necessary.
Other than that, default optimizations need to be lowered. -O0 is necessary.
Both CONFIGURE_ENV and MAKE_ENV are necessary even though they are the same.
Comment 1 Automation User 2020-04-25 03:43:22 UTC
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/139728225
Comment 2 commit-hook freebsd_committer freebsd_triage 2020-04-25 12:26:57 UTC
A commit references this bug:

Author: pkubaj
Date: Sat Apr 25 12:26:35 UTC 2020
New revision: 532950
URL: https://svnweb.freebsd.org/changeset/ports/532950

Log:
  lang/gcc9: build with base GCC on powerpc64 elfv1

  Instead of using lang/gcc8 for bootstrapping gcc9 on powerpc64 elfv1, use directly base gcc.
  Necessary changes:
  - CFLAGS_FOR_TARGET="-O0" CXXFLAGS_FOR_TARGET="-O0" BOOT_CFLAGS="-O0" in CONFIGURE_ENV and MAKE_ENV. Otherwise bootstrapped compiler fails later in the build with segfault.
  - CRTSTUFF_T_CFLAGS has changed optimizations to -O0, instead of -O2. -O2 worked in gcc8, because there was no -fno-asynchronous-unwind-tables flag added to CRTSTUFF_T_CFLAGS. Since this works when building with clang on powerpc64 elfv2, this patch is added to EXTRA_PATCHES, only on powerpc64 elfv1,
  - BOOT_CFLAGS has added ? before =. This is to allow overriding BOOT_CFLAGS in CONFIGURE_ENV and MAKE_ENV.
  - A patch by Gustavo Romero to gcc/dumpfile.c is necessary to allow compiling with base GCC, otherwise base GCC hits ICE. Incidentally, this patch alone also fixes build for powerpc (32 bits) with base GCC.

  Bump PORTREVISION for dependency change.

  PR:		245511, 242506
  Approved by:	gerald (maintainer timeout)

Changes:
  head/lang/gcc9/Makefile
  head/lang/gcc9/files/extra-patch-libgcc_config_rs6000_t-crtstuff
  head/lang/gcc9/files/patch-Makefile.in
  head/lang/gcc9/files/patch-gcc_dumpfile.c
Comment 3 Gerald Pfeifer freebsd_committer freebsd_triage 2020-04-25 14:01:19 UTC
I was just looking into this today morning, but missed hitting "Save changes"
on my NACK.

I approve backporting the change that was discussed and committed upstream.  

Your other changes appear somewhat random and lead to a crippled compiler/
runtime.  Since this only affects powerpc* with the legacy ABI and you could
remove the dependency on GCC 8 there, let's primarily focus on how you have
been going about it.


Given that lang/gcc9 is the default version of GCC in the ports tree I would
definitely have avoided the PORTREVISION bump for the vast majority of users
- and made this conditional in this special case.

Changes to the lang/gcc ports should first go in via their lang/gcc-devel
counter-parts.  Alternatively, and I will do this in the next days (so do
*not* forward port your patch) we can disable powerpc* for lang/gcc9-devel
and focus on the lang/gcc9 port as clearly has been your approach over time.


I recommend you run `portlint -C` going forward - it would have caught
a formatting issue.  I'll address that next time I touch this Makefile.

And we don't do commit messages with lines of 299 chars.


Is files/patch-Makefile.in truely necessary?  If it is, how could overriding BOOT_CFLAGS ever have worked for anyone?

According to gcc/gcc/doc/install.texi passing BOOT_CFLAGS via MAKE_ARGS
should work.  Can you please try that instead?

(https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_9.html#SEC90
explains why files/patch-Makefile.in should not be necessary.)
Comment 4 Gerald Pfeifer freebsd_committer freebsd_triage 2020-04-25 14:20:03 UTC
Created attachment 213782 [details]
Suggested patch

This updates the earlier approach to use GCC's standard mechanism and avoids
an unnecessary local patch.

Does this work for you?  Please ensure details are right, i.e., the approach
should work, but is untested.
Comment 5 Piotr Kubaj freebsd_committer freebsd_triage 2020-04-25 22:26:46 UTC
(In reply to Gerald Pfeifer from comment #4)
Thanks, it indeed works. I thought I tested that approach already, but I clearly didn't.

Please, don't disable gcc9-devel for powerpc*. Even if there are no users of those on powerpc*, gcc*-devel serve as great testing bed to check that the next release will build just fine (especially because you don't do tests on powerpc*). This is why I think that gcc10-devel should build as well, even though no port depends on it (regarding to my earlier PR about gcc10-devel on powerpc64 elfv2).

Why are those changes crippling GCC? I understand that it will run slower, but so is the case already for GCC 7 and 8. I think it's still better from relaying on bootstrap compiler. It will also make it easier for you to remove GCC 8 ports in the future.
Comment 6 Gerald Pfeifer freebsd_committer freebsd_triage 2020-04-27 20:47:43 UTC
(In reply to Piotr Kubaj from comment #5)
> Thanks, it indeed works. I thought I tested that approach already, but
> I clearly didn't.

Excellent.  I'll apply my change to lang/gcc9 in a minute then.

> Please, don't disable gcc9-devel for powerpc*. Even if there are no users
> of those on powerpc*, gcc*-devel serve as great testing bed to check that
> the next release will build just fine (especially because you don't do
> tests on powerpc*). This is why I think that gcc10-devel should build as
> well, even though no port depends on it (regarding to my earlier PR about
> gcc10-devel on powerpc64 elfv2).

I understand, yet if that is an important function of the -devel ports
for powerpc as well (I certainly see it that way in general), can you
help test lang/gcc9-devel and push in changes there first before tackling
lang/gcc9 going forward?

I will port my change to lang/gcc9-devel and see that the dumpfile.c build
fix get backported from upstream head to the GCC 9 release branch, so that
lang/gcc9-devel will get it via the following weekly snapshot.

> Why are those changes crippling GCC? I understand that it will run slower, 
> but so is the case already for GCC 7 and 8. I think it's still better from
> relaying on bootstrap compiler.

Your change does not just affect the compiler binaries themselves, and I
assume quite a bit, it also pushes -O0 for the target libraries.

The GCC documentation has the following:

  @code{BOOT_CFLAGS} does not apply to bootstrapped target libraries.
  Since these are always compiled with the compiler currently being
  bootstrapped, you can use @code{CFLAGS_FOR_TARGET} to modify their
  compilation flags, as for non-bootstrapped target libraries.

Once my patch is in, can you please give three things a try, one after
the other?

 (1) CXXFLAGS_FOR_TARGET is really necessary (by removing it)?
 (2) CFLAGS_FOR_TARGET is really necessary (by removing it)?
 (3) For what is left after (1) and (2), is -O1 also sufficient?

If you run into a problem for the above, can you please share the last
lines of the build log, in particular the invocation that fails and where
in the chain of make invocations this is (usually the last few lines of the
log)?
Comment 7 Piotr Kubaj freebsd_committer freebsd_triage 2020-04-27 21:07:09 UTC
> I understand, yet if that is an important function of the -devel ports
> for powerpc as well (I certainly see it that way in general), can you
> help test lang/gcc9-devel and push in changes there first before tackling
> lang/gcc9 going forward?
OK.

> Your change does not just affect the compiler binaries themselves, and I
> assume quite a bit, it also pushes -O0 for the target libraries.
I know that, I can already notice that some ports build much slower than before (but it's just some, most still build in similar time).

Another advantage of building GCC with -O0 seems that some ports now build, whereas previously the compiled binaries failed during build with segfault.
I had that experience with lang/ghc. It was ported some time ago and built just fine, but some time ago started failing with segfault during build process. Now was the first time in a few months that it built. There may be other ports in similar situation.

> Once my patch is in, can you please give three things a try, one after
> the other?
>
> (1) CXXFLAGS_FOR_TARGET is really necessary (by removing it)?
> (2) CFLAGS_FOR_TARGET is really necessary (by removing it)?
> (3) For what is left after (1) and (2), is -O1 also sufficient?
OK, I'll test it.
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-04-27 21:16:42 UTC
A commit references this bug:

Author: gerald
Date: Mon Apr 27 21:16:16 UTC 2020
New revision: 533204
URL: https://svnweb.freebsd.org/changeset/ports/533204

Log:
  Improve upon revision 532950 by passing GCC optimization options via
  MAKE_ARGS instead of trying to do this via the environment (which is
  lower priority and required files/patch-Makefile.in which we can now
  remove).

  PR:		245511

Changes:
  head/lang/gcc9/Makefile
  head/lang/gcc9/files/patch-Makefile.in
Comment 9 Piotr Kubaj freebsd_committer freebsd_triage 2020-04-28 09:51:12 UTC
CXXFLAGS_FOR_TARGET="-O1":
gmake[6]: Entering directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++'
/bin/sh ../libtool --tag CXX --tag disable-shared   --mode=compile /wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src/.libs -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++/.libs -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/../libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include/powerpc64-portbld-freebsd12.1 -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++   -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2  -fdiagnostics-show-location=once    -ffunction-sections -fdata-sections  -frandom-seed=eh_personality.lo -O1  -c -o eh_personality.lo /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc
libtool: compile:  /wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src/.libs -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++/.libs -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include -fno-checking -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/../libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include/powerpc64-portbld-freebsd12.1 -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=eh_personality.lo -O1 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc  -fPIC -DPIC -D_GLIBCXX_SHARED -o eh_personality.o
during GIMPLE pass: uncprop
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc: In function '_Unwind_Reason_Code __cxxabiv1::__gxx_personality_v0(int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception*, _Unwind_Context*)':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc:336:30: internal compiler error: Segmentation fault
  336 | #define PERSONALITY_FUNCTION __gxx_personality_v0
      |                              ^~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc:351:1: note: in expansion of macro 'PERSONALITY_FUNCTION'
  351 | PERSONALITY_FUNCTION (int version,
      | ^~~~~~~~~~~~~~~~~~~~



No CXXFLAGS_FOR_TARGET:
gmake[6]: Entering directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++'
/bin/sh ../libtool --tag CXX --tag disable-shared   --mode=compile /wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src/.libs -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++/.libs -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/../libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include/powerpc64-portbld-freebsd12.1 -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++   -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2  -fdiagnostics-show-location=once    -ffunction-sections -fdata-sections  -frandom-seed=class_type_info.lo -g -O2 -pipe   -DLIBICONV_PLUG   -c -o class_type_info.lo /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc
libtool: compile:  /wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src/.libs -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++/.libs -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include -fno-checking -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/../libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include/powerpc64-portbld-freebsd12.1 -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=class_type_info.lo -g -O2 -pipe -DLIBICONV_PLUG -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc  -fPIC -DPIC -D_GLIBCXX_SHARED -o class_type_info.o
during GIMPLE pass: store-merging
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc: In member function 'virtual bool __cxxabiv1::__class_type_info::__do_upcast(const __cxxabiv1::__class_type_info*, void**) const':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc:45:6: internal compiler error: Segmentation fault
   45 | bool __class_type_info::
      |      ^~~~~~~~~~~~~~~~~



CFLAGS_FOR_TARGET="-O1":
/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/ -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -O1 -m32 -fPIC -mstrict-align
-O2  -O1 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -pthread -mno-minimal-toc -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -pthread -mno-minimal-toc -I. -I. -I../../.././gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/. -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _powisf2.o -MT _powisf2.o -MD -MP -MF _powisf2.dep -DL_powisf2 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during GIMPLE pass: uncprop
In file included from /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:56:
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c: In function '__powisf2':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:256:16: internal compiler error: Segmentation fault
  256 | #define __N(a) __ ## a
      |                ^~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:339:20: note: in expansion of macro '__N'
  339 | #define __powisf2  __N(powisf2)
      |                    ^~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:1862:16: note: in expansion of macro '__powisf2'
 1862 | #  define NAME __powisf2
      |                ^~~~~~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:1877:1: note: in expansion of macro 'NAME'
 1877 | NAME (TYPE x, int m)
      | ^~~~



No CFLAGS_FOR_TARGET:
gmake[6]: Entering directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/32/libgcc'
# If this is the top-level multilib, build all the other
# multilibs.
/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/ -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -g -O2 -pipe -DLIBICONV_PLUG -fno-strict-aliasing -m32 -fPIC -mstrict-align -O2  -g -O2 -pipe  -DLIBICONV_PLUG -fno-strict-aliasing  -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -pthread -mno-minimal-toc -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -pthread -mno-minimal-toc -I. -I. -I../../.././gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/. -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during GIMPLE pass: store-merging
In file included from /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:56:
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c: In function '__muldi3':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:219:20: internal compiler error: Segmentation fault
  219 | #define __NDW(a,b) __ ## a ## di ## b
      |                    ^~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:273:18: note: in expansion of macro '__NDW'
  273 | #define __muldi3 __NDW(mul,3)
      |                  ^~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:548:1: note: in expansion of macro '__muldi3'
  548 | __muldi3 (DWtype u, DWtype v)
      | ^~~~~~~~
Comment 10 commit-hook freebsd_committer freebsd_triage 2020-04-30 19:48:46 UTC
A commit references this bug:

Author: gerald
Date: Thu Apr 30 19:48:07 UTC 2020
New revision: 533472
URL: https://svnweb.freebsd.org/changeset/ports/533472

Log:
  Update to the 20200425 snapshot of GCC 9.3.1.

  This brings one fix for the tree optimizers, three for gcov, four for x86
  and hree for aarch64, plus two for the Fortran and C++ front ends each,
  and some ten for the C++ run-time library.

  Essentially forward port r533204 | gerald | 2020-04-27 from lang/gcc9

    Improve upon revision 532950 by passing GCC optimization options via
    MAKE_ARGS instead of trying to do this via the environment ...

  which obviates the use of GCC 8 for powerpc*. [1]

  PR:		245511 [1]

Changes:
  head/lang/gcc9-devel/Makefile
  head/lang/gcc9-devel/distinfo
Comment 11 Justin Hibbits freebsd_committer freebsd_triage 2020-04-30 20:22:15 UTC
I wouldn't say it obviates the need for all powerpc.  powerpcspe is stuck at gcc8.  The set of powerpcspe users is probably extremely small, but I don't want to see gcc8 go away until it's really necessary (needed for FreeBSD 12 at least, that's still gcc based, making good progress on clang, but still a couple hiccups I need to sort out before I can completely drop gcc on 13).
Comment 12 Gerald Pfeifer freebsd_committer freebsd_triage 2020-04-30 20:43:14 UTC
(In reply to Piotr Kubaj from comment #9)

Thank you for those tests, Piotr.  The results look concerning indeed,
I wonder what the quality of the produced compiler is. :-(

Just to make sure, what were the last lines coming from gmake, that is
those looking like

   gmake[3]: *** [mode-switching.o] Error 1
   gmake[3]: Leaving directory `/files/pfeifer/OBJ-0131-2308/gcc'
   gmake[2]: *** [all-stage2-gcc] Error 2
   gmake[2]: Leaving directory `/files/pfeifer/OBJ-0131-2308'
   gmake[1]: *** [stage2-bubble] Error 2
   gmake[1]: Leaving directory `/files/pfeifer/OBJ-0131-2308'

where I am mostly interested in those with the "***"?


I am wondering whether this misses where the actual issue happens, since
the docs say the following:

   If you wish to use non-default GCC flags when compiling the stage2
   and stage3 compilers, set @code{BOOT_CFLAGS} on the command line when
   doing @samp{make}.
  
And they also say:

   Again, if the native compiler miscompiles the stage1 compiler, you may
   need to work around this by avoiding non-working parts of the stage1
   compiler.  Use @code{STAGE1_TFLAGS} to this end.

So I am wondering whether you should not have tried setting STAGE1_TFLAGS
in the first place, to avoid a broken stage1 compiler as opposed to trying
to be gentle to a broken stage1 compiler by only invoking it with -O0.

Do you see what I mean?
Comment 13 Gerald Pfeifer freebsd_committer freebsd_triage 2020-04-30 20:47:52 UTC
(In reply to Justin Hibbits from comment #11)
> I wouldn't say it obviates the need for all powerpc. 

I believe you misunderstood the implication of my commit message.

Look at the diff and you will see what I tried to relay ;-) -- though I 
agree that just reading the commit message it easily leads astray.
Comment 14 Justin Hibbits freebsd_committer freebsd_triage 2020-04-30 20:53:47 UTC
(In reply to Gerald Pfeifer from comment #13)

Aha, sorry, I did not read the diff.  Yeah, you can ignore my comment, since gcc9 isn't built on that target anyway.
Comment 15 Piotr Kubaj freebsd_committer freebsd_triage 2020-04-30 22:10:18 UTC
No CXXFLAGS_FOR_TARGET, no CFLAGS_FOR_TARGET, STAGE1_TFLAGS="-O0":
/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/ -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -O0 -g -O2 -pipe -DLIBICONV_PLUG -fno-strict-aliasing -m32 -fPIC -mstrict-align -O2  -g -O2 -pipe  -DLIBICONV_PLUG -fno-strict-aliasing  -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -pthread -mno-minimal-toc -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -pthread -mno-minimal-toc -I. -I. -I../../.././gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/. -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during GIMPLE pass: store-merging
In file included from /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:56:
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c: In function '__muldi3':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:219:20: internal compiler error: Segmentation fault
  219 | #define __NDW(a,b) __ ## a ## di ## b
      |                    ^~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:273:18: note: in expansion of macro '__NDW'
  273 | #define __muldi3 __NDW(mul,3)
      |                  ^~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:548:1: note: in expansion of macro '__muldi3'
  548 | __muldi3 (DWtype u, DWtype v)
      | ^~~~~~~~
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[6]: *** [Makefile:498: _muldi3.o] Error 1
gmake[6]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/32/libgcc'
gmake[5]: *** [Makefile:1210: multi-do] Error 1
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[4]: *** [Makefile:127: all-multi] Error 2
gmake[4]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[3]: *** [Makefile:17170: all-stage1-target-libgcc] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[2]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[1]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
*** Error code 1



No CXXFLAGS_FOR_TARGET:
libtool: compile:  /wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src/.libs -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++/.libs -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include -fno-checking -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/../libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include/powerpc64-portbld-freebsd12.1 -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=class_type_info.lo -g -O2 -pipe -DLIBICONV_PLUG -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc  -fPIC -DPIC -D_GLIBCXX_SHARED -o class_type_info.o
during GIMPLE pass: store-merging
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc: In member function 'virtual bool __cxxabiv1::__class_type_info::__do_upcast(const __cxxabiv1::__class_type_info*, void**) const':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/class_type_info.cc:45:6: internal compiler error: Segmentation fault
   45 | bool __class_type_info::
      |      ^~~~~~~~~~~~~~~~~
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[6]: *** [Makefile:761: class_type_info.lo] Error 1
gmake[6]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++'
gmake[5]: *** [Makefile:562: all-recursive] Error 1
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3'
gmake[4]: *** [Makefile:487: all] Error 2
gmake[4]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3'
gmake[3]: *** [Makefile:15135: all-stage1-target-libstdc++-v3] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[2]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[1]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
*** Error code 1



CXXFLAGS_FOR_TARGET="-O1":
libtool: compile:  /wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/src/.libs -L/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++/.libs -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include -fno-checking -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/../libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include/powerpc64-portbld-freebsd12.1 -I/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/include -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=eh_personality.lo -O1 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc  -fPIC -DPIC -D_GLIBCXX_SHARED -o eh_personality.o
during GIMPLE pass: uncprop
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc: In function '_Unwind_Reason_Code __cxxabiv1::__gxx_personality_v0(int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception*, _Unwind_Context*)':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc:336:30: internal compiler error: Segmentation fault
  336 | #define PERSONALITY_FUNCTION __gxx_personality_v0
      |                              ^~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libstdc++-v3/libsupc++/eh_personality.cc:351:1: note: in expansion of macro 'PERSONALITY_FUNCTION'
  351 | PERSONALITY_FUNCTION (int version,
      | ^~~~~~~~~~~~~~~~~~~~
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[6]: *** [Makefile:761: eh_personality.lo] Error 1
gmake[6]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3/libsupc++'
gmake[5]: *** [Makefile:562: all-recursive] Error 1
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3'
gmake[4]: *** [Makefile:487: all] Error 2
gmake[4]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libstdc++-v3'
gmake[3]: *** [Makefile:15135: all-stage1-target-libstdc++-v3] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[2]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[1]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
*** Error code 1



CFLAGS_FOR_TARGET="-O1":
/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/ -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -O1 -m32 -fPIC -mstrict-align
-O2  -O1 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -pthread -mno-minimal-toc -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -pthread -mno-minimal-toc -I. -I. -I../../.././gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/. -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _powisf2.o -MT _powisf2.o -MD -MP -MF _powisf2.dep -DL_powisf2 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during GIMPLE pass: uncprop
In file included from /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:56:
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c: In function '__powisf2':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:256:16: internal compiler error: Segmentation fault
  256 | #define __N(a) __ ## a
      |                ^~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:339:20: note: in expansion of macro '__N'
  339 | #define __powisf2  __N(powisf2)
      |                    ^~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:1862:16: note: in expansion of macro '__powisf2'
 1862 | #  define NAME __powisf2
      |                ^~~~~~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:1877:1: note: in expansion of macro 'NAME'
 1877 | NAME (TYPE x, int m)
      | ^~~~
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[6]: *** [Makefile:498: _powisf2.o] Error 1
gmake[6]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/32/libgcc'
gmake[5]: *** [Makefile:1210: multi-do] Error 1
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[4]: *** [Makefile:127: all-multi] Error 2
gmake[4]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[3]: *** [Makefile:17170: all-stage1-target-libgcc] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[2]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[1]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
*** Error code 1



No CFLAGS_FOR_TARGET:
/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/ -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -g -O2 -pipe -DLIBICONV_PLUG -fno-strict-aliasing -m32 -fPIC -mstrict-align -O2  -g -O2 -pipe  -DLIBICONV_PLUG -fno-strict-aliasing  -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -pthread -mno-minimal-toc -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -pthread -mno-minimal-toc -I. -I. -I../../.././gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/. -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during GIMPLE pass: store-merging
In file included from /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:56:
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c: In function '__muldi3':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:219:20: internal compiler error: Segmentation fault
  219 | #define __NDW(a,b) __ ## a ## di ## b
      |                    ^~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:273:18: note: in expansion of macro '__NDW'
  273 | #define __muldi3 __NDW(mul,3)
      |                  ^~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:548:1: note: in expansion of macro '__muldi3'
  548 | __muldi3 (DWtype u, DWtype v)
      | ^~~~~~~~
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[6]: *** [Makefile:498: _muldi3.o] Error 1
gmake[6]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/32/libgcc'
gmake[5]: *** [Makefile:1210: multi-do] Error 1
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[4]: *** [Makefile:127: all-multi] Error 2
gmake[4]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[3]: *** [Makefile:17170: all-stage1-target-libgcc] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[2]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[1]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
*** Error code 1
Comment 16 Piotr Kubaj freebsd_committer freebsd_triage 2020-04-30 22:14:28 UTC
(In reply to Gerald Pfeifer from comment #12)
> I wonder what the quality of the produced compiler is. :-(
What do you mean? If you mean performance, sure it's worse, but still usable. If you suggest there might be new build errors for some ports getting built with gcc9, there are none now.
And I don't think the quality of gcc9-generated binaries will regress.
Comment 17 Gerald Pfeifer freebsd_committer freebsd_triage 2020-05-07 23:19:46 UTC
(In reply to Piotr Kubaj from comment #16)
> If you suggest there might be new build errors for some ports getting 
> built with gcc9, there are none now.

Interesting, given how broken that bootstrap compiler appears to be.

> And I don't think the quality of gcc9-generated binaries will regress.

It definitely will in terms of target libraries.  That is what
CFLAGS_FOR_TARGET="-O0" CXXFLAGS_FOR_TARGET="-O0" does.

Thank you for sharing those snippets from the various build attempts.
It appears they all fail in stage 1, trying to build target libraries.
So ideally we'd need to only tone down everything related to stage 1
- unlike the current patch which tones down the target libraries in
stage 3 even and all the other stage1-3 compilers as well - I just am
not sure how to go about that. 

Looking at the first attempt, where you noted STAGE1_TFLAGS="-O0", it
appears the compiler invocation was effectively done with -O2.  I am
wondering whether setting STAGE1_CFLAGS and STAGE1_CXXFLAGS might help.
Comment 18 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-07 23:37:49 UTC
I will test that later today since my Talos is currently busy.

BTW, since you are much more knowledgeable than me about this - you could try compiling this on ref12-ppc64.
Comment 19 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-07 23:52:06 UTC
OK, since one of Poudriere jobs finished, I'm setting it to run for the night.
Comment 20 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-08 08:49:57 UTC
I set STAGE1_CFLAGS="-O0" STAGE1_CXXFLAGS="-O0" in MAKE_ARGS and removed CFLAGS_FOR_TARGET="-O0" CXXFLAGS_FOR_TARGET="-O0". Build still fails and I can see -O0 is not passed:
gmake[6]: Entering directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/32/libgcc'
# If this is the top-level multilib, build all the other
# multilibs.
/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gcc9/work/.build/./gcc/ -B/usr/local/powerpc64-portbld-freebsd12.1/bin/ -B/usr/local/powerpc64-portbld-freebsd12.1/lib/ -isystem /usr/local/powerpc64-portbld-freebsd12.1/include -isystem /usr/local/powerpc64-portbld-freebsd12.1/sys-include   -fno-checking -g -O2 -pipe -DLIBICONV_PLUG -fno-strict-aliasing -m32 -fPIC -mstrict-align -O2  -g -O2 -pipe  -DLIBICONV_PLUG -fno-strict-aliasing  -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -pthread -mno-minimal-toc -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -pthread -mno-minimal-toc -I. -I. -I../../.././gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/. -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../gcc -I/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during GIMPLE pass: store-merging
In file included from /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:56:
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c: In function '__muldi3':
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:219:20: internal compiler error: Segmentation fault
  219 | #define __NDW(a,b) __ ## a ## di ## b
      |                    ^~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.h:273:18: note: in expansion of macro '__NDW'
  273 | #define __muldi3 __NDW(mul,3)
      |                  ^~~~~
/wrkdirs/usr/ports/lang/gcc9/work/gcc-9.3.0/libgcc/libgcc2.c:548:1: note: in expansion of macro '__muldi3'
  548 | __muldi3 (DWtype u, DWtype v)
      | ^~~~~~~~
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[6]: *** [Makefile:498: _muldi3.o] Error 1
gmake[6]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/32/libgcc'
gmake[5]: *** [Makefile:1210: multi-do] Error 1
gmake[5]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[4]: *** [Makefile:127: all-multi] Error 2
gmake[4]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build/powerpc64-portbld-freebsd12.1/libgcc'
gmake[3]: *** [Makefile:17170: all-stage1-target-libgcc] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[2]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
gmake[1]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gcc9/work/.build'
*** Error code 1




root@powerpc64-121-default:/usr/ports/lang/gcc9 # grep MAKE_ARGS Makefile
MAKE_ARGS+=             STAGE1_CFLAGS="-O0" STAGE1_CXXFLAGS="-O0" BOOT_CFLAGS="-O0"
Comment 21 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-08 09:29:07 UTC
I also tried adding CONFIGURE_ARGS+=--with-stage1-cflags="-O0", but that doesn't help.
Comment 22 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-13 19:14:47 UTC
@gerald
I don't want to open a new bug for that or reopen the old one.

I'd like to get lang/gcc11-devel building because, as I wrote before, it serves as CI-like port to make sure it builds. I know no port depends on that, but you still added ARM patch :) Could you then patch PPC as well?
Comment 23 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-13 19:15:15 UTC
I mean elfv2 of course.
Comment 24 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-16 13:10:37 UTC
For lang/gcc9-devel, you didn't commit files/extra-patch-libgcc_config_rs6000_t-crtstuff.
Comment 25 Gerald Pfeifer freebsd_committer freebsd_triage 2020-05-25 17:39:45 UTC
(In reply to Piotr Kubaj from comment #21)
> I also tried adding CONFIGURE_ARGS+=--with-stage1-cflags="-O0", but
> that doesn't help.

Hmm, that was a good catch of yours!  To bad it did not work, either. :-(

I think we have tried pretty much everything we reasonably could, and have
to face the conclusion that for powerpc in particular GCC 4.2 simply is 
really old and fragile, so we'll have to live with the settings you found.

How long until the last version of FreeBSD/powerpc with (only) GCC 4.2
goes end of life?
Comment 26 Gerald Pfeifer freebsd_committer freebsd_triage 2020-05-25 17:48:24 UTC
(In reply to Piotr Kubaj from comment #24)
> For lang/gcc9-devel, you didn't commit
> files/extra-patch-libgcc_config_rs6000_t-crtstuff.

That was not intentional.  Can you confirm that this is the only missing
piece for lang/gcc9-devel to fully work for you (compared to lang/gcc9),
and I'll take care - it's already in my tree here.
Comment 27 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-26 19:41:18 UTC
(In reply to Gerald Pfeifer from comment #26)
files/patch-gcc_dumpfile.c is also missing.

Another thing is that gcc9-devel port built with base gcc seems to bundle share/info/gcc9/libitm.info in the package (needed in pkg-plist). It doesn't happen with lang/gcc9 port. I'm not sure why this file is not present when building with gcc8.
Comment 28 Gerald Pfeifer freebsd_committer freebsd_triage 2020-05-26 22:30:15 UTC
(In reply to Piotr Kubaj from comment #27)
> files/patch-gcc_dumpfile.c is also missing.

Actually c00568f376078129196740d83946d54dc5437401 is missing - that
should have been backported upstream (and then flow into the weekly
snapshots). Let me look into that.
Comment 29 Gerald Pfeifer freebsd_committer freebsd_triage 2020-05-26 22:55:30 UTC
(In reply to Piotr Kubaj from comment #22)
> I don't want to open a new bug for that or reopen the old one.
>
> I'd like to get lang/gcc11-devel building because, as I wrote before,
> it serves as CI-like port to make sure it builds. I know no port depends
> on that, but you still added ARM patch :) Could you then patch PPC as well?

The Arm patch is an unfortunate example. It shows a local patch we are
stuck with "forever" and anyone building from pristine upstream sources
will get something not fully compatible. (And I have not added it, just
svn cp-ed it again and again as part of the whole port whenever a new
version came up.)

GCC HEAD, which feeds lang/gcc11-devel, just made C++ 11 a requirement which
means GCC 4.2 is out of the picture for real now.  This renders the situation
quite different, and in any case - yes, let's use this in a CI-like manner
- in the sense of testing close to upstream and working to tackle things
upstream.


To summarize, let's focus on gcc9-devel and the gcc10/gcc10-devel ports with
priority to ensure those are fine, since those are what our users will primarily run for the next year.

And in parallel work upstream for anything that's needed for gcc11-devel.
Thanks to weekly snapshots we'll quickly pick up any changes.
Comment 30 Piotr Kubaj freebsd_committer freebsd_triage 2020-05-27 00:23:42 UTC
> How long until the last version of FreeBSD/powerpc with (only) GCC 4.2 goes end of life?

Mell, stable/12 uses GCC and will use it until its EOL, which is 2024. That said, I'm not planning to keep fixing it after 13.0-RELEASE is available.
Comment 31 commit-hook freebsd_committer freebsd_triage 2020-05-27 09:41:52 UTC
A commit references this bug:

Author: gerald
Date: Wed May 27 09:41:37 UTC 2020
New revision: 536683
URL: https://svnweb.freebsd.org/changeset/ports/536683

Log:
  Pull in files/extra-patch-libgcc_config_rs6000_t-crtstuff from r532950
  to work around the 13 years old GCC 4.2 system compiler on powerpc64 in
  those cases we are using that.

  PR:		245511
  Submitted by:	pkubaj

Changes:
  head/lang/gcc9-devel/Makefile
  head/lang/gcc9-devel/files/extra-patch-libgcc_config_rs6000_t-crtstuff
Comment 32 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-16 12:59:06 UTC
Is there any difference between lang/gcc9 and lang/gcc9-devel ports?

The reason I ask is that lang/gcc9-devel doesn't currently build on powerpc64 elfv1 and I can't find out why. Obviously it could be because of a bug in code, but I tested also the first snapshot after 9.3.0 release and it also fails.

I think it could be something in the port's Makefile.
Comment 33 Gerald Pfeifer freebsd_committer freebsd_triage 2020-07-17 09:31:03 UTC
(In reply to Piotr Kubaj from comment #32)
> Is there any difference between lang/gcc9 and lang/gcc9-devel ports?

None that I intentionally made or am aware of (outside of the natural
ones, such as different CONFLICTS,...), and none related to building.

> The reason I ask is that lang/gcc9-devel doesn't currently build on powerpc64
> elfv1 and I can't find out why. Obviously it could be because of a bug in code, > but I tested also the first snapshot after 9.3.0 release and it also fails.
>
> I think it could be something in the port's Makefile.

This is odd.  There is a few extra whitespace changes in the Makefile,
but `diff -w lang/gcc9-devel/ lang/gcc9/` does not show anything that
looks odd.

Do you spot anything you are wondering about?


How about the last snapshot before the 9.3.0 release? In theory something
could have broken around the release time (though that's unlikely, but...)
Comment 34 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-18 18:51:14 UTC
I just tried 9-20200229. Same error:
cp /usr/ports/lang/gcc9-devel/work/gcc-9-20200229/gcc/../fixincludes/README-fixinc include-fixed/README
chmod a+r include-fixed/README
echo timestamp > stmp-int-hdrs
/usr/ports/lang/gcc9-devel/work/.build/./gcc/xgcc -B/usr/ports/lang/gcc9-devel/work/.build/./gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=/usr/ports/lang/gcc9-devel/work/gcc-9-20200229/gcc/testsuite/selftests
cc1: internal compiler error: Segmentation fault
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
gmake[5]: *** [/usr/ports/lang/gcc9-devel/work/gcc-9-20200229/gcc/c/Make-lang.in:124: s-selftest-c] Error 1
gmake[5]: Leaving directory '/usr/ports/lang/gcc9-devel/work/.build/gcc'
gmake[4]: *** [Makefile:4662: all-stage1-gcc] Error 2
gmake[4]: Leaving directory '/usr/ports/lang/gcc9-devel/work/.build'
gmake[3]: *** [Makefile:22474: stage1-bubble] Error 2
gmake[3]: Leaving directory '/usr/ports/lang/gcc9-devel/work/.build'
gmake[2]: *** [Makefile:22806: bootstrap-lean] Error 2
gmake[2]: Leaving directory '/usr/ports/lang/gcc9-devel/work/.build'
*** Error code 1

Meawhile,lang/gcc9 9.3.0_1 builds on pylon:
http://pylon.nyi.freebsd.org/data/latest-per-pkg/gcc9/9.3.0_1/121powerpc64-quarterly.log

Nothing comes to my head. Is it possible that GCC build chain detects whether I use a snapshot or a release and sets different flags for each?
Comment 35 Gerald Pfeifer freebsd_committer freebsd_triage 2020-07-18 19:38:57 UTC
(In reply to Piotr Kubaj from comment #34)
> Nothing comes to my head. Is it possible that GCC build chain detects
> whether I use a snapshot or a release and sets different flags for each?

Release branches differ from mainline/head (so gcc9 and gcc9-devel should
differ from gcc11-devel), but from what I understand releases from a release
branch and snapshots from the same branch should not.

This is really puzzling.

Is this happening witH GCC 4.2? If so, maybe we should simply build with
clang?
Comment 36 Piotr Kubaj freebsd_committer freebsd_triage 2020-07-18 19:54:38 UTC
Yes, this is happening with GCC 4.2.

It's not possible to use Clang with that environment.

Reminder:
GCC 4.2 uses ELFv1 ABI, Clang doesn't work there. GCC 4.2 is used until late December's head.
Clang uses ELFv2 ABI and GCC 4.2 can't be used there. This is since late December on head.

So only head currently uses Clang. Older branches are still on GCC 4.2 and will need to be until their EOL, since we can't change ABI on stable. Switching from ELFv1 to ELFv2 requires OS reinstallation. It's also not possible to mix binaries from two ABI's (apart from using chroots / jails or VM).
Comment 37 Gerald Pfeifer freebsd_committer freebsd_triage 2020-10-05 12:05:21 UTC
With a number of patches committed triggered by this PR and related ones,
and no updates since July, I believe we can close this?