Bug 284441 - lang/gcc and -static option lead to segfaults
Summary: lang/gcc and -static option lead to segfaults
Status: Closed FIXED
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-03-12 14:35 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(-)
Comment 12 Lorenzo Salvadore freebsd_committer freebsd_triage 2025-02-14 21:07:57 UTC
Sorry, but this cannot be closed yet: I am still missing patching lang/gcc13.
Unless someone has urgency for this patch on that version, I prefer to wait for the end of the exp-run for upgrading GCC_DEFAULT to version 14. This should reduce the amount of ports rebuilding our users need.
Comment 13 Gerald Pfeifer freebsd_committer freebsd_triage 2025-02-17 12:08:08 UTC
I pushed this to the upstream gcc-13 branch, so this week's snapshot
should have it (lang/gcc13-devel) and when GCC 13.4 is released
lang/gcc13 will get it automatically.

That said...

(In reply to Lorenzo Salvadore from comment #12)
> Sorry, but this cannot be closed yet: I am still missing patching
> lang/gcc13. Unless someone has urgency for this patch on that version,
> I prefer to wait for the end of the exp-run for upgrading GCC_DEFAULT
> to version 14.

...this fixes a user reported but, so my recommendation is to fix
lang/gcc13 rather sooner than later.

Yes, there may be an extra rebuild somewhere, but users concerned
can also block that. Still preferable over just a single users getting
hit by it and losing hours of human time?
Comment 14 commit-hook freebsd_committer freebsd_triage 2025-02-18 14:55:23 UTC
A commit in branch main references this bug:

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

commit 5f4e8f86e731841de99fbd6a9e725f5300dc47b1
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2025-02-16 07:50:19 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-18 14:54:15 +0000

    lang/gcc14-devel: Update to 14.2.1.s20250215

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

    PR:             284441

 lang/gcc14-devel/Makefile                              |  2 +-
 lang/gcc14-devel/distinfo                              |  6 +++---
 lang/gcc14-devel/files/patch-libgcc-config.host (gone) | 11 -----------
 3 files changed, 4 insertions(+), 15 deletions(-)
Comment 15 Gerald Pfeifer freebsd_committer freebsd_triage 2025-02-20 15:21:03 UTC
I now also pushed this to the upstream gcc-12 branch, so the next
snapshot should have it (lang/gcc12-devel) as should the 12.5 release
(lang/gcc12).
Comment 16 commit-hook freebsd_committer freebsd_triage 2025-02-25 15:21:37 UTC
A commit in branch main references this bug:

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

commit 057a404471cfa75ec1ec5866e78ad91ec943a9e9
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2025-02-22 13:20:53 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-25 15:16:59 +0000

    lang/gcc13-devel: Update to 13.3.1.s20250221

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

    PR:         284441

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

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

commit 75136e9b6bb4a5c88f45cf5f285499c737810ae2
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2025-02-21 15:19:02 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-02-25 15:16:56 +0000

    lang/gcc12-devel: Update to 12.4.1.s20250220

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

    PR:         284441

 lang/gcc12-devel/Makefile                              |  2 +-
 lang/gcc12-devel/distinfo                              |  6 +++---
 lang/gcc12-devel/files/patch-libgcc-config.host (gone) | 11 -----------
 3 files changed, 4 insertions(+), 15 deletions(-)
Comment 18 commit-hook freebsd_committer freebsd_triage 2025-03-12 14:31:33 UTC
A commit in branch main references this bug:

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

commit f1c61d6af201a3d60445b0619e1bf97390ac78cd
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-03-12 09:33:16 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2025-03-12 14:30:43 +0000

    lang/gcc13: 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/Makefile                             |  1 +
 lang/gcc13/files/patch-libgcc-config.host (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 19 Lorenzo Salvadore freebsd_committer freebsd_triage 2025-03-12 14:35:39 UTC
All ports for supported GCC versions have been patched. Thanks!

Since the GCC_DEFAULT upgrade will take longer than planned, I have committed the patch for lang/gcc13 too.