Bug 287211 - lang/gcc13: gfortran doesn't find libgfortran.spec on riscv64
Summary: lang/gcc13: gfortran doesn't find libgfortran.spec on riscv64
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: riscv Any
: --- Affects Some People
Assignee: Thierry Thomas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-01 11:35 UTC by Laurent Chardon
Modified: 2025-06-08 20:47 UTC (History)
4 users (show)

See Also:
salvadore: maintainer-feedback+


Attachments
failed configure log (491.95 KB, text/plain)
2025-06-01 11:35 UTC, Laurent Chardon
no flags Details
Patch for Mk/Uses/fortran.mk (946 bytes, patch)
2025-06-07 16:44 UTC, Thierry Thomas
thierry: maintainer-approval+
Details | Diff
Patch for Mk/Uses/fortran.mk (1.72 KB, patch)
2025-06-08 20:47 UTC, Thierry Thomas
thierry: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Chardon 2025-06-01 11:35:55 UTC
Created attachment 260862 [details]
failed configure log

While testing net/openmpi on riscv64, I found that gfortran tests in ./configure fail for not finding the file libgfortran.spec.

I fixed it temporarily in net/openmpi, but the issue should be fixed in gcc13 (and later?) itself.

# gfortran doesn't find libgfortran.spec on riscv64                                                                              
.if ${ARCH} == "riscv64"                                                                                                         
FCFLAGS+=  -B${LOCALBASE}/lib/gcc${GCC_DEFAULT}                                                                                  
.endif

I don't need this patch with amd64, i386 or aarch64.
Comment 1 Laurent Chardon 2025-06-01 11:37:58 UTC
The good bit in the log file is this:


configure:29488: checking if Fortran compiler works
configure:29520: gfortran13 -o conftest -Wl,-rpath=/usr/local/lib/gcc13 -fallow-argument-mismatch  -Wl,-rpath=/usr/local/lib/gcc13  -L/usr/local/lib/gcc13 -fstack-protector-strong   conftest.f -L/usr/local/lib >&5
gfortran13: fatal error: cannot read spec file 'libgfortran.spec': No such file or directory
compilation terminated.
configure:29520: $? = 1
configure: program exited with status 1
configure: failed program was:
|       program main
| 
|       end
configure:29537: result: no
configure:29552: error: Could not run a simple Fortran program.  Aborting.
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-06-02 01:49:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=aa66bd5c025a60c8666684914aa766baa9c49c26

commit aa66bd5c025a60c8666684914aa766baa9c49c26
Author:     Laurent Chardon <laurent.chardon@gmail.com>
AuthorDate: 2025-06-02 01:28:48 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-06-02 01:40:19 +0000

    net/openmpi: Update 5.0.7 => 5.0.8

    Changelog:
    https://docs.open-mpi.org/en/v5.0.8/release-notes/changelog/v5.0.x.html

    Replace PORTVERSION with DISTVERSION in MASTER_SITES.
    Fix warnings from portclippy.
    Add workaround for gfortran on riscv64.

    PR:     287212 287211

 net/openmpi/Makefile  | 13 ++++++++-----
 net/openmpi/distinfo  |  6 +++---
 net/openmpi/pkg-plist | 11 +++++++++--
 3 files changed, 20 insertions(+), 10 deletions(-)
Comment 3 Lorenzo Salvadore freebsd_committer freebsd_triage 2025-06-07 14:57:37 UTC
This is an issue for the fortran@ team, so I assign it to it. I also add Thierry and Steve who are in the team according to https://wiki.freebsd.org/Fortran .

At first glance I would say that FCFLAGS+=  -B${LOCALBASE}/lib/gcc${GCC_DEFAULT} needs to be added to Uses/fortran.mk, however I have no idea why this is necessary on riscv64 only.
Comment 4 Thierry Thomas freebsd_committer freebsd_triage 2025-06-07 16:44:23 UTC
Created attachment 261068 [details]
Patch for Mk/Uses/fortran.mk

The attached patch should not break anything.

Laurent, could you please check if it fixes your issue?
Comment 5 Laurent Chardon 2025-06-07 19:22:04 UTC
Thanks Thierry for the patch!

I'm away for a couple of weeks, I'll test when I come back. 

In the meantime, and just looking at the info included in the patch patch since I'm on my phone, should it be gcc${_GCC_VER} instead of gcc${GCC_DEFAULT}?
Comment 6 Thierry Thomas freebsd_committer freebsd_triage 2025-06-08 20:47:02 UTC
Created attachment 261095 [details]
Patch for Mk/Uses/fortran.mk

Yes, you're right, thanks!
ATM _GCC_VER and GCC_DEFAULT have the same value, but it might change.