Bug 238249 - devel/psptoolchain-gcc-stage2: fix build with GCC-based architectures
Summary: devel/psptoolchain-gcc-stage2: fix build with GCC-based architectures
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Piotr Kubaj
URL:
Keywords: needs-qa
Depends on: 238770
Blocks:
  Show dependency treegraph
 
Reported: 2019-05-30 18:52 UTC by Piotr Kubaj
Modified: 2019-07-08 06:59 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (tphilipp)
koobs: merge-quarterly?


Attachments
patch (497 bytes, patch)
2019-05-30 18:52 UTC, Piotr Kubaj
pkubaj: maintainer-approval? (tphilipp)
Details | Diff
log (52.66 KB, application/x-xz)
2019-05-31 15:06 UTC, Piotr Kubaj
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer 2019-05-30 18:52:54 UTC
Created attachment 204724 [details]
patch

Building on GCC architectures requires adding CXXFLAGS_FOR_TARGET="-O0" BOOT_CFLAGS="-O0" to MAKE_ENV.

Otherwise:
/wrkdirs/usr/ports/devel/psptoolchain-gcc-stage2/work/.build/psp/libstdc++-v3/include/ostream:219:43: internal compiler error: Segmentation fault
Please submit a full bug report,
Comment 1 Tassilo Philipp 2019-05-31 14:17:37 UTC
Thanks for your PR. Unfortunately, I cannot reproduce the actual problem, can you share some more information about what your build environment is? I guess you mean that your base system is set up to use GCC and not clang?
Can you provide the build log file?
Thanks
Comment 2 Piotr Kubaj freebsd_committer 2019-05-31 15:06:55 UTC
Created attachment 204743 [details]
log

(In reply to Tassilo Philipp from comment #1)
I build ports on powerpc64. It still uses GCC 4.2 in base instead of Clang.

Here's a log file attached.
Comment 3 Tassilo Philipp 2019-06-02 15:45:47 UTC
Thanks! Give me a few days to look at it. There are a few things I want to check (correct me if I'm wrong on any point):
- from what I see, the segfault happens with a faulty xgcc, itself built by the base gcc 4.2
- your patch looks fine, b/c it won't really matter if the toolchain's gcc is a bit less optimized
- however, I want to run some tests still if the psptoolchain produces working psp binaries
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2019-06-03 02:15:36 UTC
Reporter is committer, assign accordingly

Note: Build fixes are blanket approval candidates (if this issue is applicable)

Approved by: portmgr (blanket: build fix)
Comment 5 Tassilo Philipp 2019-06-05 14:18:03 UTC
I am still investigating on why this broke. I'm currently looking into a change done by antoine as a potential culprit, namely: https://reviews.freebsd.org/rP499897#change-iee5fTGYlh3m

I don't think that this changes anything, but want to exclude this first. I am not sure why this was added to begin with, especially with a comment that it doesn't work anyways with gcc < 4.9: In this case that change doesn't make sense for the psptoolchain-newlib and gcc-stage2 ports, as they are intentionally built iwth gcc 4.6.

This is just for reference, I'll report back once I know more.
Comment 6 Tassilo Philipp 2019-06-05 14:33:19 UTC
@Piotr: do you remember what you built this port with when you originally submitted the patch for PR 232744 to psptoolchain-gcc-stage1 (which is this port's master port). Also gcc 4.2?

Thanks
Comment 7 Piotr Kubaj freebsd_committer 2019-06-05 15:48:25 UTC
(In reply to Tassilo Philipp from comment #5)
This change doesn't matter, the port didn't build before. I haven't successfully built this port before using change in this PR. It's just that I was busy fixing other ports.
Comment 8 Tassilo Philipp 2019-06-05 16:07:41 UTC
Ok, thanks for the info.

So I have some new insight. Scratch my previous comment (5), I misread the comment in the code.

This opened a can of worms, though, as the change from antoine I mentioned is indeed problematic.
I now understand why this change was made (b/c without the SSP_CFLAGS?= line it won't compile b/c -fstack-protector-strong would be the default), it is wrong to use this for the pspsdk, b/c there is no libssp at all on this platform. So by now building the SDK with this flag (or the default) will break the psptoolchain entirely, as trying to use it in a proect will result in undefined symbols.

So, let me fix this first, submit patches for that that keep antoine's logic, but provide the correct flags, then get back to the issue you reported.

I'm sorry I didn't spot this before, but those problematic changes were done without checking back with the maintainer and I guess they were more concerned about not breaking port builds.
Comment 9 Tassilo Philipp 2019-06-05 21:19:23 UTC
"Good" news, I can repro the issue when using gcc. I actually can repro this even on the master port (psptoolchain-gcc-stage1) when using gcc 4.8.

I'll implement the logic of your patch in the master port's Makefile, so this will then fix both.
Comment 10 Tassilo Philipp 2019-06-06 16:59:14 UTC
I think I found the real culprit leading to this segfault, which is an out of bounds access in the built gcc 4.6.2 (in actually both xgcc and the final psp-gcc), which is fixed in the gcc 4.7 [1]. The fix seems to work for me, not needing the -O0 anymore, and the resulting psp-gcc seems to build correct psp binaries.

While investigating it, I noticed that psptoolchain's upstream moved from gcc 4.6.2 to 4.9.3, last year.

So, I guess I'll do the same, updating this port to build psp-gcc 4.9.3, which should implicitly fix this issue.

I'll prepare the upgrade, make sure it all works, and submit it as a PR once done. I'll keep this PR here open until then.

Thanks

[1] https://gcc.gnu.org/viewcvs/gcc/branches/gcc-4_7-branch/gcc/ira-int.h?r1=191605&r2=191604&pathrev=191605
Comment 11 Kurt Jaeger freebsd_committer 2019-06-30 21:16:24 UTC
Does this PR still apply after the psptoolchain-gcc-stage* update ?
Comment 12 commit-hook freebsd_committer 2019-07-02 08:14:12 UTC
A commit references this bug:

Author: pkubaj
Date: Tue Jul  2 08:13:56 UTC 2019
New revision: 505662
URL: https://svnweb.freebsd.org/changeset/ports/505662

Log:
  devel/psptoolchain-gcc-stage2: fix build with GCC-based architectures

  Add USES=compiler:c11:
  cc1: error: unrecognized command line option "-Wno-reserved-user-defined-literal"

  PR:		238249
  Approved by:	mentors (implicit approval)

Changes:
  head/devel/psptoolchain-gcc-stage1/Makefile
Comment 13 Piotr Kubaj freebsd_committer 2019-07-05 11:50:30 UTC
stage1 now compiles, but there's an error when compiling stage2:
In file included from /wrkdirs/usr/ports/devel/psptoolchain-gcc-stage2/work/gcc-4.9.3/gcc/cp/except.c:1013:
cfns.gperf:101:1: error: 'const char* libc_name_p(const char*, unsigned int)' redeclared inline with 'gnu_inline' attribute
Comment 14 Tassilo Philipp 2019-07-08 06:59:29 UTC
thanks for the report, will try to repro