Bug 284441 - lang/gcc and -static option lead to segfaults
Summary: lang/gcc and -static option lead to segfaults
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Lorenzo Salvadore
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-29 17:46 UTC by sgk
Modified: 2025-02-10 18:21 UTC (History)
3 users (show)

See Also:
salvadore: maintainer-feedback+


Attachments
Patch for lang/gcc14 (778 bytes, patch)
2025-01-30 20:51 UTC, sgk
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sgk 2025-01-29 17:46:31 UTC
I recently reported an issue with lang/gcc14 and static linking.  The email trail
is here:

https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html

kib has fixed FreeBSD to avoid the issue, and commit a change to top-of-tree:

https://lists.freebsd.org/archives/dev-commits-src-main/2025-January/029575.html

dim has provided a patch for lang/gcc14 and I've tested that patch with 
top-of-tree gcc sources.  He sent the patch to GCC here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

If there is soemone involved with the lang/gccXX ports and they have commit
access to gcc git repository, you may want to commit the change.

For this report, I know lang/gcc14. Other ports may also have a problem.
Comment 1 sgk 2025-01-30 20:51:11 UTC
Created attachment 257135 [details]
Patch for lang/gcc14

To move this along, here's a patch for lang/gcc14.
Comment 2 Lorenzo Salvadore freebsd_committer freebsd_triage 2025-01-31 08:52:08 UTC
Thanks for the patch, which is definitely helpful!

I am going to test it and commit it to all the GCC ports. I am going to start with the -devel ports, then if everything is all right I will move to the production ports. I believe it will not take long.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-02-04 08:17:28 UTC
A commit in branch main references this bug:

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

commit aac6274e7a2e0d07771a1989be1ad73d2844afba
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-02-02 08:20:42 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-04 08:16:34 +0000

    lang/gcc14-devel: Fix segfaults for static binaries

    Fix segmentation faults caused by -static flag into compiled binaries.

    Email thread: https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html
    Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

    PR:             284441
    Reported by:    kargl

 lang/gcc14-devel/Makefile                             |  1 +
 lang/gcc14-devel/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-02-04 08:17:30 UTC
A commit in branch main references this bug:

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

commit 07afa7646b3889d74a77e1f0206b350404baca4a
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-02-03 16:01:00 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-04 08:16:35 +0000

    lang/gcc15-devel: Fix segfaults for static binaries

    Fix segmentation faults caused by -static flag into compiled binaries.

    Email thread: https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html
    Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

    PR:             284441
    Reported by:    kargl

 lang/gcc15-devel/Makefile                             |  1 +
 lang/gcc15-devel/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-02-04 08:17:31 UTC
A commit in branch main references this bug:

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

commit 168cb3d94f79d676bb4155c15dcfcf6a48756b6d
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-01-31 09:34:06 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-04 08:16:33 +0000

    lang/gcc12-devel: Fix segfaults for static binaries

    Fix segmentation faults caused by -static flag into compiled binaries.

    Email thread: https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html
    Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

    PR:             284441
    Reported by:    kargl

 lang/gcc12-devel/Makefile                             |  1 +
 lang/gcc12-devel/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-02-04 08:17:32 UTC
A commit in branch main references this bug:

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

commit 670c92d6ac8df54055d4403d51d287a5d75cd93b
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-02-01 10:41:25 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-04 08:16:33 +0000

    lang/gcc13-devel: Fix segfaults for static binaries

    Fix segmentation faults caused by -static flag into compiled binaries.

    Email thread: https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html
    Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

    PR:             284441
    Reported by:    kargl

 lang/gcc13-devel/Makefile                             |  1 +
 lang/gcc13-devel/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 7 Gerald Pfeifer freebsd_committer freebsd_triage 2025-02-08 16:43:48 UTC
I just pushed Dim's patch to upstream GCC, so the next GCC 15 snapshot
should have it:

  https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675392.html

I plan on swiftly backporting to the GCC 14 branch as well, so the next
GCC 14 snapshot and (later) GCC 14.x release should have it as well.

If all goes well I plan on pushing back to GCC 13 as well and a bit
later GCC 12, and we can gradually drop the local patches.
Comment 8 Gerald Pfeifer freebsd_committer freebsd_triage 2025-02-09 11:26:44 UTC
I just pushed this patch to the upstream gcc-14 branch.
Comment 9 commit-hook freebsd_committer freebsd_triage 2025-02-10 18:21:43 UTC
A commit in branch main references this bug:

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

commit b200c1e6d242f9acadf58984d972040320e6cf85
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2025-02-10 10:55:09 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-10 18:19:53 +0000

    lang/gcc15-devel: Update to 15.0.1.s20250209

    Also remove recently added patch that fixed binaries compiled with the
    -static option as it has been merged upstream with commit
    06e5b0b4a244090abfea333d91fc5963292cb41d.

    PR:             284441

 lang/gcc15-devel/Makefile                              |  2 +-
 lang/gcc15-devel/distinfo                              |  6 +++---
 lang/gcc15-devel/files/patch-libgcc-config.host (gone) | 11 -----------
 3 files changed, 4 insertions(+), 15 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-02-10 18:21:45 UTC
A commit in branch main references this bug:

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

commit 6f5f51aaee2e3d4b217eebeccc64850b924e414a
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-02-04 09:08:43 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-10 18:18:05 +0000

    lang/gcc12: Fix segfaults for static binaries

    Fix segmentation faults caused by -static flag into compiled binaries.

    Email thread: https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html
    Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

    PR:             284441
    Reported by:    kargl

 lang/gcc12/Makefile                             |  1 +
 lang/gcc12/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 11 commit-hook freebsd_committer freebsd_triage 2025-02-10 18:21:46 UTC
A commit in branch main references this bug:

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

commit 17c3f4ae6778531b634603266777f838a77d306e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-02-04 12:11:11 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-10 18:18:50 +0000

    lang/gcc14: Fix segfaults for static binaries

    Fix segmentation faults caused by -static flag into compiled binaries.

    Email thread: https://lists.freebsd.org/archives/freebsd-hackers/2025-January/004236.html
    Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118685

    PR:             284441
    Reported by:    kargl

 lang/gcc14/Makefile                             |  2 +-
 lang/gcc14/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)