Bug 272759 - lang/gcc12: Only for arches not including riscv (blocks 310 packages on my list)
Summary: lang/gcc12: Only for arches not including riscv (blocks 310 packages on my list)
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: riscv Any
: --- Affects Many People
Assignee: Jessica Clarke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-27 16:29 UTC by dgilbert
Modified: 2024-03-21 23:50 UTC (History)
6 users (show)

See Also:
salvadore: maintainer-feedback+


Attachments
Poudriere log fragment with the error. (6.24 KB, text/plain)
2023-07-28 17:42 UTC, dgilbert
no flags Details
Proposed fix (958 bytes, patch)
2023-07-28 18:11 UTC, Jessica Clarke
no flags Details | Diff
v0 (5.99 KB, patch)
2023-11-28 07:54 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dgilbert 2023-07-27 16:29:45 UTC
poudriere build for gcc12 fails:

is only for aarch64 amd64 arm armv6 armv7 i386 powerpc powerpc64 powerpc64le, while you are running riscv64

This failure then skips 310 more packages in my list.

Now... gcc12 clearly _does_ support riscv... so that's one fix.  Alternatively (I wouldn't care) things that require gcc to build could require a gcc that does build in poudriere on FreebSD.
Comment 1 dgilbert 2023-07-28 17:36:41 UTC
So I made the obvious patch to allow arch riscv64 in the FreeBSD port Makefile.  After some hours of poudriere churning, I get a raft of errors from libgfortran:

In file included from /wrkdirs/usr/ports/lang/gcc12/work/gcc-12.2.0/libgfortran/runtime/fpu.c:29:
[06:39:04] ./fpu-target.h:44:3: error: unknown type name 'choke'
[06:39:04]    44 |   choke me
[06:39:04]       |   ^~~~~

... it goes on, but you can look it up in the attached poudriere log.

This poudriere log was made on a riscv unmatched with the following kernel and userland:

FreeBSD ump.daveg.ca 14.0-CURRENT FreeBSD 14.0-CURRENT riscv64 1400093 #0 main-n264297-b03012d0b600-dirty: Wed Jul 26 04:04:24 EDT 2023     root@ump.daveg.ca:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC riscv
Comment 2 dgilbert 2023-07-28 17:39:25 UTC
Well... that build log is too big.  This is my poudriere link to the log:

https://riscv.daveg.ca/data/freebsd14-HEAD/2023-07-27_17h44m41s/logs/errors/gcc12-12.2.0_6.log

Since the whole log is too big, I will cut out the relevant section and upload that as a long (since the bug tracking is more permanent a record than my poudriere logs)...
Comment 3 dgilbert 2023-07-28 17:42:12 UTC
Created attachment 243670 [details]
Poudriere log fragment with the error.
Comment 4 Jessica Clarke freebsd_committer freebsd_triage 2023-07-28 17:57:08 UTC
If you follow it back, normally on FreeBSD we (confusingly) use fpu-glibc.h for cpu-target.h, but that requires feenableexcept to exist. However, riscv64 has feenableexcept as a static inline function in its fenv.h, and GCC's configure scripts aren't prepared for that, so they think it doesn't exist, fall back on fpu-sysv.h and then the build dies because riscv64 (like every non-x86 architecture) doesn't implement either of fp(re)setsticky.
Comment 5 Jessica Clarke freebsd_committer freebsd_triage 2023-07-28 18:11:15 UTC
Created attachment 243671 [details]
Proposed fix

Can you confirm whether the attached fixes the issue? This should match the semantics of glibc's implementation (we shouldn't be reporting success when asked to actually enable exceptions), and aligns symbol exporting with x86 and powerpc (though arm also exports fegetexcept, and aarch64 doesn't export any of them like current riscv (libgfortran has its own aarch64-specific implementation so nobody noticed), so the situation is a bit inconsistent and unprincipled).
Comment 6 dgilbert 2023-07-28 18:34:44 UTC
NB: for others: I had to remove the ^M's from the patch to apply it.
Comment 7 Jessica Clarke freebsd_committer freebsd_triage 2023-07-28 18:37:45 UTC
(In reply to dgilbert from comment #6)

Depending on how you download the patch, Bugzilla helpfully does that. Copying from https://bugs.freebsd.org/bugzilla/attachment.cgi?id=243671&action=edit avoids the issue.
Comment 8 Piotr Kubaj freebsd_committer freebsd_triage 2023-07-29 08:06:11 UTC
(In reply to Jessica Clarke from comment #4)
We had exactly the same issue on powerpc*, it was fixed in https://cgit.freebsd.org/src/commit/?id=448c505c33cc334193590f3844406d6a74f26e2a.
There's still time to do the same for riscv64 before releng/14.0.
Comment 9 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-07-29 09:45:48 UTC
Please note that riscv64 is not a tier 1 platform at the moment: it is a tier 3 platform on FreeBSD 12 and tier 2 on FreeBSD 13 and 14, so support is limited.
https://www.freebsd.org/platforms/

Unfortunately I lack the resources for testing riscv64 too properly, so please feel free to propose patches, test them and commit them.

Also please note that the issue described here most probably involves GCC 12 as default GCC version, but I am planning to switch it to GCC 13 soon, so you should probably fix lang/gcc13 as well. Fixing lang/gcc14-devel could also be helpful for the future as lang/gcc14 will be created from lang/gcc14-devel when GCC 14 will be released (it will not happen soon).

Thanks.
Comment 10 Gerald Pfeifer freebsd_committer freebsd_triage 2023-08-27 20:35:50 UTC
I recommend making GCC 13 the GCC_DEFAULT for riscv64 right away,
ahead of changing the default for other architectures, and focus
on that.

Nothing to lose, possibly something to winn...
Comment 11 Mikael Urankar freebsd_committer freebsd_triage 2023-11-28 07:54:11 UTC
Created attachment 246629 [details]
v0

I don't know what I'm doing but the attached patch allows the build to finish.
Comment 12 commit-hook freebsd_committer freebsd_triage 2024-03-21 23:50:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1947a9383ec3a048e334022365aa199a6ae55289

commit 1947a9383ec3a048e334022365aa199a6ae55289
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-03-21 23:45:53 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-03-21 23:48:37 +0000

    msun/riscv: expose fe{disable,enable}except

    This is required for GCC to build.

    PR:             272759
    Reported by:    dgilbert@eicat.ca
    Submitted by:   jrtc27
    Differential Revision:  https://reviews.freebsd.org/D44333

 lib/msun/riscv/Symbol.map | 10 ++++------
 lib/msun/riscv/fenv.h     |  7 +++----
 2 files changed, 7 insertions(+), 10 deletions(-)