Bug 251670 - lang/gcc10: add support for powerpc64le
Summary: lang/gcc10: add support for powerpc64le
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: powerpc Any
: --- Affects Only Me
Assignee: Gerald Pfeifer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-07 16:29 UTC by Piotr Kubaj
Modified: 2021-01-06 12:56 UTC (History)
4 users (show)

See Also:
gerald: maintainer-feedback-


Attachments
patch (5.93 KB, patch)
2020-12-07 16:29 UTC, Piotr Kubaj
pkubaj: maintainer-approval? (gerald)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer freebsd_triage 2020-12-07 16:29:15 UTC
Created attachment 220350 [details]
patch

Upstream PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98181

This will be ported to older GCC versions if necessary.
Comment 1 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-07 16:54:56 UTC
PORTREVISION should be bumped after committing this patch, due to changed CPU tuning.
Comment 2 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-07 18:09:36 UTC
Piotr, thanks for submitting this upstream, too!

I'm ust afraid you missed Andreas T. both there and here, so let me
include him on this PR.  Andreas is FreeBSD src committer and upstream
maintainer for FreeBSD in GCC, so can approve most of your changes.

The sequence of events how it usually should go:

 1. Upstream HEAD (that will become GCC 11)
 2. lang/gcc11-devel picks that up within days
 3. Backport to upstream GCC 10 branch
 4. lang/gcc10-devel picks that up within days
 5. Backport to lang/gcc10
 6. Obsolete local patches as the next GCC 10 release comes out

(Steps 2 and 3 can take place in parallel.)


Let's try not to skip too many of the steps 2-4 (or 1-4). ;-)

It really is the safer, future proof, and in the end easier way.
Comment 3 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-07 20:26:29 UTC
OK then, I will like it will take a long time (we still have to upstream the binutils patch) :/
Comment 4 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-07 21:26:54 UTC
If Andreas has the time (and there is no utter disagreement on the 
general technical approach), we could get this done before Christmas!


