pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

gcc16: start new package



Module Name:	pkgsrc-wip
Committed By:	Thomas Klausner <wiz%NetBSD.org@localhost>
Pushed By:	wiz
Date:		Sun May 10 08:14:13 2026 +0200
Changeset:	6074c9dfec23735a786a5982ecf0065f6bda7c4f

Modified Files:
	Makefile
Added Files:
	gcc16-libjit/DESCR
	gcc16-libjit/Makefile
	gcc16-libjit/PLIST
	gcc16-libjit/buildlink3.mk
	gcc16-libs/DESCR
	gcc16-libs/Makefile
	gcc16-libs/buildlink3.mk
	gcc16/DESCR
	gcc16/Makefile
	gcc16/Makefile.common
	gcc16/TODO
	gcc16/buildlink3.mk
	gcc16/distinfo
	gcc16/options.mk
	gcc16/patches/patch-configure
	gcc16/patches/patch-configure.ac
	gcc16/patches/patch-gcc_Makefile.in
	gcc16/patches/patch-gcc_config.gcc
	gcc16/patches/patch-gcc_config.host
	gcc16/patches/patch-gcc_config_aarch64_aarch64-netbsd.h
	gcc16/patches/patch-gcc_config_arm_arm.h
	gcc16/patches/patch-gcc_config_arm_bpabi.h
	gcc16/patches/patch-gcc_config_arm_elf.h
	gcc16/patches/patch-gcc_config_arm_netbsd-eabi.h
	gcc16/patches/patch-gcc_config_arm_netbsd-elf.h
	gcc16/patches/patch-gcc_config_i386_t-netbsd64
	gcc16/patches/patch-gcc_config_netbsd.h
	gcc16/patches/patch-isl_configure
	gcc16/patches/patch-libffi_configure
	gcc16/patches/patch-libffi_testsuite_libffi.call_float2.c
	gcc16/patches/patch-libgcc_config.host
	gcc16/patches/patch-libgcc_crtstuff.c
	gcc16/patches/patch-libgcobol_configure.tgt
	gcc16/patches/patch-libgfortran_io_io.h
	gcc16/patches/patch-libquadmath_printf_quadmath-printf.c
	gcc16/patches/patch-libquadmath_strtod_strtod__l.c
	gcc16/version.mk

Log Message:
gcc16: start new package

stage 2 and 3 comparison failure

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=6074c9dfec23735a786a5982ecf0065f6bda7c4f

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                           |   3 +
 gcc16-libjit/DESCR                                 |   5 +
 gcc16-libjit/Makefile                              |  31 +++
 gcc16-libjit/PLIST                                 |   7 +
 gcc16-libjit/buildlink3.mk                         |  16 ++
 gcc16-libs/DESCR                                   |   7 +
 gcc16-libs/Makefile                                |  64 +++++++
 gcc16-libs/buildlink3.mk                           |  46 +++++
 gcc16/DESCR                                        |   2 +
 gcc16/Makefile                                     |  87 +++++++++
 gcc16/Makefile.common                              | 175 +++++++++++++++++
 gcc16/TODO                                         | 209 +++++++++++++++++++++
 gcc16/buildlink3.mk                                |  24 +++
 gcc16/distinfo                                     |  30 +++
 gcc16/options.mk                                   | 171 +++++++++++++++++
 gcc16/patches/patch-configure                      |  24 +++
 gcc16/patches/patch-configure.ac                   |  24 +++
 gcc16/patches/patch-gcc_Makefile.in                |  16 ++
 gcc16/patches/patch-gcc_config.gcc                 |  14 ++
 gcc16/patches/patch-gcc_config.host                |  15 ++
 .../patch-gcc_config_aarch64_aarch64-netbsd.h      |  18 ++
 gcc16/patches/patch-gcc_config_arm_arm.h           |  45 +++++
 gcc16/patches/patch-gcc_config_arm_bpabi.h         |  22 +++
 gcc16/patches/patch-gcc_config_arm_elf.h           |  14 ++
 gcc16/patches/patch-gcc_config_arm_netbsd-eabi.h   |  57 ++++++
 gcc16/patches/patch-gcc_config_arm_netbsd-elf.h    |  80 ++++++++
 gcc16/patches/patch-gcc_config_i386_t-netbsd64     |  22 +++
 gcc16/patches/patch-gcc_config_netbsd.h            |  14 ++
 gcc16/patches/patch-isl_configure                  |  24 +++
 gcc16/patches/patch-libffi_configure               |  16 ++
 .../patch-libffi_testsuite_libffi.call_float2.c    |  15 ++
 gcc16/patches/patch-libgcc_config.host             |  15 ++
 gcc16/patches/patch-libgcc_crtstuff.c              |  15 ++
 gcc16/patches/patch-libgcobol_configure.tgt        |  31 +++
 gcc16/patches/patch-libgfortran_io_io.h            |  18 ++
 .../patch-libquadmath_printf_quadmath-printf.c     |  26 +++
 gcc16/patches/patch-libquadmath_strtod_strtod__l.c |  23 +++
 gcc16/version.mk                                   |   3 +
 38 files changed, 1428 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 24a191f02b..7acc13885b 100644
--- a/Makefile
+++ b/Makefile
@@ -1223,6 +1223,9 @@ SUBDIR+=	gcc13
 SUBDIR+=	gcc14
 SUBDIR+=	gcc15-aux
 SUBDIR+=	gcc15-aux-libs
+SUBDIR+=	gcc16
+SUBDIR+=	gcc16-libjit
+SUBDIR+=	gcc16-libs
 SUBDIR+=	gcc42
 SUBDIR+=	gcc43
 SUBDIR+=	gcc44
