From: Jeremie Courreges-Anglas Subject: lang/gcc 11 and 15: fix unwinding and C++ exceptions To: ports@openbsd.org Cc: pascal@openbsd.org, claudio@openbsd.org, tb@openbsd.org, kirill@openbsd.org Date: Mon, 10 Nov 2025 15:27:31 +0100 During the previous months our attempts at using gcc/11 or gcc/15 on sparc64 had faced a crash in devel/boost. The crash was the "gcc_assert (code == _URC_NO_REASON);" in libgcc's uw_init_context_1() meaning the code wasn't able to find frame information. This was reproducible also on amd64 or arm64. The culprit was this check added between gcc 8 and 11: #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ + && defined(TARGET_DL_ITERATE_PHDR) \ && (defined(__OpenBSD__) || defined(__NetBSD__)) # define ElfW(type) Elf_##type # define USE_PT_GNU_EH_FRAME #endif With this additional check we're not using PT_GNU_EH_FRAME any more. TARGET_DL_ITERATE_PHDR in turn wasn't defined because the code in gcc/configure is pretty much hardcoded and nobody noticed the function was needed on OpenBSD just like on Solaris or FreeBSD etc. The diff below addresses that. There is some similar code hardcoding a differently named #define in libgcc/crtstuff.c but the code is apparently not built. Keeping our less-than-optimal habits, this diff: - bumps the revision for all subpackages even though installing just the new gcc-libs subpackage seems enough in my tests. Better safe than sorry. - doesn't add a comment in this already long and undocumented patch-gcc_configure, but I can add a blurb if someone insists. Making progress here was a team effort with claudio and tb! ok? Index: 11/Makefile =================================================================== RCS file: /cvs/ports/lang/gcc/11/Makefile,v diff -u -p -r1.56 Makefile --- 11/Makefile 3 Nov 2025 07:46:20 -0000 1.56 +++ 11/Makefile 10 Nov 2025 14:06:32 -0000 @@ -15,7 +15,7 @@ USE_NOEXECONLY = Yes V = 11.2.0 FULL_VERSION = $V FULL_PKGVERSION = $V -REVISION = 19 +REVISION = 20 ADASTRAP-amd64 = adastrap-amd64-$V-5.tar.xz ADASTRAP-i386 = adastrap-i386-$V-4.tar.xz Index: 11/patches/patch-gcc_configure =================================================================== RCS file: /cvs/ports/lang/gcc/11/patches/patch-gcc_configure,v diff -u -p -r1.2 patch-gcc_configure --- 11/patches/patch-gcc_configure 11 Mar 2022 19:28:58 -0000 1.2 +++ 11/patches/patch-gcc_configure 10 Nov 2025 14:06:05 -0000 @@ -55,3 +55,13 @@ Index: gcc/configure *) enable_default_ssp=$enableval ;; esac else +@@ -30981,6 +30987,9 @@ case "$target" in + else + gcc_cv_target_dl_iterate_phdr=no + fi ++ ;; ++ *-*-openbsd*) ++ gcc_cv_target_dl_iterate_phdr=yes + ;; + *-*-dragonfly* | *-*-freebsd*) + if grep dl_iterate_phdr $target_header_dir/sys/link_elf.h > /dev/null 2>&1; then Index: 15/Makefile =================================================================== RCS file: /cvs/ports/lang/gcc/15/Makefile,v diff -u -p -r1.10 Makefile --- 15/Makefile 3 Nov 2025 07:46:20 -0000 1.10 +++ 15/Makefile 10 Nov 2025 14:06:41 -0000 @@ -14,7 +14,7 @@ V = 15.2.0 FULL_VERSION = $V FULL_PKGVERSION = $V -REVISION = 0 +REVISION = 1 ADASTRAP-amd64 = adastrap-amd64-11.2.0-5.tar.xz ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz Index: 15/patches/patch-gcc_configure =================================================================== RCS file: /cvs/ports/lang/gcc/15/patches/patch-gcc_configure,v diff -u -p -r1.1.1.1 patch-gcc_configure --- 15/patches/patch-gcc_configure 18 Aug 2025 19:49:24 -0000 1.1.1.1 +++ 15/patches/patch-gcc_configure 10 Nov 2025 14:06:05 -0000 @@ -55,3 +55,13 @@ Index: gcc/configure *) enable_default_ssp=$enableval ;; esac else +@@ -33636,6 +33642,9 @@ $as_echo_n "checking dl_iterate_phdr in target C libra + gcc_cv_target_dl_iterate_phdr=unknown + case "$target" in + *-*-solaris2*) ++ gcc_cv_target_dl_iterate_phdr=yes ++ ;; ++ *-*-openbsd*) + gcc_cv_target_dl_iterate_phdr=yes + ;; + *-*-dragonfly* | *-*-freebsd*) -- jca