One question: Do I understand correctly that the change of default
processor (PROCESSOR_DEFAULT) is orthogonal, and we could (and from
a commit perspective likely should) make that independently?
Comment 5 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-08 00:25:24 UTC
(In reply to Gerald Pfeifer from comment #4)
Yes, the PROCESSOR_DEFAULT change is completely irrelevant to powerpc64le support.

This is simply something I noticed when adding powerpc64le support and IMO this change should be backported to older branches even when you don't add powerpc64le support for performance reasons.
Comment 6 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-11 15:30:13 UTC
(In reply to Gerald Pfeifer from comment #4)
Am I supposed to send the patch myself to gcc-patches? I'm afraid I might do something wrong, I haven't upstreamed any patches to GCC yet.
Comment 7 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-12 15:04:28 UTC
I will somehow find time to start with PROCESSOR_DEFAULT change myself,
which I should be able to get in without problems.


Is the libcpp change essentially independent? If so, let's use that as
a first step?

https://gcc.gnu.org/contribute.html#patches has details, and if you'd
like to share a draft submission with my first, I'll be happy to provide
feedback and make recommendations (on who to copy, etc).

Of course if Andreas is able to help, that'd be even better!
Comment 8 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-12 15:14:06 UTC
libcpp change is a backport of https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d00b1b023ecfc3ddc3fe952c0063dab7529d5f7a which is a patch for my bug report.

It fixes compilation when optimizing for POWER8 or newer. So this patch fixes build on powerpc64 with e.g. CPUTYPE?=power9 set. This also fixes build with powerpc64le, which uses POWER8 as a baseline.
Comment 9 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-12 15:59:28 UTC
(In reply to Piotr Kubaj from comment #8)
> libcpp change is a backport of ...

Ah, lovely. This would have been useful to mention earlier. ;-)

I checked out the GCC 10 branch and noticed this is already there, so
lang/gcc10-devel has it already and the next minor release of GCC 10
will bring this to lang/gcc10.


Do you want to go ahead and commit the libcpp patch to lang/gcc10,
mentioning the above?

Approved by: gerald (maintainer)
Comment 10 commit-hook freebsd_committer freebsd_triage 2020-12-12 16:11:51 UTC
A commit references this bug:

Author: pkubaj
Date: Sat Dec 12 16:11:28 UTC 2020
New revision: 557833
URL: https://svnweb.freebsd.org/changeset/ports/557833

Log:
  lang/gcc10: fix build on powerpc64 with CPUTYPE=power8 or power9, also a partial fix for powerpc64le

  Backport of https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d00b1b023ecfc3ddc3fe952c0063dab7529d5f7a

  PR:		251670
  Approved by:	gerald (maintainer)

Changes:
  head/lang/gcc10/files/patch-libcpp_lex.c
Comment 11 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-13 00:16:57 UTC
I just submitted the processor default patch upstream (and can/will commit
there once approved).

Us having stripped off and taken care of those two separate issues, can 
you submit the remainder upstream?  (You can follow the pattern of my 
submission just now.)
Comment 12 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-20 19:20:57 UTC
Okay, looks like we got everything into upstream (head), Piotr?

For lang/gcc11-devel, is there anything to be done except for adding
powerpc64le to ONLY_FOR_ARCHS with the next snapshot?

(See, I told you we can do get this before Christmas. ;-)
Comment 13 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-20 21:48:50 UTC
(In reply to Gerald Pfeifer from comment #12)
Well, there is still namespace collision regarding vec_step (same as on powerpc64). It was already reported to upstream about a year ago, but they still didn't patch it.
Comment 14 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-21 16:06:07 UTC
Update: We cannot use yesterday's snapshot for lang/gcc11-devel since it's
broken on FreeBSD in at least two different ways.  I submitted a patch for
the first and reported the second.

With a bit of luck things will be resolved next Sunday.

Independently. we can request backport to the GCC 10 branch in the coming
days, which will cover lang/gcc10-devel. Once it landed there, I pre-approve
you back porting to lang/gcc10 itself - just go for it, I'd only appreciate
if you can put everything into one patch file, files/patch-powerpcle or the
like.
Comment 15 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-21 16:17:43 UTC
If the default GCC is not changed to 10 by then, can I also backport this patch to 9, or do I need to make upstream backport to 9 branch as well?
Comment 16 commit-hook freebsd_committer freebsd_triage 2020-12-28 10:18:52 UTC
A commit references this bug:

Author: gerald
Date: Mon Dec 28 10:18:04 UTC 2020
New revision: 559455
URL: https://svnweb.freebsd.org/changeset/ports/559455

Log:
  Update to the 20201226 snapshot of GCC 10.2.1.

  This brings a backport for the RTL optimizers, two for the x86 back end,
  two for the C++ front end, and one for Fortran.

  It also changes the processor defaults for 32- und 64-bit powerpc to
  PPC7450 and POWER8, respectively, per a request by pkubaj@ that I pushed
  upstream. [1]

  PR:		251670 [1]

Changes:
  head/lang/gcc10-devel/Makefile
  head/lang/gcc10-devel/distinfo
Comment 17 Mark Millard 2020-12-28 11:44:07 UTC
(In reply to commit-hook from comment #16)

So, which does "processor defaults" control? . . .

A) just the default -mtune= for the likes of -cpu=powerpc64 or -mcpu=powerpc ?
   (just scheduling, not which instructions/registers are allowed?)

B) the architecture type and/or register usage presumed/mimimum --unless
   -mcpu= is used to pick something specific, such as -mcpu=G5 ?

C) something other combination of things?

I'm guessing (A).
Comment 18 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-28 13:05:36 UTC
(In reply to Mark Millard from comment #17)
This only specifies default -mtune, not -mcpu. So it won't require you to use POWER8 by default. Linux does just the same (apart from defaulting to POWER7 on 32 bits) and it runs on G5 just fine.
Comment 19 commit-hook freebsd_committer freebsd_triage 2020-12-29 11:10:44 UTC
A commit references this bug:

Author: gerald
Date: Tue Dec 29 11:10:38 UTC 2020
New revision: 559562
URL: https://svnweb.freebsd.org/changeset/ports/559562

Log:
  Update to the 20201227 snapshot of GCC 11.0.0.

  This changes the processor defaults for 32- und 64-bit powerpc to
  PPC7450 and POWER8, respectively, per a request by pkubaj@ that I
  pushed upstream. [1]

  Enable the new powerpcle architecture which this snapshot brings in
  via upstream, per a submission by pkubaj@. [1]

  The 20201227 snapshot was broken on FreeBSD (and presumably other
  non-mainstream platforms), so we had to skip it.

  PR:		251670 [1]

Changes:
  head/lang/gcc11-devel/Makefile
  head/lang/gcc11-devel/distinfo
Comment 20 Gerald Pfeifer freebsd_committer freebsd_triage 2020-12-29 11:35:17 UTC
Next steps:

 1. With the next snapshot of GCC 10 development and the lang/gcc10-devel
    update coming with it, I'll enable powerpc64le there.
 
 2. You updating lang/gcc10 accordingly (ideally with just one patch file,
    files/patch-powerpcle or the like), is pre-approved.

    If you want to set DEFAULT_GCC=10 for powerpc64le in
    Mk/bsd.default-versions.mk that is pre-approved as well.

 3. linimon@ has heroically helped readying the tree for updating
    GCC_DEFAULT to 10, which hopefully will land in the next week or two. 

    Should this take longer than a few weeks, we can replay steps 1 and 2
    for GCC 9, though at this point fully focusing our time and energy on
    GCC 10 is my strong preference and recommendation.
Comment 21 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-29 21:37:34 UTC
(In reply to Gerald Pfeifer from comment #20)
Regarding gcc9: powerpc64le support has already been merged to 9 branch, so next gcc9-devel snapshot should enable powerpc64le as well.
Comment 22 commit-hook freebsd_committer freebsd_triage 2020-12-30 03:11:38 UTC
A commit references this bug:

Author: pkubaj
Date: Wed Dec 30 03:11:15 UTC 2020
New revision: 559636
URL: https://svnweb.freebsd.org/changeset/ports/559636

Log:
  lang/gcc10: add support for powerpc64le

  PR:		251670
  Approved by:	gerald@ (maintainer)

Changes:
  head/lang/gcc10/Makefile
  head/lang/gcc10/files/patch-powerpc64le
Comment 23 commit-hook freebsd_committer freebsd_triage 2020-12-30 03:13:39 UTC
A commit references this bug:

Author: pkubaj
Date: Wed Dec 30 03:12:58 UTC 2020
New revision: 559637
URL: https://svnweb.freebsd.org/changeset/ports/559637

Log:
  Switch default GCC for powerpc64le to 10.

  9 does not yet work and the switch to 10 is near.

  PR:		251670
  Approved by:	gerald@ (maintainer)

Changes:
  head/Mk/bsd.default-versions.mk
Comment 24 Piotr Kubaj freebsd_committer freebsd_triage 2020-12-30 03:28:24 UTC
Thanks, committed!
Comment 25 commit-hook freebsd_committer freebsd_triage 2021-01-06 12:56:38 UTC
A commit references this bug:

Author: gerald
Date: Wed Jan  6 12:56:07 UTC 2021
New revision: 560506
URL: https://svnweb.freebsd.org/changeset/ports/560506

Log:
  Update to the 20210102 snapshot of GCC 10.2.1.

  This brings two backports for the aarch64 backend and one for x86,
  plus three for the Fortran front end.

  Enable the new powerpcle architecture which this snapshot brings in
  via upstream, per a submission by pkubaj@. [1]

  This also should fix the build on aarch64 when clang is the bootstrap
  compiler. [2]

  PR:		251670 [1], 250932 [2]

Changes:
  head/lang/gcc10-devel/Makefile
  head/lang/gcc10-devel/distinfo