diff --git a/gcc16-libjit/DESCR b/gcc16-libjit/DESCR
new file mode 100644
index 0000000000..b1be37ff13
--- /dev/null
+++ b/gcc16-libjit/DESCR
@@ -0,0 +1,5 @@
+The GNU Compiler Collection (GCC) includes front ends for C, C++,
+Objective-C, Fortran, and Go.
+
+This package contains libgccjit, an API for embedding GCC inside
+programs and libraries.
diff --git a/gcc16-libjit/Makefile b/gcc16-libjit/Makefile
new file mode 100644
index 0000000000..6857e85711
--- /dev/null
+++ b/gcc16-libjit/Makefile
@@ -0,0 +1,31 @@
+# $NetBSD: Makefile,v 1.1 2025/08/05 23:33:11 wiz Exp $
+
+.include "../../wip/gcc16/Makefile.common"
+
+PKGNAME=	${GCC_PKGNAME}-libjit-${GCC16_DIST_VERSION}
+COMMENT=	GNU Compiler Collection 16 (gcclibjit library)
+
+# /usr/bin/ld: ./../intl/libintl.a(bindtextdom.o): relocation R_X86_64_32 against symbol `libintl_nl_default_dirname' can not be used when making a shared object; recompile with -fPIC
+CFLAGS+=	-fPIC
+
+INSTALLATION_DIRS=	lib
+
+CONFIGURE_ARGS+=	--enable-languages=jit
+CONFIGURE_ARGS+=	--without-static-standard-libraries
+CONFIGURE_ARGS+=	--disable-bootstrap
+CONFIGURE_ARGS+=	--enable-host-shared
+
+MAKE_FLAGS+=		BOOT_CFLAGS=${CFLAGS:Q}
+MAKE_FLAGS+=		BOOT_CXXFLAGS=${CXXFLAGS:Q}
+MAKE_FLAGS+=		BOOT_LDFLAGS=${LDFLAGS:Q}
+MAKE_FLAGS+=		LDFLAGS_FOR_TARGET=${LDFLAGS:Q}
+MAKE_FLAGS+=		CFLAGS=${CFLAGS:Q}
+
+BUILD_TARGET=		all-gcc
+
+INSTALL_DIRS=		${WRKSRC}/${OBJDIR}/gcc
+INSTALL_TARGET=		jit.install-common jit.install-info
+
+TEXINFO_REQD+=		7.0
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/gcc16-libjit/PLIST b/gcc16-libjit/PLIST
new file mode 100644
index 0000000000..44465c224e
--- /dev/null
+++ b/gcc16-libjit/PLIST
@@ -0,0 +1,7 @@
+@comment $NetBSD: PLIST,v 1.1 2025/08/05 23:33:11 wiz Exp $
+gcc16/include/libgccjit++.h
+gcc16/include/libgccjit.h
+gcc16/info/libgccjit.info
+gcc16/lib/libgccjit.so
+gcc16/lib/libgccjit.so.0
+gcc16/lib/libgccjit.so.0.0.1
diff --git a/gcc16-libjit/buildlink3.mk b/gcc16-libjit/buildlink3.mk
new file mode 100644
index 0000000000..c986cf026b
--- /dev/null
+++ b/gcc16-libjit/buildlink3.mk
@@ -0,0 +1,16 @@
+# $NetBSD: buildlink3.mk,v 1.1 2025/08/05 23:33:11 wiz Exp $
+
+BUILDLINK_TREE+=	gcc16-libjit
+
+.if !defined(GCC16_LIBJIT_BUILDLINK3_MK)
+GCC16_LIBJIT_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.gcc16-libjit+=	gcc16-libjit>=16.1.0
+BUILDLINK_PKGSRCDIR.gcc16-libjit?=	../../wip/gcc16-libjit
+
+BUILDLINK_PASSTHRU_DIRS+=			${BUILDLINK_PREFIX.gcc16-libjit}/gcc16
+BUILDLINK_FNAME_TRANSFORM.gcc16-libjit+=	-e s,gcc16/lib,lib,
+BUILDLINK_FNAME_TRANSFORM.gcc16-libjit+=	-e s,gcc16/include,include,
+.endif	# GCC16_LIBJIT_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-gcc16-libjit
diff --git a/gcc16-libs/DESCR b/gcc16-libs/DESCR
new file mode 100644
index 0000000000..2801d164a1
--- /dev/null
+++ b/gcc16-libs/DESCR
@@ -0,0 +1,7 @@
+The GNU Compiler Collection (GCC) includes front ends for C, C++, Objective-C,
+Fortran, and Go, as well as libraries for these languages (libstdc++,
+libgfortran, ...).
+
+This packages provides GCC support libraries in a specific location and allows
+packages to depend on just the libraries rather than having to pull in the full
+GCC package.
diff --git a/gcc16-libs/Makefile b/gcc16-libs/Makefile
new file mode 100644
index 0000000000..6ba8872613
--- /dev/null
+++ b/gcc16-libs/Makefile
@@ -0,0 +1,64 @@
+# $NetBSD: Makefile,v 1.4 2025/11/08 07:04:02 mrg Exp $
+
+GCC_PKGNAME=	gcc16
+.include	"../../wip/${GCC_PKGNAME}/version.mk"
+
+DISTNAME=	gcc-${GCC16_DIST_VERSION}
+PKGNAME=	${GCC_PKGNAME}-libs-${GCC16_DIST_VERSION}
+
+## The PKGREVISION of this package needs to be at least 1 more than the
+## PKGREVISION of the lang/gcc16 package so that with the dependence pattern
+## '{gcc16,gcc16-libs}>=16.1.*' pkg_add will choose gcc16-libs over gcc16.
+PKGREVISION=	1
+
+CATEGORIES=	lang
+MASTER_SITES=	# empty
+DISTFILES=	# empty
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	https://gcc.gnu.org/
+COMMENT=	The GNU Compiler Collection (GCC) support shared libraries
+LICENSE=	gnu-gpl-v2 AND gnu-gpl-v3 AND gnu-lgpl-v2 AND gnu-lgpl-v3
+
+USE_TOOLS+=	pax
+
+NO_BUILD=		yes
+CHECK_SHLIBS=		no
+RELRO_SUPPORTED=	no
+
+## Depend on exactly ${GCC16_DIST_VERSION}.
+TOOL_DEPENDS+=		${GCC_PKGNAME}-${GCC16_DIST_VERSION}{,nb[0-9]*}:../../wip/gcc16
+
+.include "../../mk/bsd.prefs.mk"
+
+LIBGCC_SUBPREFIX=	${GCC_PKGNAME}
+LIBGCC_PREFIX=		${LOCALBASE}/${LIBGCC_SUBPREFIX}
+GCC_TARGET_MACHINE?=	${MACHINE_GNU_PLATFORM}
+BUILD_DEFS+=		GCC_TARGET_MACHINE
+
+# Workaround for PR pkg/58966: mk: REQUIRES/PROVIDES analysis is wrong
+# for self-libraries.
+CHECK_SHLIBS_SUPPORTED=	no
+
+LIBRARY_FILES=	${WRKDIR}/lib_files
+
+GENERATE_PLIST+=	${SED} -e 's,^,${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/,' \
+			${LIBRARY_FILES};
+GENERATE_PLIST+=	${GREP} -q 'lib/' ${LIBRARY_FILES} || \
+			${ECHO} '@pkgdir ${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/lib';
+
+${LIBRARY_FILES}:
+	${PKG_INFO} -qL '${GCC_PKGNAME}-${GCC16_DIST_VERSION}*' |	\
+	${SED} -n -e's,^${LIBGCC_PREFIX}/,,' -e'/libexec\//d'		\
+		-e'/libgij/d;/libgcj/d;/libjvm/d'			\
+		-e'/lib.*\.${SHLIB_EXT}/p' >${LIBRARY_FILES}
+
+do-install: ${LIBRARY_FILES}
+	${TEST} -d ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib ||	\
+		${MKDIR} ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib
+	cd ${LIBGCC_PREFIX} && 						\
+	  ${PAX} -rw ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE} <${LIBRARY_FILES}
+
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/gcc16-libs/buildlink3.mk b/gcc16-libs/buildlink3.mk
new file mode 100644
index 0000000000..67b6f5215d
--- /dev/null
+++ b/gcc16-libs/buildlink3.mk
@@ -0,0 +1,46 @@
+# $NetBSD: buildlink3.mk,v 1.1 2025/07/14 17:45:31 wiz Exp $
+
+BUILDLINK_TREE+=	gcc16-libs
+
+.if !defined(GCC16_LIBS_BUILDLINK3_MK)
+GCC16_LIBS_BUILDLINK3_MK:=
+
+.if !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
+BUILDLINK_API_DEPENDS.gcc16-libs+=	gcc16-libs>=16.1.0
+.else
+BUILDLINK_API_DEPENDS.gcc16-libs+=	{gcc16,gcc16-libs}>=16.1.0
+.endif
+BUILDLINK_PKGSRCDIR.gcc16-libs=		../../wip/gcc16-libs
+BUILDLINK_DEPMETHOD.gcc16-libs?=	full
+
+BUILDLINK_PASSTHRU_DIRS+=	${BUILDLINK_PREFIX.gcc16-libs}/gcc16
+
+BUILDLINK_FILES.gcc16-libs=	#empty
+BUILDLINK_AUTO_VARS.gcc16-libs=	no
+
+.if !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
+# Use custom specs file to ensure we link against pkgsrc libraries.
+SPECS_LIBGCC=		${WRAPPER_DIR}/specs.libgcc
+WRAPPER_TARGETS+=	${SPECS_LIBGCC}
+
+LIBGCC_SUBPREFIX=	gcc16
+LIBGCC_PREFIX=		${BUILDLINK_PREFIX.gcc16-libs}/${LIBGCC_SUBPREFIX}
+GCC_TARGET_MACHINE?=	${MACHINE_GNU_PLATFORM}
+
+${SPECS_LIBGCC}:
+	@${ECHO} "*link_libgcc:" >${SPECS_LIBGCC}
+	@${ECHO} "%D ${LINKER_RPATH_FLAG}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib/%M" >>${SPECS_LIBGCC}
+
+_WRAP_EXTRA_ARGS.CC+=	-specs=${SPECS_LIBGCC}
+_WRAP_EXTRA_ARGS.CXX+=	-specs=${SPECS_LIBGCC}
+_WRAP_EXTRA_ARGS.FC+=	-specs=${SPECS_LIBGCC}
+CWRAPPERS_APPEND.cc+=	-specs=${SPECS_LIBGCC}
+CWRAPPERS_APPEND.cxx+=	-specs=${SPECS_LIBGCC}
+CWRAPPERS_APPEND.f77+=	-specs=${SPECS_LIBGCC}
+.endif
+
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.endif # GCC16_LIBS_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-gcc16-libs
diff --git a/gcc16/DESCR b/gcc16/DESCR
new file mode 100644
index 0000000000..902190a230
--- /dev/null
+++ b/gcc16/DESCR
@@ -0,0 +1,2 @@
+The GNU Compiler Collection (GCC) includes front ends for C, C++, Objective-C,
+Fortran, and Go.
diff --git a/gcc16/Makefile b/gcc16/Makefile
new file mode 100644
index 0000000000..0cb6f902d9
--- /dev/null
+++ b/gcc16/Makefile
@@ -0,0 +1,87 @@
+# $NetBSD: Makefile,v 1.4 2025/11/08 07:04:02 mrg Exp $
+
+PKGNAME=	${GCC_PKGNAME}-${GCC16_DIST_VERSION}
+## When bumping the PKGREVISION of this package the PKGREVISION of
+## lang/gcc16-libs needs to be bumped to be at least 1 more than the
+## PKGREVISION of this package!
+#PKGREVISION=	1
+COMMENT=	The GNU Compiler Collection (GCC) - 16.0 Release Series
+
+LANGS=		c
+
+# perhaps lower, but 4.8 is not good enough
+TEXINFO_REQD+=	7.0
+
+.include "Makefile.common"
+
+# In some cases LINKER_RPATH_FLAG needs a trailing space.
+LINKER_RPATH_FLAG:=	${LINKER_RPATH_FLAG:S/-rpath/& /}
+
+## The Library rpath to use in end programs.
+LDFLAGS_FOR_TARGET=	${LDFLAGS:M${COMPILER_RPATH_FLAG}*:N*/usr/lib*} ${LDFLAGS:M-Wl,-z*}
+
+# The "-static-libstdc++ -static-libgcc" flags are normally added to the
+# boot-ldflags by configure but because we are supply the boot-ldflags
+# we mash supply them.
+BOOT_LDFLAGS=		-static-libstdc++ -static-libgcc ${LDFLAGS_FOR_TARGET}
+# Needed on Darwin when LDFLAGS point to a SDK
+BOOT_LDFLAGS+=		${LDFLAGS:M-Wl,-syslibroot*}
+# GCC does not understand this option; remove it, or stage build will fail
+BUILDLINK_TRANSFORM+=	rm:-stdlib=libc++
+
+# Disable fixincludes on SmartOS, header changes result in broken includes
+# being generated, see https://github.com/joyent/pkgsrc-legacy/issues/270
+.if ${OS_VARIANT} == "SmartOS"
+SUBST_CLASSES+=		fixinc
+SUBST_STAGE.fixinc=	pre-configure
+SUBST_FILES.fixinc=	gcc/Makefile.in
+SUBST_SED.fixinc=	-e "s,\./fixinc.sh,-c true,"
+.endif
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-*)
+# on NetBSD, use the native SSP code in libc
+CONFIGURE_ARGS+=	--disable-libssp
+# Match base libstdc++ major
+SUBST_CLASSES+=		libstdc
+SUBST_STAGE.libstdc=	pre-configure
+SUBST_FILES.libstdc=	libstdc++-v3/configure
+SUBST_MESSAGE.libstdc=	Bumping libstdc++ major to 7
+SUBST_SED.libstdc=	-e 's,libtool_VERSION=6:,libtool_VERSION=7:,g'
+.else
+CONFIGURE_ARGS+=	--enable-libssp
+.endif
+
+## For target librarys and libjava programs.
+CONFIGURE_ENV+=		LDFLAGS_FOR_TARGET=${LDFLAGS_FOR_TARGET:Q}
+
+.if ${USE_CROSS_COMPILE:U:tl} == "yes"
+CONFIGURE_ENV+=		CC_FOR_BUILD=${NATIVE_CC:Q}
+CONFIGURE_ENV+=		CXX_FOR_BUILD=${NATIVE_CXX:Q}
+.endif
+
+CONFIGURE_ARGS+=	--enable-languages=${LANGS:Q}
+CONFIGURE_ARGS+=	--enable-shared
+
+CTF_FILES_SKIP+=	*/gengtype	# CPU limit exceeded
+
+TEST_TARGET=	-j ${MAKE_JOBS} -k check || ${TRUE}
+TEST_DEPENDS+=	dejagnu-[0-9]*:../../devel/dejagnu
+
+post-test:
+	${RUN} cd ${WRKSRC} && cd ${OBJDIR} &&		\
+	${SHELL} ${WRKSRC}/contrib/test_summary >${WRKDIR}/test_summary.log
+	${INFO_MSG} "Test summary are available in ${WRKDIR}/test_summary.log"
+
+post-install:
+	${TEST} -f ${DESTDIR}${GCC_PREFIX}/bin/cc || \
+		( cd ${DESTDIR}${GCC_PREFIX}/bin ; ${LN} -f gcc cc )
+.if !empty(MACHINE_PLATFORM:MSunOS-*-*86*) && ${OS_VERSION} != "5.11"
+	${SH} files/values.c ${DESTDIR}${GCC_PREFIX}/bin/gcc -m32 || ${TRUE}
+	${SH} files/values.c ${DESTDIR}${GCC_PREFIX}/bin/gcc -m64 || ${TRUE}
+.endif
+
+GENERATE_PLIST+= \
+	cd ${DESTDIR}${PREFIX} && \
+	${FIND} ${GCC_SUBPREFIX} \( -type f -o -type l \) -print | ${SORT};
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/gcc16/Makefile.common b/gcc16/Makefile.common
new file mode 100644
index 0000000000..590ae514d2
--- /dev/null
+++ b/gcc16/Makefile.common
@@ -0,0 +1,175 @@
+# $NetBSD: Makefile.common,v 1.2 2025/07/17 05:37:09 wiz Exp $
+# used by wip/gcc16-libjit/Makefile
+
+GCC_PKGNAME=		gcc16
+.include		"version.mk"
+
+DISTNAME=	gcc-${GCC16_DIST_VERSION}
+CATEGORIES=	lang
+MASTER_SITES=	${MASTER_SITE_GNU:=gcc/gcc-${GCC16_DIST_VERSION}/}
+EXTRACT_SUFX=	.tar.xz
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	https://gcc.gnu.org/
+LICENSE=	gnu-gpl-v2 AND gnu-gpl-v3 AND gnu-lgpl-v2 AND gnu-lgpl-v3
+
+DISTFILES=		${DEFAULT_DISTFILES}
+EXTRACT_ONLY=		${DEFAULT_DISTFILES}
+
+PATCHDIR=		${.CURDIR}/../../wip/gcc16/patches
+DISTINFO_FILE=		${.CURDIR}/../../wip/gcc16/distinfo
+
+# Relocations result in a linker error on AArch64, but not x86.
+MKPIE_SUPPORTED=	no
+CHECK_RELRO_SKIP+=	${GCC_PKGNAME}/lib/*
+
+USE_LANGUAGES=		c c++
+USE_TOOLS+=		gmake makeinfo sed tar:build
+USE_TOOLS.NetBSD+=	gsed
+
+GNU_CONFIGURE=		yes
+GNU_CONFIGURE_STRICT=	no
+## Build outside ${WRKSRC}
+OBJDIR=			../build
+CONFIGURE_DIRS=		${OBJDIR}
+CONFIGURE_SCRIPT=	../${DISTNAME}/configure
+GCC_SUBPREFIX=		${GCC_PKGNAME}
+GCC_PREFIX=		${PREFIX}/${GCC_SUBPREFIX}
+GNU_CONFIGURE_PREFIX=	${GCC_PREFIX}
+INFO_FILES=		yes
+CONFIGURE_ARGS+=	--disable-libstdcxx-pch
+
+# error: 'for' loop initial declarations are only allowed in C99 mode
+FORCE_C_STD=		gnu99
+USE_CXX_FEATURES+=	c++14
+#FORCE_CXX_STD=		c++11
+
+UNLIMIT_RESOURCES+=	datasize
+UNLIMIT_RESOURCES+=	stacksize
+
+CHECK_PORTABILITY_SKIP+=	contrib/*
+CHECK_PORTABILITY_SKIP+=	gcc/configure.orig_dist
+
+.include "../../mk/bsd.prefs.mk"
+
+.include "options.mk"
+
+.if ${OPSYS} == "Darwin"
+BUILDLINK_TRANSFORM+=	rm:-nodefaultrpaths
+CONFIGURE_ARGS+=	--disable-darwin-at-rpath
+.endif
+
+## For graphite support.
+.if !empty(PKG_OPTIONS:Mgcc-graphite)
+
+EXTRACT_ONLY+=	${ISL24}.tar.xz
+
+post-extract:
+	${MV} ${WRKDIR}/${ISL24} ${WRKSRC}/isl
+.endif
+
+CONFIGURE_ARGS+=	--enable-long-long
+CONFIGURE_ARGS+=	--with-local-prefix=${GCC_PREFIX:Q}
+CONFIGURE_ARGS+=	--enable-threads=posix
+CONFIGURE_ARGS+=	--with-boot-ldflags=${BOOT_LDFLAGS:Q}
+CONFIGURE_ARGS+=	--without-zstd
+# causes build errors even when using wip/gcc16 to self-host.
+CONFIGURE_ARGS.SunOS+=	--disable-libsanitizer
+# multilib on Darwin requires fat-binaries
+CONFIGURE_ARGS.Darwin+=	--disable-multilib
+.if !empty(OSX_SDK_PATH)
+CONFIGURE_ARGS.Darwin+=	--with-sysroot=${OSX_SDK_PATH}
+.endif
+CONFIGURE_ARGS.NetBSD+=	--with-gnu-ld --with-ld=/usr/bin/ld
+CONFIGURE_ARGS.NetBSD+=	--with-gnu-as --with-as=/usr/bin/as
+MAKE_ENV.NetBSD+=	ac_cv_func_clock_gettime=yes
+MAKE_ENV.NetBSD+=	ac_cv_func_gethostbyname_r=no
+MAKE_ENV.NetBSD+=	ac_cv_func_freelocale=no
+MAKE_ENV.NetBSD+=	ac_cv_func_newlocale=no
+MAKE_ENV.NetBSD+=	ac_cv_func_uselocale=no
+MAKE_ENV.SunOS+=	ac_cv_func_mkostemp=no
+
+.if !empty(PKGSRC_COMPILER:Mclang) || ${OPSYS} == "DragonFly"
+CONFIGURE_ARGS+=	--disable-bootstrap
+.endif
+
+.if ${MACHINE_PLATFORM:MNetBSD-*-i386} || ${MACHINE_PLATFORM:MLinux-*-i386}
+CONFIGURE_ARGS+=	--with-arch=i486 --with-tune=i486
+.endif
+
+.if ${MACHINE_PLATFORM:MNetBSD-*-x86_64} || ${MACHINE_PLATFORM:MLinux-*-x86_64}
+CONFIGURE_ARGS+=	--with-arch=nocona --with-tune=nocona --with-fpmath=sse
+.endif
+
+.if ${MACHINE_PLATFORM:MDarwin-[0-8].*-*}
+CONFIGURE_ARGS+=	--with-dwarf2
+.endif
+
+# ${WRKSRC}/fixincludes/ looks for sed and compiles the path to sed into
+# a binary so we need to make sure we give it the installed sed and not
+# the tool wrapped one.
+MAKE_ENV+=		ac_cv_path_SED=${TOOLS_SED}
+MAKE_ENV+=		lt_cv_path_SED=${TOOLS_SED}
+
+# Determine whether to use binutils
+.if ${OPSYS} == "SunOS"
+.  if exists(/usr/sfw/bin/gobjdump)
+CONFIGURE_ENV+=		OBJDUMP=/usr/sfw/bin/gobjdump
+.  endif
+.  if exists(/usr/bin/ld)
+CONFIGURE_ARGS+=	--without-gnu-ld --with-ld=/usr/bin/ld
+.  else
+CONFIGURE_ARGS+=	--without-gnu-ld --with-ld=/usr/ccs/bin/ld
+.  endif
+.  if exists(/usr/sfw/bin/gas)
+CONFIGURE_ARGS+=	--with-gnu-as --with-as=/usr/sfw/bin/gas
+.  elif exists(/usr/ccs/bin/as)
+CONFIGURE_ARGS+=	--without-gnu-as --with-as=/usr/ccs/bin/as
+.  else
+BUILDLINK_DEPMETHOD.binutils=	full
+.    include "../../devel/binutils/buildlink3.mk"
+CONFIGURE_ARGS+=	--with-gnu-as --with-as=${PREFIX}/bin/gas
+.  endif
+.endif
+
+.if ${OPSYS} == "Linux"
+# glibc limitations, needs at least -O1
+FORTIFY_SUPPORTED=	no
+.endif
+
+.if ${OS_VARIANT} == "SmartOS"
+SUBST_CLASSES+=		ccs
+SUBST_STAGE.ccs=	pre-configure
+SUBST_FILES.ccs=	contrib/make_sunver.pl
+SUBST_SED.ccs=		-e 's,/usr/ccs/bin,/usr/bin,g'
+.endif
+
+# DO NOT REMOVE THIS SUBST.  If it fails, the corruption to
+# patch-gcc_Makefile.in chronicled in PR pkg/58963 `gcc:
+# LINK_LIBGCC_SPEC snafu' <https://gnats.NetBSD.org/58963> probably got
+# replicated yet again.  You must make sure that LINK_LIBGCC_SPEC is
+# appropriately set with @GCC_TARGET_MACHINE@ in patch-gcc_Makefile.in
+# or similar, or confirm with a discussion on tech-pkg@ that it is no
+# longer relevant before you remove this SUBST.
+SUBST_CLASSES+=		vars
+SUBST_MESSAGE.vars=	Setting target machine name path in ${SUBST_FILES.vars}
+SUBST_STAGE.vars=	pre-configure
+SUBST_FILES.vars=	gcc/Makefile.in
+SUBST_VARS.vars=	GCC_TARGET_MACHINE
+
+GCC_TARGET_MACHINE?=	${MACHINE_GNU_PLATFORM}
+BUILD_DEFS+=		GCC_TARGET_MACHINE
+
+pre-configure:
+	${RUN} cd ${WRKSRC} && ${MKDIR} ${OBJDIR}
+
+CHECK_BUILTIN.zlib:= yes
+.include "../../devel/zlib/builtin.mk"
+CHECK_BUILTIN.zlib:= no
+.if ${USE_BUILTIN.zlib:tl} == yes
+CONFIGURE_ARGS+=	--with-system-zlib
+.else
+CONFIGURE_ARGS+=	--without-system-zlib
+.endif
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
diff --git a/gcc16/TODO b/gcc16/TODO
new file mode 100644
index 0000000000..81076f5f09
--- /dev/null
+++ b/gcc16/TODO
@@ -0,0 +1,209 @@
+Comparing stages 2 and 3
+warning: gcc/cobol/parse.o differs
+Bootstrap comparison failure!
+gcc/build/genoutput.o differs
+gcc/build/genrecog.o differs
+gcc/build/genmatch.o differs
+gcc/c/gimple-parser.o differs
+gcc/c/c-decl.o differs
+gcc/c/c-typeck.o differs
+gcc/c/c-parser.o differs
+gcc/cobol/except.o differs
+gcc/cobol/messages.o differs
+gcc/cobol/cdf.o differs
+gcc/cobol/charmaps.o differs
+gcc/cobol/symfind.o differs
+gcc/cobol/valconv.o differs
+gcc/cobol/gengen.o differs
+gcc/cobol/lexio.o differs
+gcc/cobol/util.o differs
+gcc/cobol/symbols.o differs
+gcc/cobol/genapi.o differs
+gcc/cobol/scan.o differs
+gcc/cp/constraint.o differs
+gcc/cp/coroutines.o differs
+gcc/cp/contracts.o differs
+gcc/cp/class.o differs
+gcc/cp/lambda.o differs
+gcc/cp/logic.o differs
+gcc/cp/error.o differs
+gcc/cp/mapper-resolver.o differs
+gcc/cp/init.o differs
+gcc/cp/constexpr.o differs
+gcc/cp/decl.o differs
+gcc/cp/name-lookup.o differs
+gcc/cp/tree.o differs
+gcc/cp/typeck.o differs
+gcc/cp/semantics.o differs
+gcc/cp/module.o differs
+gcc/cp/pt.o differs
+gcc/cp/parser.o differs
+gcc/fortran/check.o differs
+gcc/fortran/io.o differs
+gcc/fortran/decl.o differs
+gcc/fortran/module.o differs
+gcc/fortran/trans-common.o differs
+gcc/fortran/trans-decl.o differs
+gcc/fortran/trans-array.o differs
+gcc/fortran/trans-openmp.o differs
+gcc/lto/lto-partition.o differs
+gcc/lto/lto-common.o differs
+gcc/objc/objc-gnu-runtime-abi-01.o differs
+gcc/objcp/objc-gnu-runtime-abi-01.o differs
+gcc/objcp/objc-next-runtime-abi-02.o differs
+gcc/objcp/objcp-act.o differs
+gcc/c-family/c-indentation.o differs
+gcc/c-family/c-gimplify.o differs
+gcc/c-family/c-omp.o differs
+gcc/c-family/c-attribs.o differs
+gcc/c-family/c-common.o differs
+gcc/analyzer/analysis-plan.o differs
+gcc/analyzer/ana-state-to-diagnostic-state.o differs
+gcc/analyzer/checker-path.o differs
+gcc/analyzer/checker-event.o differs
+gcc/analyzer/known-function-manager.o differs
+gcc/analyzer/program-point.o differs
+gcc/analyzer/constraint-manager.o differs
+gcc/analyzer/ranges.o differs
+gcc/analyzer/program-state.o differs
+gcc/analyzer/region-model-reachability.o differs
+gcc/analyzer/state-purge.o differs
+gcc/analyzer/trimmed-graph.o differs
+gcc/analyzer/region-model.o differs
+gcc/analyzer/store.o differs
+gcc/analyzer/region-model-manager.o differs
+gcc/diagnostics/source-printing.o differs
+gcc/diagnostics/sarif-sink.o differs
+gcc/rtl-ssa/accesses.o differs
+gcc/sym-exec/sym-exec-state.o differs
+gcc/attribs.o differs
+gcc/generic-match-4.o differs
+gcc/gimple-match-10.o differs
+gcc/asm-toplevel.o differs
+gcc/cfganal.o differs
+gcc/calls.o differs
+gcc/btfout.o differs
+gcc/cfgrtl.o differs
+gcc/auto-profile.o differs
+gcc/cfgexpand.o differs
+gcc/cselib.o differs
+gcc/cgraph.o differs
+gcc/dumpfile.o differs
+gcc/dwarf2cfi.o differs
+gcc/fixed-value.o differs
+gcc/except.o differs
+gcc/fwprop.o differs
+gcc/expmed.o differs
+gcc/ggc-common.o differs
+gcc/gimple-expr.o differs
+gcc/gimple-loop-jam.o differs
+gcc/gimple-low.o differs
+gcc/expr.o differs
+gcc/gimple-predicate-analysis.o differs
+gcc/gimple-range-gori.o differs
+gcc/gimple-ssa-isolate-paths.o differs
+gcc/gimple-ssa-sccopy.o differs
+gcc/fold-const.o differs
+gcc/godump.o differs
+gcc/gimple-ssa-strength-reduction.o differs
+gcc/gimple-ssa-store-merging.o differs
+gcc/graphite-isl-ast-to-gimple.o differs
+gcc/gimple-ssa-warn-access.o differs
+gcc/graphite-scop-detection.o differs
+gcc/dwarf2out.o differs
+gcc/haifa-sched.o differs
+gcc/ipa-comdats.o differs
+gcc/ipa-free-lang-data.o differs
+gcc/gtype-desc.o differs
+gcc/ipa-inline.o differs
+gcc/ipa-devirt.o differs
+gcc/ipa-sra.o differs
+gcc/gimplify.o differs
+gcc/ipa-reference.o differs
+gcc/ipa-icf-gimple.o differs
+gcc/ipa-cp.o differs
+gcc/ipa-utils.o differs
+gcc/ipa-strub.o differs
+gcc/ipa.o differs
+gcc/ipa-param-manipulation.o differs
+gcc/ipa-modref.o differs
+gcc/ipa-icf.o differs
+gcc/ipa-prop.o differs
+gcc/ira-color.o differs
+gcc/lower-subreg.o differs
+gcc/late-combine.o differs
+gcc/pair-fusion.o differs
+gcc/lra-eliminations.o differs
+gcc/lra.o differs
+gcc/lto-cgraph.o differs
+gcc/lto-streamer-in.o differs
+gcc/omp-oacc-kernels-decompose.o differs
+gcc/omp-offload.o differs
+gcc/lra-constraints.o differs
+gcc/optabs-tree.o differs
+gcc/lto-streamer-out.o differs
+gcc/omp-oacc-neuter-broadcast.o differs
+gcc/prime-paths.o differs
+gcc/print-rtl.o differs
+gcc/path-coverage.o differs
+gcc/optabs.o differs
+gcc/passes.o differs
+gcc/predict.o differs
+gcc/recog.o differs
+gcc/omp-low.o differs
+gcc/rtlanal.o differs
+gcc/substring-locations.o differs
+gcc/tree-affine.o differs
+gcc/tree-emutls.o differs
+gcc/tree-eh.o differs
+gcc/tree-data-ref.o differs
+gcc/tree-nested.o differs
+gcc/tree-loop-distribution.o differs
+gcc/tree-cfg.o differs
+gcc/tree-if-conv.o differs
+gcc/tree-inline.o differs
+gcc/tree-parloops.o differs
+gcc/tree-profile.o differs
+gcc/tree-ssa-alias.o differs
+gcc/tree-switch-conversion.o differs
+gcc/tree-ssa-ccp.o differs
+gcc/tree-ssa-loop-im.o differs
+gcc/tree-ssa-loop-unswitch.o differs
+gcc/tree-ssa-phiopt.o differs
+gcc/tree-ssa-loop-ivopts.o differs
+gcc/tree-ssa-structalias.o differs
+gcc/tree-ssa-math-opts.o differs
+gcc/tree-ssa-loop-niter.o differs
+gcc/tree-streamer.o differs
+gcc/tree-ssa-uninit.o differs
+gcc/tree-ssa-reassoc.o differs
+gcc/tree-tailcall.o differs
+gcc/tree-vect-slp-patterns.o differs
+gcc/tree-vectorizer.o differs
+gcc/tree-vect-loop-manip.o differs
+gcc/value-range-storage.o differs
+gcc/value-prof.o differs
+gcc/wide-int.o differs
+gcc/var-tracking.o differs
+gcc/varasm.o differs
+gcc/tree-vect-loop.o differs
+gcc/tree.o differs
+gcc/tree-vect-stmts.o differs
+gcc/tree-vect-slp.o differs
+gcc/i386-features.o differs
+gcc/input.o differs
+gcc/graphviz.o differs
+gcc/xml.o differs
+gcc/lto-wrapper.o differs
+gcc/lto-ltrans-cache.o differs
+gcc/gcov.o differs
+isl/isl_test_cpp-isl_test_cpp.o differs
+libcody/buffer.o differs
+gmake[2]: *** [Makefile:29621: compare] Error 1
+gmake[2]: Leaving directory '/tmp/lang/gcc16/work/build'
+gmake[1]: *** [Makefile:29601: stage3-bubble] Error 2
+gmake[1]: Leaving directory '/tmp/lang/gcc16/work/build'
+gmake: *** [Makefile:1144: all] Error 2
+*** Error code 2
+
+
diff --git a/gcc16/buildlink3.mk b/gcc16/buildlink3.mk
new file mode 100644
index 0000000000..f2c01fd5a3
--- /dev/null
+++ b/gcc16/buildlink3.mk
@@ -0,0 +1,24 @@
+# $NetBSD: buildlink3.mk,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+BUILDLINK_TREE+=	gcc16
+
+.if !defined(GCC16_BUILDLINK3_MK)
+GCC16_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.gcc16+=	gcc16>=${_GCC_REQD}
+BUILDLINK_ABI_DEPENDS.gcc16+=	gcc16>=16.1
+BUILDLINK_PKGSRCDIR.gcc16=	../../wip/gcc16
+BUILDLINK_DEPMETHOD.gcc16?=	build
+
+BUILDLINK_PASSTHRU_DIRS+=	${BUILDLINK_PREFIX.gcc16}/gcc16
+
+BUILDLINK_FILES.gcc16=		# empty
+BUILDLINK_AUTO_VARS.gcc16=	no
+
+pkgbase := gcc16
+.include "../../mk/pkg-build-options.mk"
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.endif
+
+BUILDLINK_TREE+=	-gcc16
diff --git a/gcc16/distinfo b/gcc16/distinfo
new file mode 100644
index 0000000000..9095543e83
--- /dev/null
+++ b/gcc16/distinfo
@@ -0,0 +1,30 @@
+$NetBSD: distinfo,v 1.4 2025/11/08 07:04:02 mrg Exp $
+
+BLAKE2s (gcc-16.1.0.tar.xz) = 037fe6c26509be014b26e0c16b07c2faac0c9894491b4525582d45ff88c66970
+SHA512 (gcc-16.1.0.tar.xz) = b3454958891ab47e1e5b6cb9396c0ad3b04f32fe2a7bf1153a143f21013fdb6b295ca94c98964698a688e4c1d7555ffd8ffbc20187507cce6b1c32cbcc09897a
+Size (gcc-16.1.0.tar.xz) = 102456900 bytes
+BLAKE2s (isl-0.24.tar.xz) = a3013b0d39b7fe68a1b3e15dc7e925b347d555348ee946a80f5319a76973cd61
+SHA512 (isl-0.24.tar.xz) = ff6bdcff839e1cd473f2a0c1e4dd4a3612ec6fee4544ccbc62b530a7248db2cf93b4b99bf493a86ddf2aba00e768927265d5d411f92061ea85fd7929073428e8
+Size (isl-0.24.tar.xz) = 1930956 bytes
+SHA1 (patch-configure) = 8e33eda65a5a5ba212ebab8c26ca4dc2e5ae0c51
+SHA1 (patch-configure.ac) = b72e07578678926dca9ce5b008bacbfcecb68cbb
+SHA1 (patch-gcc_Makefile.in) = a31ddc27f1092cfdf5ac896ca79c8590b5aceb47
+SHA1 (patch-gcc_config.gcc) = 65126c56f0cd9027f66b5f677773dfa9973b451c
+SHA1 (patch-gcc_config.host) = bf95dd21bfdf79d173e745fbd35c9bb99fdf4087
+SHA1 (patch-gcc_config_aarch64_aarch64-netbsd.h) = abf19e2445bce1773162bddef16cd7f41eb36827
+SHA1 (patch-gcc_config_arm_arm.h) = 9d554349869d67d6393552c33a7824f0dd53cb11
+SHA1 (patch-gcc_config_arm_bpabi.h) = 0b0de5ad95442e34397cb46739ef6e36048d6f45
+SHA1 (patch-gcc_config_arm_elf.h) = 57748157084319cb92d892f2ea5b2f3355567551
+SHA1 (patch-gcc_config_arm_netbsd-eabi.h) = 85eb89de6f2e64fac50251f06d7e4eab35903dae
+SHA1 (patch-gcc_config_arm_netbsd-elf.h) = 568f537d624199ef9f9f56088fe4fff7e946b2e2
+SHA1 (patch-gcc_config_i386_t-netbsd64) = 914b4d2fd65f5e46681aa2ea592d0bc75299f09a
+SHA1 (patch-gcc_config_netbsd.h) = ada05409eacb33bc1e7a659f3090f2f43551a35d
+SHA1 (patch-isl_configure) = a6295c509bdc82e8b54d7dec5252994532463091
+SHA1 (patch-libffi_configure) = 919bbe094e3ce547a0186eeaddb20a662595f79a
+SHA1 (patch-libffi_testsuite_libffi.call_float2.c) = 89e2dd6aaf2c1f75726f02362d8a8bf7178694ea
+SHA1 (patch-libgcc_config.host) = c9ea8bda0e6a1a8c4c39e4b8320a34b86e1da278
+SHA1 (patch-libgcc_crtstuff.c) = dd7808497b058bcac4aa8d91388d6a7685bb5e5c
+SHA1 (patch-libgcobol_configure.tgt) = d5a0e35e03ff8c835cbcb6cf17725ae82fd727af
+SHA1 (patch-libgfortran_io_io.h) = d44676239a7f45e42054d24bd5224f43c20055c0
+SHA1 (patch-libquadmath_printf_quadmath-printf.c) = 78e09f1e6d61ee57cee83275093cf46b2335d204
+SHA1 (patch-libquadmath_strtod_strtod__l.c) = 6142c10d34174174cce7f06c37eab04dc431b2dc
diff --git a/gcc16/options.mk b/gcc16/options.mk
new file mode 100644
index 0000000000..735e44524d
--- /dev/null
+++ b/gcc16/options.mk
@@ -0,0 +1,171 @@
+# $NetBSD: options.mk,v 1.2 2025/11/08 07:04:02 mrg Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.${GCC_PKGNAME}
+PKG_SUPPORTED_OPTIONS=	nls gcc-inplace-math gcc-c++ gcc-cobol gcc-fortran \
+			gcc-go gcc-objc gcc-objc++ gcc-graphite \
+			always-libgcc
+PKG_SUGGESTED_OPTIONS=	gcc-c++ gcc-fortran gcc-objc gcc-objc++ \
+			gcc-graphite gcc-inplace-math
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+.if ${OPSYS} == "NetBSD"
+PKG_SUGGESTED_OPTIONS+=	nls
+. if ${MACHINE_PLATFORM:M*-x86_64} || ${MACHINE_PLATFORM:M*-aarch64}
+# Test riscv64 as well, it should work.
+PKG_SUGGESTED_OPTIONS+=	gcc-cobol
+. endif
+.elif ${OPSYS} == "Linux"
+PKG_SUGGESTED_OPTIONS+=	nls
+.elif ${OPSYS} == "DragonFly"
+PKG_SUGGESTED_OPTIONS+=	nls
+.elif ${OPSYS} == "SunOS"
+PKG_SUGGESTED_OPTIONS+=	gcc-inplace-math always-libgcc
+.else
+.endif
+
+.include "../../mk/compiler.mk"
+.if empty(PKGSRC_COMPILER:Mgcc)
+PKG_SUGGESTED_OPTIONS+=			always-libgcc
+.endif
+
+###
+### Determine if multilib is avalible.
+###
+MULTILIB_SUPPORTED?=	unknown
+.if ${MACHINE_PLATFORM:MLinux-*-x86_64}
+.  if exists(/usr/include/x86_64-linux-gnu/gnu)
+_GNU_INCLUDE_DIR=	/usr/include/x86_64-linux-gnu/gnu
+.  else
+_GNU_INCLUDE_DIR=	/usr/include/gnu
+.  endif
+.  if exists(${_GNU_INCLUDE_DIR}/stubs-64.h) && \
+     !exists(${_GNU_INCLUDE_DIR}/stubs-32.h)
+MULTILIB_SUPPORTED=	No
+.  else
+MULTILIB_SUPPORTED=	Yes
+.  endif
+.endif
+.if !empty(MULTILIB_SUPPORTED:M[Yy][Ee][Ss])
+PKG_SUPPORTED_OPTIONS+=	gcc-multilib
+PKG_SUGGESTED_OPTIONS+=	gcc-multilib
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+###
+### Don't install libgcc if it's older than the system one
+###
+.if empty(PKG_OPTIONS:Malways-libgcc)
+
+.  for _libdir_ in ${_OPSYS_LIB_DIRS}
+.    if exists(${_libdir_})
+BASE_LIBGCC!=			find ${_libdir_} -name libgcc_s.so 2> /dev/null
+BASE_LIBGCC_MATCH_STRING!=	${ECHO} ${BASE_LIBGCC} ${GCC16_DIST_VERSION} | \
+				${AWK} -f ../../mk/scripts/larger_symbol_version.awk
+.      if ${BASE_LIBGCC_MATCH_STRING:Mnewer}
+DELETE_INSTALLED_LIBGCC=	yes
+.      endif
+.    endif
+.  endfor
+
+.  if ${DELETE_INSTALLED_LIBGCC:Uno} == "yes"
+post-install:	delete-installed-libgcc
+
+.PHONY: delete-installed-libgcc
+delete-installed-libgcc:
+	${FIND} ${DESTDIR} -name 'libgcc_s.so*' -delete
+
+.  endif
+
+.endif
+
+###
+### Native Language Support
+###
+.if !empty(PKG_OPTIONS:Mnls)
+USE_TOOLS+=		msgfmt
+CONFIGURE_ARGS+=	--enable-nls
+CONFIGURE_ARGS+=	--with-libiconv-prefix=${BUILDLINK_PREFIX.iconv}
+MAKE_ENV+=		ICONVPREFIX=${BUILDLINK_PREFIX.iconv}
+.include "../../converters/libiconv/buildlink3.mk"
+.include "../../devel/gettext-lib/buildlink3.mk"
+.else
+CONFIGURE_ARGS+=	--disable-nls
+.endif
+
+###
+### Multilib Support
+###
+.if (!empty(MULTILIB_SUPPORTED:M[Yy][Ee][Ss]) && \
+      empty(PKG_OPTIONS:Mgcc-multilib) ) || \
+    !empty(MULTILIB_SUPPORTED:M[Nn][Oo])
+CONFIGURE_ARGS+=	--disable-multilib
+.endif
+
+###
+### Build math libraries in place
+###
+.if !empty(PKG_OPTIONS:Mgcc-inplace-math)
+.  include "../../devel/gmp/inplace.mk"
+.  include "../../math/mpcomplex/inplace.mk"
+.  include "../../math/mpfr/inplace.mk"
+.else
+CONFIGURE_ARGS+=	--with-gmp=${BUILDLINK_PREFIX.gmp}
+CONFIGURE_ARGS+=	--with-mpc=${BUILDLINK_PREFIX.mpcomplex}
+CONFIGURE_ARGS+=	--with-mpfr=${BUILDLINK_PREFIX.mpfr}
+LIBS.SunOS+=		-lgmp
+.  include "../../devel/gmp/buildlink3.mk"
+.  include "../../math/mpcomplex/buildlink3.mk"
+.  include "../../math/mpfr/buildlink3.mk"
+.endif
+
+###
+### Graphite Support
+###
+.if !empty(PKG_OPTIONS:Mgcc-graphite)
+ISL24=			isl-0.24
+SITES.${ISL24}.tar.bz2=	${MASTER_SITE_GNU:=gcc/infrastructure/}
+DISTFILES+=		${ISL24}.tar.xz
+.endif
+
+###
+### Optional languages
+### Ada could be added although there is a bootstrapping issue.
+###
+
+.if !empty(PKG_OPTIONS:Mgcc-objc++)
+.  if empty(PKG_OPTIONS:Mgcc-c++)
+PKG_OPTIONS+=		gcc-c++
+.  endif
+.  if empty(PKG_OPTIONS:Mgcc-objc)
+PKG_OPTIONS+=		gcc-objc
+.  endif
+LANGS+=			obj-c++
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-objc)
+LANGS+=			objc
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-go)
+LANGS+=			go
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-fortran)
+LANGS+=			fortran
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-cobol)
+LANGS+=			cobol
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-c++)
+LANGS+=			c++
+USE_TOOLS+=		perl
+CONFIGURE_ARGS+=	--enable-__cxa_atexit
+CONFIGURE_ARGS+=	--with-gxx-include-dir=${GCC_PREFIX}/include/c++/
+.else
+CONFIGURE_ARGS+=	--disable-build-with-cxx
+CONFIGURE_ARGS+=	--disable-build-poststage1-with-cxx
+.endif
diff --git a/gcc16/patches/patch-configure b/gcc16/patches/patch-configure
new file mode 100644
index 0000000000..256cc54f53
--- /dev/null
+++ b/gcc16/patches/patch-configure
@@ -0,0 +1,24 @@
+$NetBSD: patch-configure,v 1.1 2025/11/08 07:04:02 mrg Exp $
+
+Enable COBOL on NetBSD amd64/arm64/riscv64.
+
+
+--- configure.orig	2025-08-07 23:51:39.874338130 -0700
++++ configure	2025-11-05 19:28:09.763698065 -0800
+@@ -3581,14 +3581,14 @@ case ,${enable_languages}, in
+     ;;
+   *)
+     case "${target}" in
+-      aarch64-*-linux*|x86_64-*-linux*)
++      aarch64-*-linux*|x86_64-*-linux*|aarch64-*-netbsd*|x86_64-*-netbsd*|riscv64-*-netbsd*)
+         ;;
+       *-*-*)
+         unsupported_languages="$unsupported_languages cobol"
+         ;;
+     esac
+     case "${host}" in
+-      aarch64-*-linux*|x86_64-*-linux*)
++      aarch64-*-linux*|x86_64-*-linux*|aarch64-*-netbsd*|x86_64-*-netbsd*|riscv64-*-netbsd*)
+         ;;
+       *-*-*)
+         unsupported_languages="$unsupported_languages cobol"
diff --git a/gcc16/patches/patch-configure.ac b/gcc16/patches/patch-configure.ac
new file mode 100644
index 0000000000..c87026c8c9
--- /dev/null
+++ b/gcc16/patches/patch-configure.ac
@@ -0,0 +1,24 @@
+$NetBSD: patch-configure.ac,v 1.1 2025/11/08 07:04:02 mrg Exp $
+
+Enable COBOL on NetBSD amd64/arm64/riscv64.
+
+
+--- configure.ac.orig	2025-08-07 23:51:39.874338130 -0700
++++ configure.ac	2025-11-05 19:22:39.706058829 -0800
+@@ -801,14 +801,14 @@ case ,${enable_languages}, in
+     ;;
+   *)
+     case "${target}" in
+-      aarch64-*-linux*|x86_64-*-linux*)
++      aarch64-*-linux*|x86_64-*-linux*|aarch64-*-netbsd*|x86_64-*-netbsd*|riscv64-*-netbsd*)
+         ;;
+       *-*-*)
+         unsupported_languages="$unsupported_languages cobol"
+         ;;
+     esac
+     case "${host}" in
+-      aarch64-*-linux*|x86_64-*-linux*)
++      aarch64-*-linux*|x86_64-*-linux*|aarch64-*-netbsd*|x86_64-*-netbsd*|riscv64-*-netbsd*)
+         ;;
+       *-*-*)
+         unsupported_languages="$unsupported_languages cobol"
diff --git a/gcc16/patches/patch-gcc_Makefile.in b/gcc16/patches/patch-gcc_Makefile.in
new file mode 100644
index 0000000000..0d3360098f
--- /dev/null
+++ b/gcc16/patches/patch-gcc_Makefile.in
@@ -0,0 +1,16 @@
+$NetBSD: patch-gcc_Makefile.in,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Ensure libgcc from this GCC is found before others.  Note that there must
+not be a whitespace between $(LINKER_RPATH_FLAG) and the path.  Otherwise
+the flag may be misinterpreted by the linker (e.g. Apple ld).
+
+--- gcc/Makefile.in.orig	2017-04-18 18:10:27.000000000 +0000
++++ gcc/Makefile.in
+@@ -2112,6 +2112,7 @@ prefix.o: $(BASEVER)
+ # Language-independent files.
+ 
+ DRIVER_DEFINES = \
++  -DLINK_LIBGCC_SPEC="\"%D $(LINKER_RPATH_FLAG)$(prefix)/@GCC_TARGET_MACHINE@/lib/%M $(LINKER_RPATH_FLAG)$(libdir)/%M \"" \
+   -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
+   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
+   -DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/gcc/\" \
diff --git a/gcc16/patches/patch-gcc_config.gcc b/gcc16/patches/patch-gcc_config.gcc
new file mode 100644
index 0000000000..ec215d34dc
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config.gcc
@@ -0,0 +1,14 @@
+$NetBSD: patch-gcc_config.gcc,v 1.1 2025/08/04 02:48:24 mrg Exp $
+
+Enable multilib support on amd64.
+
+--- gcc/config.gcc.orig	2025-04-25 01:18:00.000000000 -0700
++++ gcc/config.gcc	2025-08-03 17:22:06.592442114 -0700
+@@ -1992,6 +1992,7 @@
+ 	;;
+ x86_64-*-netbsd*)
+ 	tm_file="${tm_file} i386/unix.h i386/att.h elfos.h ${nbsd_tm_file} i386/x86-64.h i386/netbsd64.h"
++	tmake_file="${tmake_file} i386/t-netbsd64"
+ 	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
+ 	;;
+ i[34567]86-*-openbsd*)
diff --git a/gcc16/patches/patch-gcc_config.host b/gcc16/patches/patch-gcc_config.host
new file mode 100644
index 0000000000..1372d2b2fd
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config.host
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_config.host,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Add aarch64*-*-netbsd*.
+
+--- gcc/config.host.orig	2022-05-06 07:30:56.000000000 +0000
++++ gcc/config.host
+@@ -99,7 +99,7 @@ case ${host} in
+ esac
+ 
+ case ${host} in
+-  aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\
++  aarch64*-*-freebsd* | aarch64*-*-netbsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\
+   aarch64*-*-darwin*)
+     case ${target} in
+       aarch64*-*-*)
diff --git a/gcc16/patches/patch-gcc_config_aarch64_aarch64-netbsd.h b/gcc16/patches/patch-gcc_config_aarch64_aarch64-netbsd.h
new file mode 100644
index 0000000000..2b9f6a8f84
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_aarch64_aarch64-netbsd.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-gcc_config_aarch64_aarch64-netbsd.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Match what is in NetBSD src.  Fixes at least aarch64eb, and
+probably several others.
+
+--- gcc/config/aarch64/aarch64-netbsd.h.orig	2021-04-08 04:56:28.033740243 -0700
++++ gcc/config/aarch64/aarch64-netbsd.h	2021-04-24 00:16:41.451665444 -0700
+@@ -20,6 +20,10 @@
+ #ifndef GCC_AARCH64_NETBSD_H
+ #define GCC_AARCH64_NETBSD_H
+ 
++/* NetBSD malloc(3) does 64, not 128 bytes. */
++#undef MALLOC_ABI_ALIGNMENT
++#define MALLOC_ABI_ALIGNMENT  64
++
+ #define TARGET_LINKER_BIG_EMULATION "aarch64nbsdb"
+ #define TARGET_LINKER_LITTLE_EMULATION "aarch64nbsd"
+ 
diff --git a/gcc16/patches/patch-gcc_config_arm_arm.h b/gcc16/patches/patch-gcc_config_arm_arm.h
new file mode 100644
index 0000000000..93879c6499
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_arm_arm.h
@@ -0,0 +1,45 @@
+$NetBSD: patch-gcc_config_arm_arm.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+--- gcc/config/arm/arm.h.orig	2021-04-08 04:56:28.057740534 -0700
++++ gcc/config/arm/arm.h	2022-01-31 21:11:39.595024008 -0800
+@@ -937,6 +937,11 @@
+ #define ARM_UNWIND_INFO  0
+ #endif
+ 
++/* Overriden by config/arm/netbsd-eabi.h.  */
++#ifndef ARM_DWARF_UNWIND_TABLES
++#define ARM_DWARF_UNWIND_TABLES 0
++#endif
++
+ /* Use r0 and r1 to pass exception handling information.  */
+ #define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM)
+ 
+@@ -948,11 +953,19 @@
+ #define ARM_TARGET2_DWARF_FORMAT DW_EH_PE_pcrel
+ #endif
+ 
++#if ARM_DWARF_UNWIND_TABLES
++/* DWARF unwinding uses the normal indirect/pcrel vs absptr format
++   for 32bit platforms. */
++#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
++  (flag_pic ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
++            : DW_EH_PE_absptr)
++#else
+ /* ttype entries (the only interesting data references used)
+    use TARGET2 relocations.  */
+ #define ASM_PREFERRED_EH_DATA_FORMAT(code, data) \
+   (((code) == 0 && (data) == 1 && ARM_UNWIND_INFO) ? ARM_TARGET2_DWARF_FORMAT \
+ 			       : DW_EH_PE_absptr)
++#endif
+ 
+ /* The native (Norcroft) Pascal compiler for the ARM passes the static chain
+    as an invisible last argument (possible since varargs don't exist in
+@@ -2342,7 +2355,7 @@
+ 
+ /* -mcpu=native handling only makes sense with compiler running on
+    an ARM chip.  */
+-#if defined(__arm__)
++#if defined(__arm__) && defined(__linux__)
+ extern const char *host_detect_local_cpu (int argc, const char **argv);
+ #define HAVE_LOCAL_CPU_DETECT
+ # define MCPU_MTUNE_NATIVE_FUNCTIONS			\
diff --git a/gcc16/patches/patch-gcc_config_arm_bpabi.h b/gcc16/patches/patch-gcc_config_arm_bpabi.h
new file mode 100644
index 0000000000..067dcff58b
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_arm_bpabi.h
@@ -0,0 +1,22 @@
+$NetBSD: patch-gcc_config_arm_bpabi.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+--- gcc/config/arm/bpabi.h.orig	2021-04-08 04:56:28.061740583 -0700
++++ gcc/config/arm/bpabi.h	2022-01-31 21:13:16.734263818 -0800
+@@ -24,6 +24,7 @@
+    <http://www.gnu.org/licenses/>.  */
+ 
+ /* Use the AAPCS ABI by default.  */
++#undef ARM_DEFAULT_ABI
+ #define ARM_DEFAULT_ABI ARM_ABI_AAPCS
+ 
+ /* Assume that AAPCS ABIs should adhere to the full BPABI.  */
+@@ -107,7 +108,9 @@
+ /* The BPABI specifies the use of .{init,fini}_array.  Therefore, we
+    do not want GCC to put anything into the .{init,fini} sections.  */
+ #undef INIT_SECTION_ASM_OP
++#define INIT_SECTION_ASM_OP ""
+ #undef FINI_SECTION_ASM_OP
++#define FINI_SECTION_ASM_OP ""
+ #define INIT_ARRAY_SECTION_ASM_OP ARM_EABI_CTORS_SECTION_OP
+ #define FINI_ARRAY_SECTION_ASM_OP ARM_EABI_DTORS_SECTION_OP
+ 
diff --git a/gcc16/patches/patch-gcc_config_arm_elf.h b/gcc16/patches/patch-gcc_config_arm_elf.h
new file mode 100644
index 0000000000..5a9941495c
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_arm_elf.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-gcc_config_arm_elf.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+--- gcc/config/arm/elf.h.orig	2021-04-08 04:56:28.065740630 -0700
++++ gcc/config/arm/elf.h	2022-01-31 21:14:04.684223580 -0800
+@@ -147,6 +147,8 @@
+ #undef L_floatdidf
+ #undef L_floatdisf
+ #undef L_floatundidf
++/* XXXMRG: don't take this out, we need it! */
++# ifndef __NetBSD__
+ #undef L_floatundisf
++# endif
+ #endif
+-
diff --git a/gcc16/patches/patch-gcc_config_arm_netbsd-eabi.h b/gcc16/patches/patch-gcc_config_arm_netbsd-eabi.h
new file mode 100644
index 0000000000..a93a5be4d3
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_arm_netbsd-eabi.h
@@ -0,0 +1,57 @@
+$NetBSD: patch-gcc_config_arm_netbsd-eabi.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+--- gcc/config/arm/netbsd-eabi.h.orig	2021-04-08 04:56:28.065740630 -0700
++++ gcc/config/arm/netbsd-eabi.h	2022-01-31 21:15:29.555403989 -0800
+@@ -49,8 +49,8 @@
+ 
+ #undef ARM_UNWIND_INFO
+ #define ARM_UNWIND_INFO 0
+-#undef DWARF2_UNWIND_INFO
+-#define DWARF2_UNWIND_INFO 1
++#undef ARM_DWARF_UNWIND_TABLES
++#define ARM_DWARF_UNWIND_TABLES 1
+ 
+ #undef TARGET_OS_CPP_BUILTINS
+ #define TARGET_OS_CPP_BUILTINS()		\
+@@ -59,7 +59,7 @@
+       if (TARGET_AAPCS_BASED)			\
+ 	TARGET_BPABI_CPP_BUILTINS();		\
+       NETBSD_OS_CPP_BUILTINS_ELF();		\
+-      if (DWARF2_UNWIND_INFO)			\
++      if (ARM_DWARF_UNWIND_TABLES)		\
+ 	builtin_define ("__ARM_DWARF_EH__");	\
+     }						\
+   while (0)
+@@ -81,17 +81,25 @@
+ 
+ #undef SUBTARGET_EXTRA_ASM_SPEC
+ #define SUBTARGET_EXTRA_ASM_SPEC		\
+-  "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} "	\
++  "-matpcs %{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} "	\
+   "%{fpic|fpie:-k} "				\
+   "%{fPIC|fPIE:-k}"
+ 
++/* Default to full VFP if -mhard-float is specified.  */
++#undef SUBTARGET_ASM_FLOAT_SPEC
++#define SUBTARGET_ASM_FLOAT_SPEC	\
++  "%{mhard-float:%{!mfpu=*:-mfpu=vfp}}   \
++   %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfp}}"
++
+ #undef SUBTARGET_EXTRA_SPECS
+ #define SUBTARGET_EXTRA_SPECS						\
+   { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC },		\
++  { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, 		\
+   { "linker_eabi_suffix",	TARGET_LINKER_EABI_SUFFIX },		\
+   { "linker_emulation",		TARGET_LINKER_EMULATION },		\
+   { "linker_big_emulation",	TARGET_LINKER_BIG_EMULATION },		\
+   { "linker_little_emulation",	TARGET_LINKER_LITTLE_EMULATION },	\
++  { "be8_link_spec",		BE8_LINK_SPEC }, 			\
+   { "target_fix_v4bx_spec",	TARGET_FIX_V4BX_SPEC },			\
+   NETBSD_SUBTARGET_EXTRA_SPECS
+ 
+@@ -102,4 +110,5 @@
+   "-X %{mbig-endian:-EB -m %(linker_big_emulation)} "		\
+   "%{mlittle-endian:-EL -m %(linker_liitle_emulation)} "	\
+   "%{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} "	\
++  "%(be8_link_spec) "						\
+   "%(target_fix_v4bx_spec) %(netbsd_link_spec)"
diff --git a/gcc16/patches/patch-gcc_config_arm_netbsd-elf.h b/gcc16/patches/patch-gcc_config_arm_netbsd-elf.h
new file mode 100644
index 0000000000..0e23576681
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_arm_netbsd-elf.h
@@ -0,0 +1,80 @@
+$NetBSD: patch-gcc_config_arm_netbsd-elf.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+--- gcc/config/arm/netbsd-elf.h.orig	2023-04-26 07:09:39.000000000 +0000
++++ gcc/config/arm/netbsd-elf.h
+@@ -27,9 +27,20 @@
+ 
+ /* arm.h defaults to ARM6 CPU.  */
+ 
+-/* This defaults us to little-endian.  */
+-#ifndef TARGET_ENDIAN_DEFAULT
+-#define TARGET_ENDIAN_DEFAULT 0
++/* Default EABI to armv5t so that thumb shared libraries work.
++   The ARM926EH-S core is the default for armv5te, so set
++   SUBTARGET_CPU_DEFAULT to achieve this.  */
++
++#define SUBTARGET_CPU_DEFAULT \
++	(ARM_DEFAULT_ABI != ARM_ABI_APCS && ARM_DEFAULT_ABI != ARM_ABI_ATPCS \
++	    ? TARGET_CPU_arm926ejs : TARGET_CPU_arm6)
++
++/* TARGET_BIG_ENDIAN_DEFAULT is set in
++   config.gcc for big endian configurations.  */
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define TARGET_ENDIAN_DEFAULT    MASK_BIG_END
++#else
++#define TARGET_ENDIAN_DEFAULT    0
+ #endif
+ 
+ #undef MULTILIB_DEFAULTS
+@@ -56,25 +67,28 @@
+ 
+ #undef SUBTARGET_EXTRA_ASM_SPEC
+ #define SUBTARGET_EXTRA_ASM_SPEC	\
++  "-matpcs %{mabi=aapcs*:-meabi=5} "	\
+   "%{" FPIE_OR_FPIC_SPEC ":-k}"
+ 
++#undef SUBTARGET_EXTRA_SPECS
++#define SUBTARGET_EXTRA_SPECS					\
++  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC },	\
++  { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC },	\
++  NETBSD_SUBTARGET_EXTRA_SPECS
++
+ /* Default to full VFP if -mfloat-abi=hard is specified.  */
+ #undef SUBTARGET_ASM_FLOAT_SPEC
+-#define SUBTARGET_ASM_FLOAT_SPEC	\
+-  "%{mfloat-abi=hard:{!mfpu=*:-mfpu=vfp}}"
+-
+-#undef SUBTARGET_EXTRA_SPECS
+-#define SUBTARGET_EXTRA_SPECS				\
+-  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC }, \
+-  { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, \
+-  { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF },	\
+-  { "netbsd_entry_point",	NETBSD_ENTRY_POINT },
++#define SUBTARGET_ASM_FLOAT_SPEC		\
++  "%{mhard-float:%{!mfpu=*:-mfpu=vfp}}		\
++   %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfp}}"
+ 
+ #define NETBSD_ENTRY_POINT "__start"
+ 
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+-  "-X %{mbig-endian:-EB} %{mlittle-endian:-EL} \
++  "-X \
++   %{mbig-endian:-EB %{-mabi=aapcs*:-m armelfb_nbsd_eabi}} \
++   %{mlittle-endian:-EL %{-mabi=aapcs*:-m armelf_nbsd_eabi}} \
+    %(netbsd_link_spec)"
+ 
+ /* Make GCC agree with <machine/ansi.h>.  */
+@@ -85,6 +99,12 @@
+ #undef PTRDIFF_TYPE
+ #define PTRDIFF_TYPE "long int"
+ 
++#undef INTPTR_TYPE
++#define INTPTR_TYPE PTRDIFF_TYPE
++
++#undef UINTPTR_TYPE
++#define UINTPTR_TYPE SIZE_TYPE
++
+ /* NetBSD does its profiling differently to the Acorn compiler. We
+    don't need a word following the mcount call; and to skip it
+    requires either an assembly stub or use of fomit-frame-pointer when
diff --git a/gcc16/patches/patch-gcc_config_i386_t-netbsd64 b/gcc16/patches/patch-gcc_config_i386_t-netbsd64
new file mode 100644
index 0000000000..2381e9f5de
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_i386_t-netbsd64
@@ -0,0 +1,22 @@
+$NetBSD: patch-gcc_config_i386_t-netbsd64,v 1.1 2025/08/04 02:48:24 mrg Exp $
+
+Enable multilib support on amd64.
+
+--- /dev/null	2025-08-03 17:17:47.388033634 -0700
++++ gcc/config/i386/t-netbsd64	2025-08-03 17:20:16.285905032 -0700
+@@ -0,0 +1,15 @@
++# NetBSD has "non-native" libraries in /usr/lib/<arch>.
++# For NetBSD/amd64 we thus have /usr/lib and /usr/lib/i386.
++
++MULTILIB_OPTIONS = m64/m32
++MULTILIB_DIRNAMES = 64 32 
++MULTILIB_OSDIRNAMES = . ../lib/i386
++
++LIBGCC = stmp-multilib
++INSTALL_LIBGCC = install-multilib
++
++# The pushl in CTOR initialization interferes with frame pointer elimination.
++# crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables,
++# because then __FRAME_END__ might not be the last thing in .eh_frame
++# section.
++CRTSTUFF_T_CFLAGS += -fno-omit-frame-pointer -fno-asynchronous-unwind-tables
diff --git a/gcc16/patches/patch-gcc_config_netbsd.h b/gcc16/patches/patch-gcc_config_netbsd.h
new file mode 100644
index 0000000000..fba03f847f
--- /dev/null
+++ b/gcc16/patches/patch-gcc_config_netbsd.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-gcc_config_netbsd.h,v 1.1 2025/11/08 07:04:02 mrg Exp $
+
+NetBSD doesn't have a -ldl.
+
+
+--- gcc/config/netbsd.h.orig	2025-08-07 23:51:40.599350224 -0700
++++ gcc/config/netbsd.h	2025-11-06 12:07:01.954484996 -0800
+@@ -166,3 +166,6 @@ along with GCC; see the file COPYING3.  
+   do {									\
+     netbsd_patch_builtins ();						\
+   } while(0)
++
++/* NetBSD does not have a dl library. */
++#define DL_LIBRARY ""
diff --git a/gcc16/patches/patch-isl_configure b/gcc16/patches/patch-isl_configure
new file mode 100644
index 0000000000..0d60b02e1d
--- /dev/null
+++ b/gcc16/patches/patch-isl_configure
@@ -0,0 +1,24 @@
+$NetBSD: patch-isl_configure,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Fix unportable test(1) operator.
+
+--- isl/configure.orig	2021-04-26 09:13:19.000000000 +0000
++++ isl/configure
+@@ -20657,7 +20657,7 @@ else
+   HAVE_CXX11_FALSE=
+ fi
+ 
+- if test "x$with_int" == "ximath-32"; then
++ if test "x$with_int" = "ximath-32"; then
+   SMALL_INT_OPT_TRUE=
+   SMALL_INT_OPT_FALSE='#'
+ else
+@@ -20665,7 +20665,7 @@ else
+   SMALL_INT_OPT_FALSE=
+ fi
+ 
+-if test "x$with_int" == "ximath-32"; then :
++if test "x$with_int" = "ximath-32"; then :
+ 
+ 
+ $as_echo "#define USE_SMALL_INT_OPT /**/" >>confdefs.h
diff --git a/gcc16/patches/patch-libffi_configure b/gcc16/patches/patch-libffi_configure
new file mode 100644
index 0000000000..c8c3693598
--- /dev/null
+++ b/gcc16/patches/patch-libffi_configure
@@ -0,0 +1,16 @@
+$NetBSD: patch-libffi_configure,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90146
+https://github.com/libffi/libffi/issues/485
+
+--- libffi/configure.orig	2022-05-06 07:31:19.000000000 +0000
++++ libffi/configure
+@@ -16155,7 +16155,7 @@ case "$target" in
+ $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
+ 
+      ;;
+-     *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
++     *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-netbsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
+ 
+ $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
+ 
diff --git a/gcc16/patches/patch-libffi_testsuite_libffi.call_float2.c b/gcc16/patches/patch-libffi_testsuite_libffi.call_float2.c
new file mode 100644
index 0000000000..2e7748b682
--- /dev/null
+++ b/gcc16/patches/patch-libffi_testsuite_libffi.call_float2.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-libffi_testsuite_libffi.call_float2.c,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90146
+
+--- libffi/testsuite/libffi.call/float2.c.orig	2022-05-06 07:30:59.000000000 +0000
++++ libffi/testsuite/libffi.call/float2.c
+@@ -47,7 +47,7 @@ int main (void)
+   /* long double support under SunOS/gcc is pretty much non-existent.
+      You'll get the odd bus error in library routines like printf() */
+ #else
+-  printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
++  printf ("%Lf, %Lf, %Lf, %Lf\n", (long double)ld, (long double)ldblit(f), (long double)(ld - ldblit(f)), (long double)LDBL_EPSILON);
+ #endif
+ 
+   /* These are not always the same!! Check for a reasonable delta */
diff --git a/gcc16/patches/patch-libgcc_config.host b/gcc16/patches/patch-libgcc_config.host
new file mode 100644
index 0000000000..f5b466c859
--- /dev/null
+++ b/gcc16/patches/patch-libgcc_config.host
@@ -0,0 +1,15 @@
+$NetBSD: patch-libgcc_config.host,v 1.1 2025/11/08 07:04:02 mrg Exp $
+
+Fix NetBSD/arm64.
+
+
+--- libgcc/config.host.orig	2025-08-07 23:51:44.833420855 -0700
++++ libgcc/config.host	2025-11-07 03:15:28.811881325 -0800
+@@ -424,6 +424,7 @@ aarch64*-*-freebsd*)
+ aarch64*-*-netbsd*)
+ 	extra_parts="$extra_parts crtfastmath.o"
+ 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
++	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
+ 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
+ 	tmake_file="${tmake_file} t-dfprules"
+ 	md_unwind_def_header=aarch64/aarch64-unwind-def.h
diff --git a/gcc16/patches/patch-libgcc_crtstuff.c b/gcc16/patches/patch-libgcc_crtstuff.c
new file mode 100644
index 0000000000..bbb3d2087c
--- /dev/null
+++ b/gcc16/patches/patch-libgcc_crtstuff.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-libgcc_crtstuff.c,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90147
+
+--- libgcc/crtstuff.c.orig	2025-04-25 08:18:04.000000000 +0000
++++ libgcc/crtstuff.c
+@@ -81,7 +81,7 @@ call_ ## FUNC (void)					\
+ #endif
+ 
+ #if defined(TARGET_DL_ITERATE_PHDR) && \
+-   (defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__))
++   (defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
+ #define BSD_DL_ITERATE_PHDR_AVAILABLE
+ #endif
+ 
diff --git a/gcc16/patches/patch-libgcobol_configure.tgt b/gcc16/patches/patch-libgcobol_configure.tgt
new file mode 100644
index 0000000000..af7ee0d982
--- /dev/null
+++ b/gcc16/patches/patch-libgcobol_configure.tgt
@@ -0,0 +1,31 @@
+$NetBSD: patch-libgcobol_configure.tgt,v 1.1 2025/11/08 07:04:02 mrg Exp $
+
+Enable libgcobol on NetBSD amd64, arm64, and riscv64.
+
+
+--- libgcobol/configure.tgt.orig	2025-08-07 23:51:44.929422457 -0700
++++ libgcobol/configure.tgt	2025-11-06 11:01:55.070054980 -0800
+@@ -26,7 +26,7 @@
+ LIBGCOBOL_SUPPORTED=no
+ 
+ case "${target}" in
+-    aarch64*-*-linux*)
++    aarch64*-*-linux* | aarch64*-*-netbsd*)
+ 	LIBGCOBOL_SUPPORTED=yes
+ 	;;
+     powerpc64le-*-linux*)
+@@ -34,12 +34,12 @@ case "${target}" in
+ 		LIBGCOBOL_SUPPORTED=yes
+ 	fi
+ 	;;
+-    riscv64-*-linux*)
++    riscv64-*-linux* | riscv64-*-netbsd*)
+ 	if test x$ac_cv_sizeof_void_p = x8; then
+ 		LIBGCOBOL_SUPPORTED=yes
+ 	fi
+ 	;;
+-    x86_64-*-linux* | i?86-*-linux* | x86_64-*-darwin*)
++    x86_64-*-linux* | i?86-*-linux* | x86_64-*-darwin* | x86_64-*-netbsd*)
+ 	if test x$ac_cv_sizeof_void_p = x8; then
+ 		LIBGCOBOL_SUPPORTED=yes
+ 	fi
diff --git a/gcc16/patches/patch-libgfortran_io_io.h b/gcc16/patches/patch-libgfortran_io_io.h
new file mode 100644
index 0000000000..886b328d39
--- /dev/null
+++ b/gcc16/patches/patch-libgfortran_io_io.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-libgfortran_io_io.h,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Don't declare old_locale* an internal_proto to avoid linking problems
+
+--- libgfortran/io/io.h.orig	2018-01-07 10:17:52.000000000 +0000
++++ libgfortran/io/io.h
+@@ -57,11 +57,8 @@ extern locale_t c_locale;
+ internal_proto(c_locale);
+ #else
+ extern char* old_locale;
+-internal_proto(old_locale);
+ extern int old_locale_ctr;
+-internal_proto(old_locale_ctr);
+ extern __gthread_mutex_t old_locale_lock;
+-internal_proto(old_locale_lock);
+ #endif
+ 
+ 
diff --git a/gcc16/patches/patch-libquadmath_printf_quadmath-printf.c b/gcc16/patches/patch-libquadmath_printf_quadmath-printf.c
new file mode 100644
index 0000000000..65ad906b62
--- /dev/null
+++ b/gcc16/patches/patch-libquadmath_printf_quadmath-printf.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-libquadmath_printf_quadmath-printf.c,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Fix -Werror=char-subscripts.
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95178
+
+--- libquadmath/printf/quadmath-printf.c.orig	2020-05-07 10:50:02.000000000 +0000
++++ libquadmath/printf/quadmath-printf.c
+@@ -189,7 +189,7 @@ quadmath_snprintf (char *str, size_t siz
+       ++format;
+       info.width = va_arg (ap, int);
+     }
+-  else if (isdigit (*format))
++  else if (isdigit ((unsigned char) *format))
+     /* Constant width specification.  */
+     info.width = read_int (&format);
+ 
+@@ -206,7 +206,7 @@ quadmath_snprintf (char *str, size_t siz
+ 
+ 	  info.prec = va_arg (ap, int);
+ 	}
+-      else if (isdigit (*format))
++      else if (isdigit ((unsigned char) *format))
+ 	info.prec = read_int (&format);
+       else
+ 	/* "%.?" is treated like "%.0?".  */
diff --git a/gcc16/patches/patch-libquadmath_strtod_strtod__l.c b/gcc16/patches/patch-libquadmath_strtod_strtod__l.c
new file mode 100644
index 0000000000..6f029f0d02
--- /dev/null
+++ b/gcc16/patches/patch-libquadmath_strtod_strtod__l.c
@@ -0,0 +1,23 @@
+$NetBSD: patch-libquadmath_strtod_strtod__l.c,v 1.1 2025/07/14 17:44:53 wiz Exp $
+
+Fix -Werror=char-subscripts.
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95178
+
+--- libquadmath/strtod/strtod_l.c.orig	2020-05-07 10:50:02.000000000 +0000
++++ libquadmath/strtod/strtod_l.c
+@@ -57,10 +57,10 @@
+ # define STRING_TYPE char
+ # define CHAR_TYPE char
+ # define L_(Ch) Ch
+-# define ISSPACE(Ch) isspace (Ch)
+-# define ISDIGIT(Ch) isdigit (Ch)
+-# define ISXDIGIT(Ch) isxdigit (Ch)
+-# define TOLOWER(Ch) tolower (Ch)
++# define ISSPACE(Ch) isspace ((unsigned char) Ch)
++# define ISDIGIT(Ch) isdigit ((unsigned char) Ch)
++# define ISXDIGIT(Ch) isxdigit ((unsigned char) Ch)
++# define TOLOWER(Ch) tolower ((unsigned char) Ch)
+ # define TOLOWER_C(Ch) \
+   ({__typeof(Ch) __tlc = (Ch); \
+     (__tlc >= 'A' && __tlc <= 'Z') ? __tlc - 'A' + 'a' : __tlc; })
diff --git a/gcc16/version.mk b/gcc16/version.mk
new file mode 100644
index 0000000000..cfa620e412
--- /dev/null
+++ b/gcc16/version.mk
@@ -0,0 +1,3 @@
+# $NetBSD: version.mk,v 1.2 2025/08/09 15:53:10 wiz Exp $
+
+GCC16_DIST_VERSION:=	16.1.0


Home | Main Index | Thread Index | Old Index