As recommended by Brad, I've updated the fixes for all necessary platforms so that -static works.
Some platforms already had something like this so this set of patches is for a subset of all platforms. Only tested on amd64. John Index: Makefile =================================================================== RCS file: /cvs/ports/lang/gcc/8/Makefile,v retrieving revision 1.34 diff -u -p -r1.34 Makefile --- Makefile 4 Sep 2020 09:55:34 -0000 1.34 +++ Makefile 9 Sep 2020 18:32:52 -0000 @@ -16,6 +16,7 @@ USE_LLD = No DPB_PROPERTIES = parallel V = 8.4.0 +REVISION = 0 FULL_VERSION = $V FULL_PKGVERSION = $V Index: patches/patch-gcc_config_aarch64_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_aarch64_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_aarch64_openbsd_h --- patches/patch-gcc_config_aarch64_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_aarch64_openbsd_h 9 Sep 2020 18:32:52 -0000 @@ -57,7 +57,7 @@ Index: gcc/config/aarch64/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ ++ %{!shared:%{!static:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}} \ + -L/usr/lib" + +#define OPENBSD_ENTRY_POINT "__start" Index: patches/patch-gcc_config_alpha_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_alpha_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_alpha_openbsd_h --- patches/patch-gcc_config_alpha_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_alpha_openbsd_h 9 Sep 2020 18:32:52 -0000 @@ -17,7 +17,7 @@ Index: gcc/config/alpha/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" + +/* As an elf system, we need crtbegin/crtend stuff. */ +#undef STARTFILE_SPEC Index: patches/patch-gcc_config_arm_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_arm_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_arm_openbsd_h --- patches/patch-gcc_config_arm_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_arm_openbsd_h 9 Sep 2020 18:32:52 -0000 @@ -82,7 +82,7 @@ Index: gcc/config/arm/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ ++ %{!shared:%{!static:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}} \ + %{!nostdlib:-L/usr/lib}" +#endif + Index: patches/patch-gcc_config_i386_openbsdelf_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_i386_openbsdelf_h,v retrieving revision 1.3 diff -u -p -r1.3 patch-gcc_config_i386_openbsdelf_h --- patches/patch-gcc_config_i386_openbsdelf_h 8 Aug 2020 16:48:48 -0000 1.3 +++ patches/patch-gcc_config_i386_openbsdelf_h 9 Sep 2020 18:32:52 -0000 @@ -1,5 +1,7 @@ $OpenBSD: patch-gcc_config_i386_openbsdelf_h,v 1.3 2020/08/08 16:48:48 sthen Exp $ +Test shared and static before adopting dynamic. + Index: gcc/config/i386/openbsdelf.h --- gcc/config/i386/openbsdelf.h.orig +++ gcc/config/i386/openbsdelf.h @@ -10,7 +12,7 @@ Index: gcc/config/i386/openbsdelf.h + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" -+ %{!shared:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}} \ + -L/usr/lib" #undef STARTFILE_SPEC Index: patches/patch-gcc_config_mips_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_mips_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_mips_openbsd_h --- patches/patch-gcc_config_mips_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_mips_openbsd_h 9 Sep 2020 18:32:52 -0000 @@ -142,7 +142,7 @@ Index: gcc/config/mips/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" + +/* As an elf system, we need crtbegin/crtend stuff. */ +#undef STARTFILE_SPEC Index: patches/patch-gcc_config_pa_pa-openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_pa_pa-openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_pa_pa-openbsd_h --- patches/patch-gcc_config_pa_pa-openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_pa_pa-openbsd_h 9 Sep 2020 18:32:52 -0000 @@ -9,7 +9,7 @@ Index: gcc/config/pa/pa-openbsd.h + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" #undef STARTFILE_SPEC #define STARTFILE_SPEC "\ Index: patches/patch-gcc_config_sparc_openbsd64_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_sparc_openbsd64_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_sparc_openbsd64_h --- patches/patch-gcc_config_sparc_openbsd64_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_sparc_openbsd64_h 9 Sep 2020 18:32:52 -0000 @@ -68,7 +68,7 @@ Index: gcc/config/sparc/openbsd64.h + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" /* As an elf system, we need crtbegin/crtend stuff. */ #undef STARTFILE_SPEC