pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
gcc15-gnat{-libs}: add new packages version 15.1.0 (preview)
Module Name: pkgsrc-wip
Committed By: Dmytro Kazankov <dkazankov%NetBSD.org@localhost>
Pushed By: dkazankov
Date: Thu May 8 08:06:23 2025 +0300
Changeset: eb9d9410e5f5b8efdd0ad731e6cbda85e06f8375
Added Files:
gcc15-gnat-libs/DESCR
gcc15-gnat-libs/Makefile
gcc15-gnat-libs/buildlink3.mk
gcc15-gnat/DESCR
gcc15-gnat/Makefile
gcc15-gnat/buildlink3.mk
gcc15-gnat/distinfo
gcc15-gnat/options.mk
gcc15-gnat/patches/patch-gcc_Makefile.in
gcc15-gnat/patches/patch-gcc_ada_Makefile.rtl
gcc15-gnat/patches/patch-gcc_ada_adaint.c
gcc15-gnat/patches/patch-gcc_ada_adaint.h
gcc15-gnat/patches/patch-gcc_ada_cstreams.c
gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.adb
gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.ads
gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-taprop____posix.adb
gcc15-gnat/patches/patch-gcc_ada_s-oscons-tmplt.c
gcc15-gnat/patches/patch-gcc_ada_sysdep.c
gcc15-gnat/patches/patch-gcc_ada_terminals.c
gcc15-gnat/patches/patch-gcc_ada_tracebak.c
gcc15-gnat/patches/patch-gcc_config.host
gcc15-gnat/patches/patch-gcc_configure
gcc15-gnat/patches/patch-gcc_tree.h
gcc15-gnat/patches/patch-gnattools_configure
gcc15-gnat/patches/patch-libcody_configure
gcc15-gnat/patches/patch-libffi_configure
gcc15-gnat/patches/patch-libffi_testsuite_libffi.call_float2.c
gcc15-gnat/patches/patch-libgcc_crtstuff.c
gcc15-gnat/patches/patch-libgomp_configure.tgt
gcc15-gnat/patches/patch-libquadmath_printf_quadmath-printf.c
gcc15-gnat/patches/patch-libquadmath_strtod_strtod__l.c
gcc15-gnat/patches/patch-libstdc++-v3_libsupc++_new__opa.cc
Log Message:
gcc15-gnat{-libs}: add new packages version 15.1.0 (preview)
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=eb9d9410e5f5b8efdd0ad731e6cbda85e06f8375
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
gcc15-gnat-libs/DESCR | 5 +
gcc15-gnat-libs/Makefile | 66 +++
gcc15-gnat-libs/buildlink3.mk | 31 +
gcc15-gnat/DESCR | 3 +
gcc15-gnat/Makefile | 267 +++++++++
gcc15-gnat/buildlink3.mk | 39 ++
gcc15-gnat/distinfo | 29 +
gcc15-gnat/options.mk | 103 ++++
gcc15-gnat/patches/patch-gcc_Makefile.in | 16 +
gcc15-gnat/patches/patch-gcc_ada_Makefile.rtl | 158 +++++
gcc15-gnat/patches/patch-gcc_ada_adaint.c | 88 +++
gcc15-gnat/patches/patch-gcc_ada_adaint.h | 35 ++
gcc15-gnat/patches/patch-gcc_ada_cstreams.c | 25 +
.../patch-gcc_ada_libgnarl_s-osinte____netbsd.adb | 123 ++++
.../patch-gcc_ada_libgnarl_s-osinte____netbsd.ads | 647 +++++++++++++++++++++
.../patch-gcc_ada_libgnarl_s-taprop____posix.adb | 27 +
gcc15-gnat/patches/patch-gcc_ada_s-oscons-tmplt.c | 94 +++
gcc15-gnat/patches/patch-gcc_ada_sysdep.c | 42 ++
gcc15-gnat/patches/patch-gcc_ada_terminals.c | 15 +
gcc15-gnat/patches/patch-gcc_ada_tracebak.c | 15 +
gcc15-gnat/patches/patch-gcc_config.host | 15 +
gcc15-gnat/patches/patch-gcc_configure | 15 +
gcc15-gnat/patches/patch-gcc_tree.h | 15 +
gcc15-gnat/patches/patch-gnattools_configure | 16 +
gcc15-gnat/patches/patch-libcody_configure | 33 ++
gcc15-gnat/patches/patch-libffi_configure | 16 +
.../patch-libffi_testsuite_libffi.call_float2.c | 15 +
gcc15-gnat/patches/patch-libgcc_crtstuff.c | 15 +
gcc15-gnat/patches/patch-libgomp_configure.tgt | 18 +
.../patch-libquadmath_printf_quadmath-printf.c | 26 +
.../patches/patch-libquadmath_strtod_strtod__l.c | 23 +
.../patch-libstdc++-v3_libsupc++_new__opa.cc | 17 +
32 files changed, 2052 insertions(+)
diffs:
diff --git a/gcc15-gnat-libs/DESCR b/gcc15-gnat-libs/DESCR
new file mode 100644
index 0000000000..e110d7fdd5
--- /dev/null
+++ b/gcc15-gnat-libs/DESCR
@@ -0,0 +1,5 @@
+The GNU Compiler Collection (GCC) GNAT libraries
+
+This packages provides GNAT support libraries in a specific location and allows
+packages to depend on just the libraries rather than having to pull in the full
+GNAT package.
diff --git a/gcc15-gnat-libs/Makefile b/gcc15-gnat-libs/Makefile
new file mode 100644
index 0000000000..55cb101404
--- /dev/null
+++ b/gcc15-gnat-libs/Makefile
@@ -0,0 +1,66 @@
+# $NetBSD: Makefile,v 1.1 2025/04/27 12:00:00 dkazankov Exp $
+
+GCC_PKGNAME= gcc15-gnat
+GCC_DIST_VERSION= 15.1.0
+
+DISTNAME= gcc-${GCC_DIST_VERSION}
+PKGNAME= ${GCC_PKGNAME}-libs-${GCC_DIST_VERSION}
+
+## The PKGREVISION of this package needs to be at least 1 more than the
+## PKGREVISION of the lang/gcc15-gnat package so that with the dependence pattern
+## '{gcc15-gnat,gcc15-gnat-libs}>=15.1.*' pkg_add will choose gcc15-gnat-libs over gcc15-gnat.
+PKGREVISION= 1
+
+CATEGORIES= lang
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= dkazankov%NetBSD.org@localhost
+HOMEPAGE= https://gcc.gnu.org/
+COMMENT= The GNU Compiler Collection (GCC) GNAT support shared libraries
+LICENSE= gnu-gpl-v2 AND gnu-gpl-v3 AND gnu-lgpl-v2 AND gnu-lgpl-v3
+
+USE_TOOLS+= pax
+
+CHECK_SHLIBS_SUPPORTED= no
+CHECK_RELRO_SUPPORTED= no
+
+## Depend on exactly ${GCC_DIST_VERSION}.
+TOOL_DEPENDS+= ${GCC_PKGNAME}-${GCC_DIST_VERSION}{,nb[0-9]*}:../../wip/${GCC_PKGNAME}
+
+.include "../../mk/bsd.prefs.mk"
+
+LIBGCC_SUBPREFIX= ${GCC_PKGNAME}
+LIBGCC_PREFIX= ${LOCALBASE}/${LIBGCC_SUBPREFIX}
+GCC_TARGET_MACHINE?= ${MACHINE_GNU_PLATFORM}
+BUILD_DEFS+= GCC_PKGNAME
+BUILD_DEFS+= GCC_TARGET_MACHINE
+
+LIBRARY_FILES= ${WRKDIR}/library_files
+
+do-build:
+ ${PKG_INFO} -qL '${GCC_PKGNAME}-${GCC_DIST_VERSION}*' | \
+ ${SED} -n -e's,^${LIBGCC_PREFIX}/,,p' | \
+ ${SED} -n -e'/lib\/.*\/crt.*\.o/p' \
+ -e'/lib\/.*\/adalib\/lib.*\.so.*/p' \
+ -e'/.*\/ada_target_properties/p' \
+ -e'/lib\/lib.*\.so.*/p' \
+ > ${LIBRARY_FILES}
+
+TARGET_LIBDIR= ${GCC_PKGNAME}/${GCC_TARGET_MACHINE}/lib
+
+do-install:
+ ${TEST} -d ${DESTDIR}${LOCALBASE}/${TARGET_LIBDIR} || \
+ ${MKDIR} ${DESTDIR}${LOCALBASE}/${TARGET_LIBDIR}
+ cd ${LIBGCC_PREFIX} && \
+ ${PAX} -rw -s '/^\(.*\/\)\([^\/]*\)/\2/' \
+ ${DESTDIR}${LOCALBASE}/${TARGET_LIBDIR} <${LIBRARY_FILES}
+
+GENERATE_PLIST+= ${ECHO} '@pkgdir ${TARGET_LIBDIR}' ;
+GENERATE_PLIST+= ${SED} -e 's,^\(.*\/\)\([^\/]*\),\2,' ${LIBRARY_FILES} | \
+ ${SED} -e 's,^,${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/lib/,' ;
+
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/gcc15-gnat-libs/buildlink3.mk b/gcc15-gnat-libs/buildlink3.mk
new file mode 100644
index 0000000000..d71f9f8c8d
--- /dev/null
+++ b/gcc15-gnat-libs/buildlink3.mk
@@ -0,0 +1,31 @@
+# $NetBSD: buildlink3.mk,v 1.1 2025/04/27 12:00:00 dkazankov Exp $
+
+BUILDLINK_TREE+= gcc15-gnat-libs
+
+.if !defined(GCC15_GNAT_LIBS_BUILDLINK3_MK)
+GCC15_GNAT_LIBS_BUILDLINK3_MK:=
+
+.if !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
+BUILDLINK_API_DEPENDS.gcc15-gnat-libs+= gcc15-gnat-libs>=15.1.0
+.else
+BUILDLINK_API_DEPENDS.gcc15-gnat-libs+= {gcc15-gnat,gcc15-gnat-libs}>=15.1.0
+.endif
+BUILDLINK_PKGSRCDIR.gcc15-gnat-libs= ../../wip/gcc15-gnat-libs
+BUILDLINK_DEPMETHOD.gcc15-gnat-libs?= full
+
+GCC_TARGET_MACHINE?= ${MACHINE_GNU_PLATFORM}
+
+TARGET_LIBDIR.gcc15-gnat-libs= ${PREFIX}/gcc15-gnat/${GCC_TARGET_MACHINE}/lib
+
+BUILDLINK_PASSTHRU_DIRS+= ${TARGET_LIBDIR.gcc15-gnat-libs}
+
+BUILDLINK_FILES.gcc15-gnat-libs= #empty
+BUILDLINK_AUTO_VARS.gcc15-gnat-libs= no
+BUILDLINK_AUTO_DIRS.gcc15-gnat-libs= no
+
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+
+.endif # GCC15_GNAT_LIBS_BUILDLINK3_MK
+
+BUILDLINK_TREE+= -gcc15-gnat-libs
diff --git a/gcc15-gnat/DESCR b/gcc15-gnat/DESCR
new file mode 100644
index 0000000000..19c8ca29ec
--- /dev/null
+++ b/gcc15-gnat/DESCR
@@ -0,0 +1,3 @@
+The GNU Compiler Collection (GCC)
+
+This package contains GNAT compiler and Ada tools
diff --git a/gcc15-gnat/Makefile b/gcc15-gnat/Makefile
new file mode 100644
index 0000000000..88ef2cafac
--- /dev/null
+++ b/gcc15-gnat/Makefile
@@ -0,0 +1,267 @@
+# $NetBSD: Makefile,v 1.1 2025/04/27 12:00:00 dkazankov Exp $
+
+GCC_PKGNAME= gcc15-gnat
+GCC_DIST_VERSION= 15.1.0
+
+PKGNAME= ${GCC_PKGNAME}-${GCC_DIST_VERSION}
+COMMENT= GNAT compiler and Ada tools
+DISTNAME= gcc-${GCC_DIST_VERSION}
+CATEGORIES= lang
+MASTER_SITES= ${MASTER_SITE_GNU:=gcc/gcc-${GCC_DIST_VERSION}/}
+EXTRACT_SUFX= .tar.xz
+
+MAINTAINER= dkazankov%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}
+
+#CHECK_PIE_SUPPORTED= no
+#CHECK_RELRO_SUPPORTED= no
+
+# We really need gcc10-aux as bootstrap compiler only.
+# Although gcc6-aux can no longer be used for this.
+TOOL_DEPENDS+= gcc10-aux-[0-9]*:../../lang/gcc10-aux
+
+USE_TOOLS+= gmake makeinfo sed perl flex bison
+USE_TOOLS.NetBSD+= gsed
+TEXINFO_REQD= 7.0
+BISON_REQD= 3.5
+
+GNU_CONFIGURE= yes
+GNU_CONFIGURE_STRICT= no
+
+UNLIMIT_RESOURCES+= datasize
+UNLIMIT_RESOURCES+= stacksize
+
+CHECK_PORTABILITY_SKIP+= contrib/*
+CHECK_PORTABILITY_SKIP+= gcc/configure.orig_dist
+
+# The following is added from gcc6-aux because gcc10-aux (GNAT bootstrap compiler for GNAT 13-15 packages)
+# can only be built with gcc6-aux. In turn, this limitation comes from the fact that bootstrap
+# compilers for gcc6-aux are only available for these platforms.
+ONLY_FOR_PLATFORM= DragonFly-*-x86_64 \
+ FreeBSD-*-i386 \
+ FreeBSD-*-x86_64 \
+ SunOS-5.1[1-9]*-i386 \
+ SunOS-5.1[1-9]*-x86_64 \
+ NetBSD-*-i386 \
+ NetBSD-*-x86_64
+
+# *-i386 builds of gcc6-aux are broken for now (as on 2025/05/01)
+BROKEN_ON_PLATFORM= *-*-i386
+
+.include "../../mk/bsd.prefs.mk"
+
+.include "options.mk"
+
+BOOTC_BASE= ${LOCALBASE}/gcc10-aux
+BOOTC_LD_LIBRARY_PATH= ${BOOTC_BASE}/lib:${BOOTC_BASE}/lib/gcc/${MACHINE_GNU_PLATFORM}/10.3.0:${BOOTC_BASE}/lib/gcc/${MACHINE_GNU_PLATFORM}/10.3.0/adalib
+
+CONFIGURE_ENV+= CC_FOR_BUILD=${BOOTC_BASE}/bin/gcc
+CONFIGURE_ENV+= CXX_FOR_BUILD=${BOOTC_BASE}/bin/g++
+
+MAKE_ENV+= LD_LIBRARY_PATH=${BOOTC_LD_LIBRARY_PATH}
+
+## Build outside ${WRKSRC}
+OBJDIR= ${WRKDIR}/build
+CONFIGURE_DIRS= ${OBJDIR}
+CONFIGURE_SCRIPT= ${WRKSRC}/configure
+GCC_SUBPREFIX= ${GCC_PKGNAME}
+GCC_PREFIX= ${PREFIX}/${GCC_SUBPREFIX}
+GNU_CONFIGURE_PREFIX= ${GCC_PREFIX}
+INFO_FILES= yes
+CONFIGURE_ARGS+= --disable-libstdcxx-pch
+
+STAGE1_LDFLAGS= ${LDFLAGS} -static
+
+# 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= ${COMPILER_RPATH_FLAG}${PREFIX}/lib
+LDFLAGS_FOR_TARGET+= ${COMPILER_RPATH_FLAG}${GCC_PREFIX}/lib
+LDFLAGS_FOR_TARGET+= ${COMPILER_RPATH_FLAG}${GCC_PREFIX}/lib/gcc/${MACHINE_GNU_PLATFORM}/${GCC_DIST_VERSION}/adalib
+
+# 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
+BOOT_LDFLAGS+= ${LDFLAGS_FOR_TARGET}
+# Needed on Darwin when LDFLAGS point to a SDK
+.if !empty(OSX_SDK_PATH)
+BOOT_LDFLAGS+= ${LDFLAGS:M-Wl,-syslibroot*}
+.endif
+# 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 ${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
+
+CONFIGURE_ARGS+= --enable-languages=ada,c,c++ --enable-stage1-languages=c,c++,ada
+
+#CONFIGURE_ARGS+= --with-static-standard-libraries
+# This will create slightly slower compiler
+CONFIGURE_ARGS+= --enable-shared
+CONFIGURE_ARGS+= --enable-host-shared
+CONFIGURE_ARGS+= --enable-host-pie
+CONFIGURE_ARGS+= --enable-host-bind-now
+#CONFIGURE_ARGS+= --enable-default-pie
+#CONFIGURE_ARGS+= --with-newlib
+CONFIGURE_ARGS+= --enable-long-long
+CONFIGURE_ARGS+= --with-local-prefix=${GCC_PREFIX:Q}
+CONFIGURE_ARGS+= --with-gxx-include-dir='${GCC_PREFIX}/include/c++'
+CONFIGURE_ARGS+= --enable-__cxa_atexit
+CONFIGURE_ARGS+= --enable-threads=posix
+CONFIGURE_ARGS+= --with-stage1-ldflags=${STAGE1_LDFLAGS:Q}
+CONFIGURE_ARGS+= --with-boot-ldflags=${BOOT_LDFLAGS:Q}
+# causes build errors even when using lang/gcc* 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
+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}
+
+# GCC 15 requires latest binutils
+BUILDLINK_API_DEPENDS.binutils+= binutils>=2.35
+.include "../../devel/binutils/buildlink3.mk"
+
+CONFIGURE_ARGS+= --with-gnu-ld --with-ld=${PREFIX}/bin/gld
+CONFIGURE_ARGS+= --with-gnu-as --with-as=${PREFIX}/bin/gas
+
+.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
+
+# Use C preprocessed symbols on NetBSD
+.if ${OPSYS} == "NetBSD"
+SUBST_CLASSES+= select
+SUBST_MESSAGE.select= Replace select with __gnat_select in ${SUBST_FILES.select}
+SUBST_STAGE.select= post-patch
+SUBST_FILES.select= gcc/ada/libgnat/g-socthi.ads
+SUBST_SED.select= -e "s,\"select\",\"__gnat_select\","
+
+SUBST_CLASSES+= nanosleep
+SUBST_MESSAGE.nanosleep= Replace nanosleep with __gnat_nanosleep in ${SUBST_FILES.nanosleep}
+SUBST_STAGE.nanosleep= post-patch
+SUBST_FILES.nanosleep= gcc/ada/libgnat/s-osprim__posix.adb
+SUBST_SED.nanosleep= -e "s,\"nanosleep\",\"__gnat_nanosleep\","
+
+SUBST_CLASSES+= gettimeofday
+SUBST_MESSAGE.gettimeofday= Replace gettimeofday with __gnat_gettimeofday in ${SUBST_FILES.gettimeofday}
+SUBST_STAGE.gettimeofday= post-patch
+SUBST_FILES.gettimeofday= gcc/ada/libgnat/s-osprim__posix.adb
+SUBST_SED.gettimeofday= -e "s,\"gettimeofday\",\"__gnat_gettimeofday\","
+.endif
+
+CTF_FILES_SKIP+= */gengtype # CPU limit exceeded
+
+TEST_TARGET= -j ${MAKE_JOBS} -k check || ${TRUE}
+TEST_DEPENDS+= dejagnu-[0-9]*:../../devel/dejagnu
+
+pre-configure:
+ ${RUN} cd ${WRKSRC} && ${MKDIR} ${OBJDIR}
+
+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:
+# Fix group write mode
+ ${CHMOD} g-w ${DESTDIR}${GCC_PREFIX}/lib/gcc/${MACHINE_GNU_PLATFORM}/${GCC_DIST_VERSION}/adainclude/standard.ads.h
+# Create old name that modern gnat no longer provides
+ ${TEST} -f ${DESTDIR}${GCC_PREFIX}/bin/gnat && \
+ ( cd ${DESTDIR}${GCC_PREFIX}/bin ; ${LN} -f gnat ada )
+.if ${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 -or -type l \) -print | ${SORT};
+
+.include "../../archivers/zstd/buildlink3.mk"
+CONFIGURE_ARGS+= --with-zstd=${BUILDLINK_PREFIX.zstd}
+
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
+
+# This should be here so we ensure that bootstrap compiler is at the beginning of the list
+PREPEND_PATH+= ${BOOTC_BASE}/bin
diff --git a/gcc15-gnat/buildlink3.mk b/gcc15-gnat/buildlink3.mk
new file mode 100644
index 0000000000..0b3726c307
--- /dev/null
+++ b/gcc15-gnat/buildlink3.mk
@@ -0,0 +1,39 @@
+# $NetBSD: buildlink3.mk,v 1.1 2025/04/27 12:00:00 dkazankov Exp $
+
+BUILDLINK_TREE+= gcc15-gnat
+
+.if !defined(GCC15_GNAT_BUILDLINK3_MK)
+GCC15_GNAT_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.gcc15-gnat+= gcc15-gnat>=15
+BUILDLINK_ABI_DEPENDS.gcc15-gnat+= gcc15-gnat>=15.1
+BUILDLINK_PKGSRCDIR.gcc15-gnat= ../../wip/gcc15-gnat
+BUILDLINK_DEPMETHOD.gcc15-gnat?= build
+
+PREPEND_PATH+= ${BUILDLINK_DIR}/gcc15-gnat/bin
+
+GNU_TARGET_MACHINE?= ${MACHINE_GNU_PLATFORM}
+
+ADALIB_PREFIX= gcc15-gnat/lib/gcc/${GNU_TARGET_MACHINE}/15.1.0
+
+BUILDLINK_FILES.gcc15-gnat+= gcc15-gnat/${GNU_TARGET_MACHINE}/lib/*
+
+BUILDLINK_INCDIRS.gcc15-gnat+= gcc15-gnat/include
+BUILDLINK_INCDIRS.gcc15-gnat+= ${ADALIB_PREFIX}/include
+BUILDLINK_INCDIRS.gcc15-gnat+= ${ADALIB_PREFIX}/include-fixed
+BUILDLINK_INCDIRS.gcc15-gnat+= ${ADALIB_PREFIX}/plugin/include
+BUILDLINK_INCDIRS.gcc15-gnat+= ${ADALIB_PREFIX}/adainclude
+
+BUILDLINK_LIBDIRS.gcc15-gnat+= gcc15-gnat/lib
+BUILDLINK_LIBDIRS.gcc15-gnat+= ${ADALIB_PREFIX}
+BUILDLINK_LIBDIRS.gcc15-gnat+= ${ADALIB_PREFIX}/adalib
+BUILDLINK_LIBDIRS.gcc15-gnat+= gcc15-gnat/${GNU_TARGET_MACHINE}/lib
+
+BUILDLINK_CONTENTS_FILTER.gcc15-gnat= ${EGREP} \
+ '(bin/.*|include/.*|lib/.*|libexec/.*|${GNU_TARGET_MACHINE}/lib/.*)'
+
+pkgbase := gcc15-gnat
+.include "../../mk/pkg-build-options.mk"
+.endif
+
+BUILDLINK_TREE+= -gcc15-gnat
diff --git a/gcc15-gnat/distinfo b/gcc15-gnat/distinfo
new file mode 100644
index 0000000000..1cf88535e8
--- /dev/null
+++ b/gcc15-gnat/distinfo
@@ -0,0 +1,29 @@
+$NetBSD: distinfo,v 1.1 2025/04/25 19:35:10 dkazankov Exp $
+
+BLAKE2s (gcc-15.1.0.tar.xz) = 260d64654fbfc0ee06540cc4604cd7071be53d616069a9dd57e5359a0b0ecf46
+SHA512 (gcc-15.1.0.tar.xz) = ddd35ca6c653dffa88f7c7ef9ee4cd806e156e0f3b30f4d63e75a8363361285cd566ee73127734cde6a934611de815bee3e32e24bfd2e0ab9f7ff35c929821c1
+Size (gcc-15.1.0.tar.xz) = 98268344 bytes
+SHA1 (patch-gcc_Makefile.in) = a3976de1679978fb7598fd5777ea1ab4bb596896
+SHA1 (patch-gcc_ada_Makefile.rtl) = 376acf3e0b26bf07d0e83c54437403945de604f0
+SHA1 (patch-gcc_ada_adaint.c) = 62411073bac71aa96d12c69a0b02a4206401f852
+SHA1 (patch-gcc_ada_adaint.h) = cc0f2733b97d92c5fbaa21b70e413f7bb5dc9b82
+SHA1 (patch-gcc_ada_cstreams.c) = 10b181c24c73cb2523deed6bb6d9c6b41404e9e0
+SHA1 (patch-gcc_ada_libgnarl_s-osinte____netbsd.adb) = 66bafa4b027e810f78b67eeee5510fa8bc897359
+SHA1 (patch-gcc_ada_libgnarl_s-osinte____netbsd.ads) = 81dfcba01ba4c4931b974cb00af27f5c7853a0d9
+SHA1 (patch-gcc_ada_libgnarl_s-taprop____posix.adb) = 492d40ef2406500f5913687bfe5c9a6e081459f5
+SHA1 (patch-gcc_ada_s-oscons-tmplt.c) = baecf8c28e267b2d2e7e1e7943eabd96bf87f411
+SHA1 (patch-gcc_ada_sysdep.c) = f227b82e81b551f80858be26563173949b2f4c85
+SHA1 (patch-gcc_ada_terminals.c) = b603d018fabb843cc68fa13caee307d48b0e9b62
+SHA1 (patch-gcc_ada_tracebak.c) = 4c80984e086debe6131030a8fed28f9d302bffe4
+SHA1 (patch-gcc_config.host) = bf95dd21bfdf79d173e745fbd35c9bb99fdf4087
+SHA1 (patch-gcc_configure) = 72983cd72129a920ec8123ab52f66026df909782
+SHA1 (patch-gcc_tree.h) = 402c23ae02a6d50d0899baa7e32205e3292f1eca
+SHA1 (patch-gnattools_configure) = ca592eb0ff40d7103ed69370b34a55de43ba6b09
+SHA1 (patch-libcody_configure) = 361fa471f6afb578782322586395faa8f4e9a40c
+SHA1 (patch-libffi_configure) = b7e3ac7febb98e789d7b662bd2e80edae61345a1
+SHA1 (patch-libffi_testsuite_libffi.call_float2.c) = 89e2dd6aaf2c1f75726f02362d8a8bf7178694ea
+SHA1 (patch-libgcc_crtstuff.c) = c5b079a2bc84b3b2e85a73a6631569d84aca9e2c
+SHA1 (patch-libgomp_configure.tgt) = ba20fd420b682ccf558832eab38a5f2acce5d176
+SHA1 (patch-libquadmath_printf_quadmath-printf.c) = 78e09f1e6d61ee57cee83275093cf46b2335d204
+SHA1 (patch-libquadmath_strtod_strtod__l.c) = 6142c10d34174174cce7f06c37eab04dc431b2dc
+SHA1 (patch-libstdc++-v3_libsupc++_new__opa.cc) = dc0bffea3a5172377a4bca3224cb0986a1708632
diff --git a/gcc15-gnat/options.mk b/gcc15-gnat/options.mk
new file mode 100644
index 0000000000..d32a55daa5
--- /dev/null
+++ b/gcc15-gnat/options.mk
@@ -0,0 +1,103 @@
+# $NetBSD: options.mk,v 1.1 2025/04/27 12:00:00 dkazankov Exp $
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.gcc15-gnat
+PKG_SUPPORTED_OPTIONS= nls gcc-inplace-math gcc-graphite
+PKG_SUGGESTED_OPTIONS= gcc-graphite
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+.if ${OPSYS} == "NetBSD"
+#PKG_SUGGESTED_OPTIONS+= nls
+.elif ${OPSYS} == "Linux"
+PKG_SUGGESTED_OPTIONS+= nls
+.elif ${OPSYS} == "DragonFly"
+PKG_SUGGESTED_OPTIONS+= nls
+.elif ${OPSYS} == "SunOS"
+PKG_SUGGESTED_OPTIONS+= gcc-inplace-math
+.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"
+
+###
+### Native Language Support
+###
+.if !empty(PKG_OPTIONS:Mnls)
+CONFIGURE_ARGS+= --enable-nls
+CONFIGURE_ARGS+= --with-libiconv-prefix=${BUILDLINK_PREFIX.iconv}
+MAKE_ENV+= ICONVPREFIX=${BUILDLINK_PREFIX.iconv}
+BUILDLINK_API_DEPENDS.iconv+= libiconv>=1.17
+#PREFER.iconv= pkgsrc
+.include "../../converters/libiconv/buildlink3.mk"
+BUILDLINK_API_DEPENDS.gettext+= gettext-lib>=0.14.5
+#PREFER.gettext= pkgsrc
+.include "../../devel/gettext-lib/buildlink3.mk"
+.include "../../devel/gettext-tools/msgfmt-desktop.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
+###
+BUILDLINK_API_DEPENDS.gmp+= gmp>=4.3.2
+BUILDLINK_API_DEPENDS.mpcomplex+= mpcomplex>=1.0.1
+BUILDLINK_API_DEPENDS.mpfr+= mpfr>=3.1.0
+.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)
+BUILDLINK_API_DEPENDS.isl+= isl>=0.15
+. if !empty(PKG_OPTIONS:Mgcc-inplace-math)
+. include "../../math/isl/inplace.mk"
+FORCE_CXX_STD= c++17
+. else
+. include "../../math/isl/buildlink3.mk"
+CONFIGURE_ARGS+= --with-isl=${BUILDLINK_PREFIX.isl}
+. endif
+.endif
diff --git a/gcc15-gnat/patches/patch-gcc_Makefile.in b/gcc15-gnat/patches/patch-gcc_Makefile.in
new file mode 100644
index 0000000000..cb2bec050a
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_Makefile.in
@@ -0,0 +1,16 @@
+$NetBSD: patch-gcc_Makefile.in,v 1.1 2025/04/25 19:35:10 dkazankov 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 2025-04-25 08:18:00.000000000 +0000
++++ gcc/Makefile.in
+@@ -2597,6 +2597,7 @@
+ # 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/gcc15-gnat/patches/patch-gcc_ada_Makefile.rtl b/gcc15-gnat/patches/patch-gcc_ada_Makefile.rtl
new file mode 100644
index 0000000000..ea8056f6d8
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_Makefile.rtl
@@ -0,0 +1,158 @@
+$NetBSD: patch-gcc_ada_Makefile.rtl,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add NetBSD as a target and generate the required files correctly.
+
+--- gcc/ada/Makefile.rtl.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/Makefile.rtl
+@@ -1991,6 +1991,151 @@
+ endif
+ endif
+
++# x86 NetBSD
++ifeq ($(SELECTED_PAIRS),PAIRS_NONE)
++ifeq ($(strip $(filter-out %86 netbsd%,$(target_cpu) $(target_os))),)
++
++ SELECTED_PAIRS=x86-netbsd
++
++ LIBGNAT_TARGET_PAIRS = \
++ a-intnam.ads<libgnarl/a-intnam__bsd.ads \
++ s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
++ s-intman.adb<libgnarl/s-intman__posix.adb \
++ s-mudido.adb<libgnarl/s-mudido__affinity.adb \
++ s-osinte.adb<libgnarl/s-osinte__netbsd.adb \
++ s-osinte.ads<libgnarl/s-osinte__netbsd.ads \
++ s-oslock.ads<libgnat/s-oslock__posix.ads \
++ s-osprim.adb<libgnat/s-osprim__posix.adb \
++ s-taprop.adb<libgnarl/s-taprop__posix.adb \
++ s-taspri.ads<libgnarl/s-taspri__posix.ads \
++ s-tpopsp.adb<libgnarl/s-tpopsp__posix.adb \
++ $(TRASYM_DWARF_UNIX_PAIRS) \
++ $(ATOMICS_TARGET_PAIRS) \
++ $(X86_TARGET_PAIRS) \
++ system.ads<libgnat/system-freebsd.ads
++
++ GNATLIB_SHARED = gnatlib-shared-dual
++
++ EXTRA_GNATRTL_NONTASKING_OBJS += g-sse.o g-ssvety.o
++ EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
++
++ EH_MECHANISM=-gcc
++ THREADSLIB= -lpthread -lrt
++ GMEM_LIB = gmemlib
++ LIBRARY_VERSION := $(LIB_VERSION)
++ MISCLIB = -lutil
++endif
++endif
++
++# x86-64 NetBSD
++ifeq ($(SELECTED_PAIRS),PAIRS_NONE)
++ifeq ($(strip $(filter-out %86_64 netbsd%,$(target_cpu) $(target_os))),)
++
++ SELECTED_PAIRS=x86_64-netbsd
++
++ LIBGNAT_TARGET_PAIRS = \
++ a-intnam.ads<libgnarl/a-intnam__bsd.ads \
++ s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
++ s-intman.adb<libgnarl/s-intman__posix.adb \
++ s-mudido.adb<libgnarl/s-mudido__affinity.adb \
++ s-osinte.adb<libgnarl/s-osinte__netbsd.adb \
++ s-osinte.ads<libgnarl/s-osinte__netbsd.ads \
++ s-oslock.ads<libgnat/s-oslock__posix.ads \
++ s-osprim.adb<libgnat/s-osprim__posix.adb \
++ s-taprop.adb<libgnarl/s-taprop__posix.adb \
++ s-taspri.ads<libgnarl/s-taspri__posix.ads \
++ s-tpopsp.adb<libgnarl/s-tpopsp__posix.adb \
++ $(TRASYM_DWARF_UNIX_PAIRS) \
++ $(ATOMICS_TARGET_PAIRS) \
++ $(X86_64_TARGET_PAIRS) \
++ $(GNATRTL_128BIT_PAIRS) \
++ system.ads<libgnat/system-freebsd.ads
++
++ GNATLIB_SHARED = gnatlib-shared-dual
++
++ EXTRA_GNATRTL_NONTASKING_OBJS += g-sse.o g-ssvety.o
++ EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
++ EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
++
++ EH_MECHANISM=-gcc
++ THREADSLIB= -lpthread -lrt
++ GMEM_LIB = gmemlib
++ LIBRARY_VERSION := $(LIB_VERSION)
++ MISCLIB = -lutil
++endif
++endif
++
++# arm NetBSD
++ifeq ($(SELECTED_PAIRS),PAIRS_NONE)
++ifeq ($(strip $(filter-out %arm netbsd%,$(target_cpu) $(target_os))),)
++
++ SELECTED_PAIRS=arm-netbsd
++
++ LIBGNAT_TARGET_PAIRS = \
++ a-intnam.ads<libgnarl/a-intnam__bsd.ads \
++ s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
++ s-intman.adb<libgnarl/s-intman__posix.adb \
++ s-mudido.adb<libgnarl/s-mudido__affinity.adb \
++ s-osinte.adb<libgnarl/s-osinte__netbsd.adb \
++ s-osinte.ads<libgnarl/s-osinte__netbsd.ads \
++ s-oslock.ads<libgnat/s-oslock__posix.ads \
++ s-osprim.adb<libgnat/s-osprim__posix.adb \
++ s-taprop.adb<libgnarl/s-taprop__posix.adb \
++ s-taspri.ads<libgnarl/s-taspri__posix.ads \
++ s-tpopsp.adb<libgnarl/s-tpopsp__posix.adb \
++ $(ATOMICS_TARGET_PAIRS) \
++ $(ATOMICS_BUILTINS_TARGET_PAIRS) \
++ system.ads<libgnat/system-freebsd.ads
++
++ GNATLIB_SHARED = gnatlib-shared-dual
++
++ EH_MECHANISM=-arm
++ THREADSLIB= -lpthread -lrt
++ GMEM_LIB = gmemlib
++ LIBRARY_VERSION := $(LIB_VERSION)
++ MISCLIB = -lutil
++endif
++endif
++
++# aarch64 NetBSD
++ifeq ($(SELECTED_PAIRS),PAIRS_NONE)
++ifeq ($(strip $(filter-out %aarch64 netbsd%,$(target_cpu) $(target_os))),)
++
++ SELECTED_PAIRS=aarch64-netbsd
++
++ LIBGNAT_TARGET_PAIRS = \
++ a-intnam.ads<libgnarl/a-intnam__bsd.ads \
++ a-nallfl.ads<libgnat/a-nallfl__wraplf.ads \
++ s-dorepr.adb<libgnat/s-dorepr__fma.adb \
++ s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
++ s-intman.adb<libgnarl/s-intman__posix.adb \
++ s-mudido.adb<libgnarl/s-mudido__affinity.adb \
++ s-osinte.adb<libgnarl/s-osinte__netbsd.adb \
++ s-osinte.ads<libgnarl/s-osinte__netbsd.ads \
++ s-oslock.ads<libgnat/s-oslock__posix.ads \
++ s-osprim.adb<libgnat/s-osprim__posix.adb \
++ s-taprop.adb<libgnarl/s-taprop__posix.adb \
++ s-taspri.ads<libgnarl/s-taspri__posix.ads \
++ s-tpopsp.adb<libgnarl/s-tpopsp__posix.adb \
++ $(TRASYM_DWARF_UNIX_PAIRS) \
++ $(ATOMICS_TARGET_PAIRS) \
++ $(ATOMICS_BUILTINS_TARGET_PAIRS) \
++ $(GNATRTL_128BIT_PAIRS) \
++ system.ads<libgnat/system-freebsd.ads
++
++ EXTRA_GNATRTL_NONTASKING_OBJS = $(GNATRTL_128BIT_OBJS)
++ EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
++
++ GNATLIB_SHARED = gnatlib-shared-dual
++
++ EH_MECHANISM=-gcc
++ THREADSLIB= -lpthread -lrt
++ GMEM_LIB = gmemlib
++ LIBRARY_VERSION := $(LIB_VERSION)
++ MISCLIB = -lutil
++endif
++endif
++
+ # S390 Linux
+ ifeq ($(SELECTED_PAIRS),PAIRS_NONE)
+ ifeq ($(strip $(filter-out s390% linux%,$(target_cpu) $(target_os))),)
diff --git a/gcc15-gnat/patches/patch-gcc_ada_adaint.c b/gcc15-gnat/patches/patch-gcc_ada_adaint.c
new file mode 100644
index 0000000000..61b0bed0f3
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_adaint.c
@@ -0,0 +1,88 @@
+$NetBSD: patch-gcc_ada_adaint.c,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+NetBSD does not use symbol versioning, which requires some functions
+to be preprocessed in C. This patch adds those functions definitions,
+not only for NetBSD, but for any other system too.
+
+--- gcc/ada/adaint.c.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/adaint.c
+@@ -853,7 +853,8 @@
+ }
+
+ #if defined (_WIN32) || defined (__linux__) || defined (__sun__) \
+- || defined (__FreeBSD__) || defined(__DragonFly__) || defined (__QNX__)
++ || defined (__FreeBSD__) || defined(__DragonFly__) || defined (__QNX__) \
++ || defined (__NetBSD__)
+ #define HAS_TARGET_WCHAR_T
+ #endif
+
+@@ -3714,6 +3715,69 @@
+ */
+ }
+
++#if defined(__NetBSD__)
++/* It's 2021, and NetBSD still doesn't use symbol versioning in their
++ * libraries. They mimic this by having header macros rename the function
++ * at compile time. If we don't wrap the functions, the osinte specification
++ * for NetBSD would need to import e.g. __sigaltstack14 instead of sigaltstack.
++ * By wrapping, new versions won't break gnat.
++ */
++int
++__gnat_sigemptyset (sigset_t *set) {
++ return sigemptyset (set);
++}
++int
++__gnat_sigfillset (sigset_t *set) {
++ return sigfillset (set);
++}
++int
++__gnat_sigaddset (sigset_t *set, int signo) {
++ return sigaddset (set, signo);
++}
++int
++__gnat_sigdelset (sigset_t *set, int signo) {
++ return sigdelset (set, signo);
++}
++int
++__gnat_sigismember (sigset_t *set, int signo) {
++ return sigismember (set, signo);
++}
++int
++__gnat_sigaltstack (const stack_t *ss, stack_t *oss) {
++ return sigaltstack (ss, oss);
++}
++int
++__gnat_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) {
++ return sigaction (sig, act, oact);
++}
++int
++__gnat_clock_getres (clockid_t clock_id, struct timespec *res) {
++ return clock_getres (clock_id, res);
++}
++int
++__gnat_clock_gettime (clockid_t clock_id, struct timespec *tp) {
++ return clock_gettime (clock_id, tp);
++}
++int
++__gnat_nanosleep (const struct timespec *rqtp, struct timespec *rmtp) {
++ return nanosleep (rqtp, rmtp);
++}
++int
++__gnat_gettimeofday (struct timeval * tp, struct timezone * tzp) {
++ return gettimeofday (tp, tzp);
++}
++
++int
++__gnat_select(int nfds, fd_set * readfds, fd_set * writefds,
++ fd_set * exceptfds, struct timeval * timeout) {
++ return select (nfds, readfds, writefds, exceptfds, timeout);
++}
++int
++__gnat_socket (int domain, int type, int protocol) {
++ return socket (domain, type, protocol);
++}
++#endif
++
+ #ifdef __cplusplus
+ }
+ #endif
diff --git a/gcc15-gnat/patches/patch-gcc_ada_adaint.h b/gcc15-gnat/patches/patch-gcc_ada_adaint.h
new file mode 100644
index 0000000000..a9739efb1b
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_adaint.h
@@ -0,0 +1,35 @@
+$NetBSD: patch-gcc_ada_adaint.h,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Due to the lack of symbol versioning in NetBSD, some functions need
+to be exported from C to be used correctly. This patch addresses
+that issue and makes sure that other systems also work correclty.
+
+--- gcc/ada/adaint.h.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/adaint.h
+@@ -348,6 +348,26 @@
+
+ extern const void * __gnat_get_executable_load_address (void);
+
++#if defined(__NetBSD__)
++#include <signal.h>
++extern int __gnat_sigemptyset (sigset_t *);
++extern int __gnat_sigfillset (sigset_t *);
++extern int __gnat_sigaddset (sigset_t *, int);
++extern int __gnat_sigdelset (sigset_t *, int);
++extern int __gnat_sigismember (sigset_t *, int);
++extern int __gnat_sigaltstack (const stack_t *, stack_t *);
++extern int __gnat_sigaction (int, const struct sigaction *, struct sigaction *);
++#include <time.h>
++extern int __gnat_nanosleep (const struct timespec *, struct timespec *);
++extern int __gnat_gettimeofday (struct timeval *, struct timezone *);
++#include <sys/select.h>
++extern int __gnat_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
++#include <sys/socket.h>
++extern int __gnat_socket (int, int, int);
++extern int __gnat_clock_getres (clockid_t, struct timespec *);
++extern int __gnat_clock_gettime (clockid_t, struct timespec *);
++#endif
++
+ #ifdef __cplusplus
+ }
+ #endif
diff --git a/gcc15-gnat/patches/patch-gcc_ada_cstreams.c b/gcc15-gnat/patches/patch-gcc_ada_cstreams.c
new file mode 100644
index 0000000000..27bc7be9c5
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_cstreams.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-gcc_ada_cstreams.c,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add missing defines
+
+--- gcc/ada/cstreams.c.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/cstreams.c
+@@ -186,7 +186,8 @@
+ *p = '\\';
+ }
+
+-#elif defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__)
++#elif defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__) \
++ || defined (__NetBSD__)
+
+ /* Use realpath function which resolves links and references to . and ..
+ on those Unix systems that support it. Note that GNU/Linux provides it but
+@@ -255,7 +256,7 @@
+ }
+
+ #elif defined (__linux__) || defined (__sun__) || defined (__FreeBSD__) \
+- || defined (__APPLE__)
++ || defined (__APPLE__) || defined (__NetBSD__)
+ /* section for platforms having ftello/fseeko */
+
+ __int64
diff --git a/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.adb b/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.adb
new file mode 100644
index 0000000000..dd303b84e7
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.adb
@@ -0,0 +1,123 @@
+$NetBSD: patch-gcc_ada_libgnarl_s-osinte____netbsd.adb,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add NetBSD interface
+
+--- /dev/null
++++ gcc/ada/libgnarl/s-osinte__netbsd.adb
+@@ -0,0 +1,116 @@
++------------------------------------------------------------------------------
++-- --
++-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
++-- --
++-- S Y S T E M . O S _ I N T E R F A C E --
++-- --
++-- B o d y --
++-- --
++-- Copyright (C) 1991-2015, Free Software Foundation, Inc. --
++-- --
++-- GNARL is free software; you can redistribute it and/or modify it under --
++-- terms of the GNU General Public License as published by the Free Soft- --
++-- ware Foundation; either version 3, or (at your option) any later ver- --
++-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
++-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
++-- or FITNESS FOR A PARTICULAR PURPOSE. --
++-- --
++-- As a special exception under Section 7 of GPL version 3, you are granted --
++-- additional permissions described in the GCC Runtime Library Exception, --
++-- version 3.1, as published by the Free Software Foundation. --
++-- --
++-- You should have received a copy of the GNU General Public License and --
++-- a copy of the GCC Runtime Library Exception along with this program; --
++-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
++-- <http://www.gnu.org/licenses/>. --
++-- --
++-- GNARL was developed by the GNARL team at Florida State University. It is --
++-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
++-- State University (http://www.gnat.com). --
++-- --
++------------------------------------------------------------------------------
++
++-- This is the NetBSD THREADS version of this package
++
++with Interfaces.C; use Interfaces.C;
++
++package body System.OS_Interface is
++
++ -----------
++ -- Errno --
++ -----------
++
++ function Errno return int is
++ type int_ptr is access all int;
++
++ function internal_errno return int_ptr;
++ pragma Import (C, internal_errno, "__errno");
++
++ begin
++ return (internal_errno.all);
++ end Errno;
++
++ --------------------
++ -- Get_Stack_Base --
++ --------------------
++
++ function Get_Stack_Base (thread : pthread_t) return Address is
++ pragma Unreferenced (thread);
++ begin
++ return Null_Address;
++ end Get_Stack_Base;
++
++ ------------------
++ -- pthread_init --
++ ------------------
++
++ procedure pthread_init is
++ begin
++ null;
++ end pthread_init;
++
++ -----------------
++ -- To_Duration --
++ -----------------
++
++ function To_Duration (TS : timespec) return Duration is
++ begin
++ return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9;
++ end To_Duration;
++
++ ------------------------
++ -- To_Target_Priority --
++ ------------------------
++
++ function To_Target_Priority
++ (Prio : System.Any_Priority) return Interfaces.C.int
++ is
++ begin
++ return Interfaces.C.int (Prio);
++ end To_Target_Priority;
++
++ -----------------
++ -- To_Timespec --
++ -----------------
++
++ function To_Timespec (D : Duration) return timespec is
++ S : time_t;
++ F : Duration;
++
++ begin
++ S := time_t (Long_Long_Integer (D));
++ F := D - Duration (S);
++
++ -- If F has negative value due to a round-up, adjust for positive F
++ -- value.
++
++ if F < 0.0 then
++ S := S - 1;
++ F := F + 1.0;
++ end if;
++
++ return timespec'(ts_sec => S,
++ ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
++ end To_Timespec;
++
++end System.OS_Interface;
diff --git a/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.ads b/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.ads
new file mode 100644
index 0000000000..df0da4dc98
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-osinte____netbsd.ads
@@ -0,0 +1,647 @@
+$NetBSD: patch-gcc_ada_libgnarl_s-osinte____netbsd.ads,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add NetBSD interface
+
+--- /dev/null
++++ gcc/ada/libgnarl/s-osinte__netbsd.ads
+@@ -0,0 +1,640 @@
++------------------------------------------------------------------------------
++-- --
++-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
++-- --
++-- S Y S T E M . O S _ I N T E R F A C E --
++-- --
++-- S p e c --
++-- --
++-- Copyright (C) 1991-1994, Florida State University --
++-- Copyright (C) 1995-2015, Free Software Foundation, Inc. --
++-- --
++-- GNAT is free software; you can redistribute it and/or modify it under --
++-- terms of the GNU General Public License as published by the Free Soft- --
++-- ware Foundation; either version 3, or (at your option) any later ver- --
++-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
++-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
++-- or FITNESS FOR A PARTICULAR PURPOSE. --
++-- --
++-- As a special exception under Section 7 of GPL version 3, you are granted --
++-- additional permissions described in the GCC Runtime Library Exception, --
++-- version 3.1, as published by the Free Software Foundation. --
++-- --
++-- You should have received a copy of the GNU General Public License and --
++-- a copy of the GCC Runtime Library Exception along with this program; --
++-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
++-- <http://www.gnu.org/licenses/>. --
++-- --
++-- GNARL was developed by the GNARL team at Florida State University. It is --
++-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
++-- State University (http://www.gnat.com). --
++-- --
++------------------------------------------------------------------------------
++
++-- This is the NetBSD PTHREADS version of this package.
++
++-- This package encapsulates all direct interfaces to OS services
++-- that are needed by the tasking run-time (libgnarl).
++
++-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
++-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
++
++with Ada.Unchecked_Conversion;
++
++with Interfaces.C;
++with System.OS_Locks;
++with System.Parameters;
++
++package System.OS_Interface is
++ pragma Preelaborate;
++
++ pragma Linker_Options ("-pthread");
++
++ subtype int is Interfaces.C.int;
++ subtype short is Interfaces.C.short;
++ subtype long is Interfaces.C.long;
++ subtype unsigned is Interfaces.C.unsigned;
++ subtype unsigned_short is Interfaces.C.unsigned_short;
++ subtype unsigned_long is Interfaces.C.unsigned_long;
++ subtype unsigned_char is Interfaces.C.unsigned_char;
++ subtype plain_char is Interfaces.C.plain_char;
++ subtype size_t is Interfaces.C.size_t;
++ subtype char_array is Interfaces.C.char_array;
++ subtype int64 is Interfaces.Integer_64;
++
++ -----------
++ -- Errno --
++ -----------
++
++ function Errno return int;
++ pragma Inline (Errno);
++
++ EAGAIN : constant := 35;
++ EINTR : constant := 4;
++ EINVAL : constant := 22;
++ ENOMEM : constant := 12;
++ ETIMEDOUT : constant := 60;
++
++ -------------
++ -- Signals --
++ -------------
++
++ Max_Interrupt : constant := 31;
++ type Signal is new int range 0 .. Max_Interrupt;
++ for Signal'Size use int'Size;
++
++ SIGHUP : constant := 1; -- hangup
++ SIGINT : constant := 2; -- interrupt (rubout)
++ SIGQUIT : constant := 3; -- quit (ASCD FS)
++ SIGILL : constant := 4; -- illegal instruction (not reset)
++ SIGTRAP : constant := 5; -- trace trap (not reset)
++ SIGIOT : constant := 6; -- IOT instruction
++ SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
++ SIGEMT : constant := 7; -- EMT instruction
++ SIGFPE : constant := 8; -- floating point exception
++ SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
++ SIGBUS : constant := 10; -- bus error
++ SIGSEGV : constant := 11; -- segmentation violation
++ SIGSYS : constant := 12; -- bad argument to system call
++ SIGPIPE : constant := 13; -- write on a pipe with no one to read it
++ SIGALRM : constant := 14; -- alarm clock
++ SIGTERM : constant := 15; -- software termination signal from kill
++ SIGURG : constant := 16; -- urgent condition on IO channel
++ SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
++ SIGTSTP : constant := 18; -- user stop requested from tty
++ SIGCONT : constant := 19; -- stopped process has been continued
++ SIGCLD : constant := 20; -- alias for SIGCHLD
++ SIGCHLD : constant := 20; -- child status change
++ SIGTTIN : constant := 21; -- background tty read attempted
++ SIGTTOU : constant := 22; -- background tty write attempted
++ SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
++ SIGXCPU : constant := 24; -- CPU time limit exceeded
++ SIGXFSZ : constant := 25; -- filesize limit exceeded
++ SIGVTALRM : constant := 26; -- virtual timer expired
++ SIGPROF : constant := 27; -- profiling time alarm
++ SIGWINCH : constant := 28; -- window size change
++ SIGINFO : constant := 29; -- information request (NetBSD/FreeBSD)
++ SIGUSR1 : constant := 30; -- user defined signal 1
++ SIGUSR2 : constant := 31; -- user defined signal 2
++
++ SIGADAABORT : constant := SIGABRT;
++ -- Change this if you want to use another signal for task abort.
++ -- SIGTERM might be a good one.
++
++ type Signal_Set is array (Natural range <>) of Signal;
++
++ -- Interrupts that must be unmasked at all times. NetBSD
++ -- pthreads will not allow an application to mask out any
++ -- interrupt needed by the threads library.
++ Unmasked : constant Signal_Set :=
++ (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
++
++ -- NetBSD will uses SIGPROF for timing. Do not allow a
++ -- handler to attach to this signal.
++ Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
++
++ type sigset_t is private;
++
++ function sigaddset
++ (set : access sigset_t;
++ sig : Signal) return int;
++ pragma Import (C, sigaddset, "__gnat_sigaddset");
++
++ function sigdelset
++ (set : access sigset_t;
++ sig : Signal) return int;
++ pragma Import (C, sigdelset, "__gnat_sigdelset");
++
++ function sigfillset (set : access sigset_t) return int;
++ pragma Import (C, sigfillset, "__gnat_sigfillset");
++
++ function sigismember
++ (set : access sigset_t;
++ sig : Signal) return int;
++ pragma Import (C, sigismember, "__gnat_sigismember");
++
++ function sigemptyset (set : access sigset_t) return int;
++ pragma Import (C, sigemptyset, "__gnat_sigemptyset");
++
++ -- sigcontext is architecture dependent, so define it private
++ type struct_sigcontext is private;
++
++ type struct_sigaction is record
++ sa_handler : System.Address;
++ sa_mask : sigset_t;
++ sa_flags : int;
++ end record;
++ pragma Convention (C, struct_sigaction);
++
++ type struct_sigaction_ptr is access all struct_sigaction;
++
++ SIG_BLOCK : constant := 1;
++ SIG_UNBLOCK : constant := 2;
++ SIG_SETMASK : constant := 3;
++
++ SIG_DFL : constant := 0;
++ SIG_IGN : constant := 1;
++ -- Added for completeness
++ SIG_ERR : constant := -1;
++ SIG_HOLD : constant := 3;
++
++ SA_SIGINFO : constant := 16#0040#;
++ SA_ONSTACK : constant := 16#0001#;
++
++ function sigaction
++ (sig : Signal;
++ act : struct_sigaction_ptr;
++ oact : struct_sigaction_ptr) return int;
++ pragma Import (C, sigaction, "__gnat_sigaction");
++
++ ----------
++ -- Time --
++ ----------
++
++ Time_Slice_Supported : constant Boolean := True;
++ -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
++
++ type timespec is private;
++
++ function nanosleep (rqtp, rmtp : access timespec) return int;
++ pragma Import (C, nanosleep, "__gnat_nanosleep");
++
++ type clockid_t is new unsigned;
++
++ function clock_getres
++ (clock_id : clockid_t;
++ res : access timespec) return int;
++ pragma Import (C, clock_getres, "__gnat_clock_getres");
++
++ function clock_gettime
++ (clock_id : clockid_t;
++ tp : access timespec)
++ return int;
++ pragma Import (C, clock_gettime, "__gnat_clock_gettime");
++
++ function To_Duration (TS : timespec) return Duration;
++ pragma Inline (To_Duration);
++
++ function To_Timespec (D : Duration) return timespec;
++ pragma Inline (To_Timespec);
++
++ type struct_timezone is record
++ tz_minuteswest : int;
++ tz_dsttime : int;
++ end record;
++ pragma Convention (C, struct_timezone);
++
++ procedure usleep (useconds : unsigned_long);
++ pragma Import (C, usleep, "usleep");
++
++ -------------------------
++ -- Priority Scheduling --
++ -------------------------
++
++ SCHED_OTHER : constant := 0;
++ SCHED_FIFO : constant := 1;
++ SCHED_RR : constant := 2;
++
++ function To_Target_Priority
++ (Prio : System.Any_Priority) return Interfaces.C.int;
++ -- Maps System.Any_Priority to a POSIX priority
++
++ -------------
++ -- Process --
++ -------------
++
++ type pid_t is private;
++
++ Self_PID : constant pid_t;
++
++ function kill (pid : pid_t; sig : Signal) return int;
++ pragma Import (C, kill, "__gnat_kill");
++
++ function getpid return pid_t;
++ pragma Import (C, getpid, "getpid");
++
++ ---------
++ -- LWP --
++ ---------
++
++ function lwp_self return System.Address;
++ -- lwp_self does not exist on this thread library, revert to pthread_self
++ -- which is the closest approximation (with getpid). This function is
++ -- needed to share s-taprop.adb across POSIX-like targets.
++ pragma Import (C, lwp_self, "pthread_self");
++
++ -------------
++ -- Threads --
++ -------------
++
++ type Thread_Body is access
++ function (arg : System.Address) return System.Address;
++ pragma Convention (C, Thread_Body);
++
++ function Thread_Body_Access is new
++ Ada.Unchecked_Conversion (System.Address, Thread_Body);
++
++ type pthread_t is private;
++ subtype Thread_Id is pthread_t;
++
++ subtype pthread_mutex_t is System.OS_Locks.pthread_mutex_t;
++ type pthread_cond_t is limited private;
++ type pthread_attr_t is limited private;
++ type pthread_mutexattr_t is limited private;
++ type pthread_condattr_t is limited private;
++ type pthread_key_t is private;
++
++ PTHREAD_CREATE_DETACHED : constant := 1;
++ PTHREAD_CREATE_JOINABLE : constant := 0;
++
++ PTHREAD_SCOPE_PROCESS : constant := 0;
++ PTHREAD_SCOPE_SYSTEM : constant := 1;
++
++ subtype pthread_rwlock_t is pthread_mutex_t;
++ subtype pthread_rwlockattr_t is pthread_mutexattr_t;
++
++ -----------
++ -- Stack --
++ -----------
++
++ type stack_t is record
++ ss_sp : System.Address;
++ ss_size : size_t;
++ ss_flags : int;
++ end record;
++ pragma Convention (C, stack_t);
++
++ function sigaltstack
++ (ss : not null access stack_t;
++ oss : access stack_t) return int;
++ pragma Import (C, sigaltstack, "__gnat_sigaltstack");
++
++ Alternate_Stack : aliased System.Address;
++ -- This is a dummy definition, never used (Alternate_Stack_Size is null)
++
++ Alternate_Stack_Size : constant := 0;
++ -- No alternate signal stack is used on this platform
++
++ Stack_Base_Available : constant Boolean := False;
++ -- Indicates whether the stack base is available on this target. This
++ -- allows us to share s-osinte.adb between all the FSU run time. Note that
++ -- this value can only be true if pthread_t has a complete definition that
++ -- corresponds exactly to the C header files.
++
++ function Get_Stack_Base (thread : pthread_t) return Address;
++ pragma Inline (Get_Stack_Base);
++ -- returns the stack base of the specified thread. Only call this function
++ -- when Stack_Base_Available is True.
++
++ function Get_Page_Size return int;
++ pragma Import (C, Get_Page_Size, "_getpagesize");
++ -- Returns the size of a page
++
++ PROT_NONE : constant := 0;
++ PROT_READ : constant := 1;
++ PROT_WRITE : constant := 2;
++ PROT_EXEC : constant := 4;
++ PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
++ PROT_ON : constant := PROT_NONE;
++ PROT_OFF : constant := PROT_ALL;
++
++ function mprotect (addr : Address; len : size_t; prot : int) return int;
++ pragma Import (C, mprotect);
++
++ ---------------------------------------
++ -- Nonstandard Thread Initialization --
++ ---------------------------------------
++
++ -- FSU_THREADS requires pthread_init, which is nonstandard and this should
++ -- be invoked during the elaboration of s-taprop.adb.
++
++ -- NetBSD does not require this so we provide an empty Ada body
++
++ procedure pthread_init;
++
++ -------------------------
++ -- POSIX.1c Section 3 --
++ -------------------------
++
++ function sigwait
++ (set : access sigset_t;
++ sig : access Signal) return int;
++ pragma Import (C, sigwait, "sigwait");
++
++ function pthread_kill
++ (thread : pthread_t;
++ sig : Signal) return int;
++ pragma Import (C, pthread_kill, "pthread_kill");
++
++ function pthread_sigmask
++ (how : int;
++ set : access sigset_t;
++ oset : access sigset_t) return int;
++ pragma Import (C, pthread_sigmask, "pthread_sigmask");
++
++ --------------------------
++ -- POSIX.1c Section 11 --
++ --------------------------
++
++ function pthread_mutexattr_init
++ (attr : access pthread_mutexattr_t) return int;
++ pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
++
++ function pthread_mutexattr_destroy
++ (attr : access pthread_mutexattr_t) return int;
++ pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
++
++ function pthread_mutex_init
++ (mutex : access pthread_mutex_t;
++ attr : access pthread_mutexattr_t) return int;
++ pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
++
++ function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
++ pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
++
++ function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
++ pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
++
++ function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
++ pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
++
++ function pthread_condattr_init
++ (attr : access pthread_condattr_t) return int;
++ pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
++
++ function pthread_condattr_destroy
++ (attr : access pthread_condattr_t) return int;
++ pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
++
++ function pthread_cond_init
++ (cond : access pthread_cond_t;
++ attr : access pthread_condattr_t) return int;
++ pragma Import (C, pthread_cond_init, "pthread_cond_init");
++
++ function pthread_cond_destroy (cond : access pthread_cond_t) return int;
++ pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
++
++ function pthread_cond_signal (cond : access pthread_cond_t) return int;
++ pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
++
++ function pthread_cond_wait
++ (cond : access pthread_cond_t;
++ mutex : access pthread_mutex_t) return int;
++ pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
++
++ function pthread_cond_timedwait
++ (cond : access pthread_cond_t;
++ mutex : access pthread_mutex_t;
++ abstime : access timespec) return int;
++ pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
++
++ Relative_Timed_Wait : constant Boolean := False;
++ -- pthread_cond_timedwait requires an absolute delay time
++
++ --------------------------
++ -- POSIX.1c Section 13 --
++ --------------------------
++
++ PTHREAD_PRIO_NONE : constant := 0;
++ PTHREAD_PRIO_INHERIT : constant := 1;
++ PTHREAD_PRIO_PROTECT : constant := 2;
++
++ function pthread_mutexattr_setprotocol
++ (attr : access pthread_mutexattr_t;
++ protocol : int) return int;
++ pragma Import
++ (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
++
++ function pthread_mutexattr_getprotocol
++ (attr : access pthread_mutexattr_t;
++ protocol : access int) return int;
++ pragma Import
++ (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
++
++ function pthread_mutexattr_setprioceiling
++ (attr : access pthread_mutexattr_t;
++ prioceiling : int) return int;
++ pragma Import
++ (C, pthread_mutexattr_setprioceiling,
++ "pthread_mutexattr_setprioceiling");
++
++ function pthread_mutexattr_getprioceiling
++ (attr : access pthread_mutexattr_t;
++ prioceiling : access int) return int;
++ pragma Import
++ (C, pthread_mutexattr_getprioceiling,
++ "pthread_mutexattr_getprioceiling");
++
++ type struct_sched_param is record
++ sched_priority : int;
++ end record;
++ pragma Convention (C, struct_sched_param);
++
++ function pthread_getschedparam
++ (thread : pthread_t;
++ policy : access int;
++ param : access struct_sched_param) return int;
++ pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
++
++ function pthread_setschedparam
++ (thread : pthread_t;
++ policy : int;
++ param : access struct_sched_param) return int;
++ pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
++
++ function pthread_attr_setscope
++ (attr : access pthread_attr_t;
++ contentionscope : int) return int;
++ pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
++
++ function pthread_attr_getscope
++ (attr : access pthread_attr_t;
++ contentionscope : access int) return int;
++ pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
++
++ function pthread_attr_setinheritsched
++ (attr : access pthread_attr_t;
++ inheritsched : int) return int;
++ pragma Import
++ (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
++
++ function pthread_attr_getinheritsched
++ (attr : access pthread_attr_t;
++ inheritsched : access int) return int;
++ pragma Import
++ (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
++
++ function pthread_attr_setschedpolicy
++ (attr : access pthread_attr_t;
++ policy : int) return int;
++ pragma Import (C, pthread_attr_setschedpolicy,
++ "pthread_attr_setschedpolicy");
++
++ function pthread_attr_getschedpolicy
++ (attr : access pthread_attr_t;
++ policy : access int) return int;
++ pragma Import (C, pthread_attr_getschedpolicy,
++ "pthread_attr_getschedpolicy");
++
++ function pthread_attr_setschedparam
++ (attr : access pthread_attr_t;
++ sched_param : int) return int;
++ pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
++
++ function pthread_attr_getschedparam
++ (attr : access pthread_attr_t;
++ sched_param : access int) return int;
++ pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
++
++ function sched_yield return int;
++ pragma Import (C, sched_yield, "sched_yield");
++
++ --------------------------
++ -- P1003.1c Section 16 --
++ --------------------------
++
++ function pthread_attr_init (attributes : access pthread_attr_t) return int;
++ pragma Import (C, pthread_attr_init, "pthread_attr_init");
++
++ function pthread_attr_destroy
++ (attributes : access pthread_attr_t) return int;
++ pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
++
++ function pthread_attr_setdetachstate
++ (attr : access pthread_attr_t;
++ detachstate : int) return int;
++ pragma Import
++ (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
++
++ function pthread_attr_getdetachstate
++ (attr : access pthread_attr_t;
++ detachstate : access int) return int;
++ pragma Import
++ (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
++
++ function pthread_attr_getstacksize
++ (attr : access pthread_attr_t;
++ stacksize : access size_t) return int;
++ pragma Import
++ (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
++
++ function pthread_attr_setstacksize
++ (attr : access pthread_attr_t;
++ stacksize : size_t) return int;
++ pragma Import
++ (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
++
++ function pthread_create
++ (thread : access pthread_t;
++ attributes : access pthread_attr_t;
++ start_routine : Thread_Body;
++ arg : System.Address) return int;
++ pragma Import (C, pthread_create, "pthread_create");
++
++ function pthread_detach (thread : pthread_t) return int;
++ pragma Import (C, pthread_detach, "pthread_detach");
++
++ procedure pthread_exit (status : System.Address);
++ pragma Import (C, pthread_exit, "pthread_exit");
++
++ function pthread_self return pthread_t;
++ pragma Import (C, pthread_self, "pthread_self");
++
++ --------------------------
++ -- POSIX.1c Section 17 --
++ --------------------------
++
++ function pthread_setspecific
++ (key : pthread_key_t;
++ value : System.Address) return int;
++ pragma Import (C, pthread_setspecific, "pthread_setspecific");
++
++ function pthread_getspecific (key : pthread_key_t) return System.Address;
++ pragma Import (C, pthread_getspecific, "pthread_getspecific");
++
++ type destructor_pointer is access procedure (arg : System.Address);
++ pragma Convention (C, destructor_pointer);
++
++ function pthread_key_create
++ (key : access pthread_key_t;
++ destructor : destructor_pointer) return int;
++ pragma Import (C, pthread_key_create, "pthread_key_create");
++
++private
++
++ type sigset_t is array (1 .. 4) of unsigned;
++
++ -- In NetBSD the component sa_handler turns out to
++ -- be one a union type, and the selector is a macro:
++ -- #define sa_handler __sigaction_u._handler
++ -- #define sa_sigaction __sigaction_u._sigaction
++
++ -- Should we add a signal_context type here ???
++ -- How could it be done independent of the CPU architecture ???
++ -- sigcontext type is opaque, so it is architecturally neutral.
++ -- It is always passed as an access type, so define it as an empty record
++ -- since the contents are not used anywhere.
++
++ type struct_sigcontext is null record;
++ pragma Convention (C, struct_sigcontext);
++
++ type pid_t is new int;
++ Self_PID : constant pid_t := 0;
++
++ type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
++ .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
++
++ type timespec is record
++ ts_sec : time_t;
++ ts_nsec : long;
++ end record;
++ pragma Convention (C, timespec);
++
++ type pthread_t is new System.Address;
++ type pthread_attr_t is new System.Address;
++ type pthread_mutexattr_t is new System.Address;
++ type pthread_cond_t is new System.Address;
++ type pthread_condattr_t is new System.Address;
++ type pthread_key_t is new int;
++
++end System.OS_Interface;
diff --git a/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-taprop____posix.adb b/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-taprop____posix.adb
new file mode 100644
index 0000000000..04bb6ac292
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_libgnarl_s-taprop____posix.adb
@@ -0,0 +1,27 @@
+$NetBSD: patch-gcc_ada_libgnarl_s-taprop____posix.adb,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+When using SCHED_OTHER, the minimum and maximum in NetBSD is -1.
+In most other OSs it is 0. Change the behaviour to try to set the
+params using the default priority, if that fails, use 0, otherwise
+use -1. If none are valid, the tasking system will fail if assertions
+are on.
+
+--- gcc/ada/libgnarl/s-taprop__posix.adb.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/libgnarl/s-taprop__posix.adb
+@@ -616,6 +616,16 @@
+ else
+ Result := pthread_setschedparam
+ (T.Common.LL.Thread, SCHED_OTHER, Param'Access);
++ if Result /= 0 then
++ Param.sched_priority := 0;
++ Result := pthread_setschedparam
++ (T.Common.LL.Thread, SCHED_OTHER, Param'Access);
++ if Result /= 0 then
++ Param.sched_priority := -1;
++ Result := pthread_setschedparam
++ (T.Common.LL.Thread, SCHED_OTHER, Param'Access);
++ end if;
++ end if;
+ end if;
+
+ pragma Assert (Result = 0);
diff --git a/gcc15-gnat/patches/patch-gcc_ada_s-oscons-tmplt.c b/gcc15-gnat/patches/patch-gcc_ada_s-oscons-tmplt.c
new file mode 100644
index 0000000000..3a7cc4c178
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_s-oscons-tmplt.c
@@ -0,0 +1,94 @@
+$NetBSD: patch-gcc_ada_s-oscons-tmplt.c,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add NetBSD to some defined parts and bump the version of
+_XOPEN_SOURCE and add _NETBSD_SOURCE.
+
+--- gcc/ada/s-oscons-tmplt.c.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/s-oscons-tmplt.c
+@@ -86,7 +86,8 @@
+ ** a number of non-POSIX but useful/required features.
+ **/
+
+-#if defined (__linux__) || defined (__ANDROID__) || defined (__GNU__)
++#if defined (__linux__) || defined (__ANDROID__) || defined (__GNU__) \
++ || defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__)
+
+ /* Define _XOPEN_SOURCE to get IOV_MAX */
+ # if !defined (_XOPEN_SOURCE)
+@@ -96,6 +97,18 @@
+ /* Define _BSD_SOURCE to get CRTSCTS */
+ # define _BSD_SOURCE
+
++#elif defined (__NetBSD__)
++
++# if !defined (_XOPEN_SOURCE)
++/* We use 520 since NetBSD does not include getaddrinfo flags with only 500 */
++# define _XOPEN_SOURCE 520
++# endif
++
++# define _BSD_SOURCE
++/* NetBSD requires _NETBSD_SOURCE to be defined in order to include */
++/* NI_MAX{HOST,SERV} correctly */
++# define _NETBSD_SOURCE
++
+ #endif /* defined (__linux__) || defined (__ANDROID__) || defined (__GNU__) */
+
+ /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
+@@ -160,7 +173,9 @@
+ #endif
+
+ #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__) \
+- || defined (__rtems__) || defined (__GNU__)
++ || defined (__rtems__) || defined (__GNU__) \
++ || defined (__FreeBSD__) || defined (__DragonFly__) || defined (__NetBSD__) \
++ || defined (__OpenBSD__)
+ # include <pthread.h>
+ # include <signal.h>
+ #endif
+@@ -405,11 +420,14 @@
+
+ */
+
+-/* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
++/* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD
++ and NetBSD
++*/
+
+-#if defined (__FreeBSD__) || defined (__DragonFly__)
++#if defined (__FreeBSD__) || defined (__DragonFly__) || defined (__NetBSD__) \
++ || defined (__OpenBSD__)
+ # define CNI CNU
+-# define IOCTL_Req_T "Interfaces.C.unsigned"
++# define IOCTL_Req_T "Interfaces.C.unsigned_long"
+ #else
+ # define CNI CND
+ # define IOCTL_Req_T "Interfaces.C.int"
+@@ -1054,7 +1072,8 @@
+
+ */
+
+-#if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
++#if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__) \
++ || defined (__NetBSD__) || defined (__OpenBSD__)
+ # define PTY_Library "-lutil"
+ #else
+ # define PTY_Library ""
+@@ -1976,6 +1995,7 @@
+ #if defined(__linux__) || defined(__FreeBSD__) \
+ || (defined(_AIX) && defined(_AIXVERSION_530)) \
+ || defined(__DragonFly__) || defined(__QNX__) \
++ || defined(__NetBSD__) || defined(__OpenBSD__) \
+ || defined (__vxworks)
+ /** On these platforms use system provided monotonic clock instead of
+ ** the default CLOCK_REALTIME. We then need to set up cond var attributes
+@@ -1999,8 +2019,8 @@
+
+ #if defined (__APPLE__) || defined (__ANDROID__) || defined (DUMMY) \
+ || defined (__FreeBSD__) || defined (__linux__) \
+- || defined (__QNX__) || defined (__rtems__) || defined (__GNU__)
+-
++ || defined (__QNX__) || defined (__rtems__) || defined (__GNU__) \
++ || defined (__NetBSD__) || defined (__OpenBSD__)
+ /*
+
+ -- Sizes of pthread data types
diff --git a/gcc15-gnat/patches/patch-gcc_ada_sysdep.c b/gcc15-gnat/patches/patch-gcc_ada_sysdep.c
new file mode 100644
index 0000000000..43ee873c51
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_sysdep.c
@@ -0,0 +1,42 @@
+$NetBSD: patch-gcc_ada_sysdep.c,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add NetBSD to some defined sections
+
+--- gcc/ada/sysdep.c.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/sysdep.c
+@@ -338,7 +338,7 @@
+ || (defined (__svr4__) && defined (__i386__)) || defined (__Lynx__) \
+ || defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
+ || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__) \
+- || defined (__QNX__)
++ || defined (__QNX__) || defined (__NetBSD__)
+
+ # ifdef __MINGW32__
+ # include <conio.h> /* for getch(), kbhit() */
+@@ -387,7 +387,7 @@
+ || defined (_AIX) || (defined (__svr4__) && defined (__i386__)) \
+ || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
+ || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__) \
+- || defined (__QNX__)
++ || defined (__QNX__) || defined (__NetBSD__)
+ char c;
+ int nread;
+ int good_one = 0;
+@@ -408,7 +408,7 @@
+ || defined (_AIX) || (defined (__svr4__) && defined (__i386__)) \
+ || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
+ || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__) \
+- || defined (__QNX__)
++ || defined (__QNX__) || defined (__NetBSD__)
+ eof_ch = termios_rec.c_cc[VEOF];
+
+ /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for
+@@ -847,7 +847,7 @@
+
+ #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (__linux__) \
+ || defined (__GLIBC__) || defined (__DragonFly__) || defined (__OpenBSD__) \
+- || defined (__DJGPP__) || defined (__QNX__)
++ || defined (__DJGPP__) || defined (__QNX__) || defined (__NetBSD__)
+ {
+ localtime_r (&time, &tp);
+ *off = tp.tm_gmtoff;
diff --git a/gcc15-gnat/patches/patch-gcc_ada_terminals.c b/gcc15-gnat/patches/patch-gcc_ada_terminals.c
new file mode 100644
index 0000000000..4a13134644
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_terminals.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_ada_terminals.c,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+openpty defined in <util.h> on NetBSD
+
+--- gcc/ada/terminals.c.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/terminals.c
+@@ -1122,7 +1122,7 @@
+ #if defined (__hpux__)
+ # include <sys/stropts.h>
+ #endif
+-#if defined (__APPLE__)
++#if defined (__APPLE__) || defined (__NetBSD__)
+ # include <util.h>
+ #endif
+ #if defined (__FreeBSD__)
diff --git a/gcc15-gnat/patches/patch-gcc_ada_tracebak.c b/gcc15-gnat/patches/patch-gcc_ada_tracebak.c
new file mode 100644
index 0000000000..ce49e526cf
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_ada_tracebak.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_ada_tracebak.c,v 1.1 2025/04/28 22:00:00 dkazankov Exp $
+
+Add NetBSD to some defines
+
+--- gcc/ada/tracebak.c.orig 2025-04-25 08:18:00.000000000 +0000
++++ gcc/ada/tracebak.c
+@@ -567,7 +567,7 @@
+ /*------------------- aarch64 FreeBSD, Linux, RTEMS -----------------*/
+
+ #elif (defined (__aarch64__) && (defined (__FreeBSD__) || \
+- defined (__linux__) || defined (__rtems__)))
++ defined (__linux__) || defined (__rtems__) || defined (__NetBSD__)))
+
+ #define USE_GCC_UNWINDER
+ #define PC_ADJUST -4
diff --git a/gcc15-gnat/patches/patch-gcc_config.host b/gcc15-gnat/patches/patch-gcc_config.host
new file mode 100644
index 0000000000..82c5c1064e
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_config.host
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_config.host,v 1.1 2025/04/25 19:35:10 dkazankov 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/gcc15-gnat/patches/patch-gcc_configure b/gcc15-gnat/patches/patch-gcc_configure
new file mode 100644
index 0000000000..ffbb651d97
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_configure
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_configure,v 1.2 2025/04/29 22:00:00 dkazankov Exp $
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90143
+
+--- gcc/configure.orig 2025-04-25 08:21:27.000000000 +0000
++++ gcc/configure 2025-04-29 19:09:34.273376432 +0000
+@@ -33638,7 +33638,7 @@
+ *-*-solaris2*)
+ gcc_cv_target_dl_iterate_phdr=yes
+ ;;
+- *-*-dragonfly* | *-*-freebsd*)
++ *-*-dragonfly* | *-*-freebsd* | *-*-netbsd*)
+ if grep dl_iterate_phdr $target_header_dir/sys/link_elf.h > /dev/null 2>&1; then
+ gcc_cv_target_dl_iterate_phdr=yes
+ else
diff --git a/gcc15-gnat/patches/patch-gcc_tree.h b/gcc15-gnat/patches/patch-gcc_tree.h
new file mode 100644
index 0000000000..2717f7474b
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gcc_tree.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_tree.h,v 1.1 2025/04/25 19:35:10 dkazankov Exp $
+
+LTO compilation error
+
+--- gcc/tree.h.orig 2025-04-25 08:18:04.000000000 +0000
++++ gcc/tree.h
+@@ -1355,7 +1355,7 @@
+
+ extern void protected_set_expr_location (tree, location_t);
+ extern void protected_set_expr_location_if_unset (tree, location_t);
+-ATTRIBUTE_WARN_UNUSED_RESULT
++WARN_UNUSED_RESULT
+ extern tree protected_set_expr_location_unshare (tree, location_t);
+
+ WARN_UNUSED_RESULT extern tree maybe_wrap_with_location (tree, location_t);
diff --git a/gcc15-gnat/patches/patch-gnattools_configure b/gcc15-gnat/patches/patch-gnattools_configure
new file mode 100644
index 0000000000..2c49dad1b6
--- /dev/null
+++ b/gcc15-gnat/patches/patch-gnattools_configure
@@ -0,0 +1,16 @@
+$NetBSD: patch-gnattools_configure,v 1.1 2025/04/25 19:35:10 dkazankov Exp $
+
+Include NetBSD in the gnat tools configure.
+
+--- gnattools/configure.orig 2025-04-25 08:18:04.000000000 +0000
++++ gnattools/configure
+@@ -2075,6 +2075,9 @@
+ *-*-freebsd*)
+ TOOLS_TARGET_PAIRS="indepsw.adb<indepsw-gnu.adb"
+ ;;
++ *-*-netbsd*)
++ TOOLS_TARGET_PAIRS="indepsw.adb<indepsw-gnu.adb"
++ ;;
+ *-*-linux*)
+ TOOLS_TARGET_PAIRS="indepsw.adb<indepsw-gnu.adb"
+ ;;
diff --git a/gcc15-gnat/patches/patch-libcody_configure b/gcc15-gnat/patches/patch-libcody_configure
new file mode 100644
index 0000000000..dbfc271897
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libcody_configure
@@ -0,0 +1,33 @@
+$NetBSD: patch-libcody_configure,v 1.1 2025/04/25 19:35:10 dkazankov Exp $
+
+Fix c++ version test
+
+--- libcody/configure.orig 2024-05-07 09:51:41.000000000 +0300
++++ libcody/configure 2024-07-29 18:21:31.801520751 +0300
+@@ -2501,7 +2501,7 @@
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+-#if __cplusplus != 201103
++#if __cplusplus < 201103L
+ #error "C++11 is required"
+ #endif
+
+@@ -2522,7 +2522,7 @@
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+-#if __cplusplus != 201103
++#if __cplusplus < 201103L
+ #error "C++11 is required"
+ #endif
+
+@@ -2542,7 +2542,7 @@
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+-#if __cplusplus > 201103
++#if __cplusplus < 201103L
+ #error "C++11 is required"
+ #endif
+
diff --git a/gcc15-gnat/patches/patch-libffi_configure b/gcc15-gnat/patches/patch-libffi_configure
new file mode 100644
index 0000000000..9fca638bef
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libffi_configure
@@ -0,0 +1,16 @@
+$NetBSD: patch-libffi_configure,v 1.1 2025/04/25 19:35:10 dkazankov Exp $
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90146
+https://github.com/libffi/libffi/issues/485
+
+--- libffi/configure.orig 2024-05-07 09:52:51.000000000 +0300
++++ libffi/configure
+@@ -16351,7 +16351,7 @@
+ $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/gcc15-gnat/patches/patch-libffi_testsuite_libffi.call_float2.c b/gcc15-gnat/patches/patch-libffi_testsuite_libffi.call_float2.c
new file mode 100644
index 0000000000..b83934e082
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libffi_testsuite_libffi.call_float2.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-libffi_testsuite_libffi.call_float2.c,v 1.1 2025/04/25 19:35:10 dkazankov 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/gcc15-gnat/patches/patch-libgcc_crtstuff.c b/gcc15-gnat/patches/patch-libgcc_crtstuff.c
new file mode 100644
index 0000000000..1c79044e36
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libgcc_crtstuff.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-libgcc_crtstuff.c,v 1.1 2025/04/29 06:00:00 dkazankov 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 @@
+ #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/gcc15-gnat/patches/patch-libgomp_configure.tgt b/gcc15-gnat/patches/patch-libgomp_configure.tgt
new file mode 100644
index 0000000000..ca59cccd7c
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libgomp_configure.tgt
@@ -0,0 +1,18 @@
+$NetBSD: patch-libgomp_configure.tgt,v 1.1 2025/04/29 06:00:00 dkazankov Exp $
+
+Add NetBSD target
+
+--- libgomp/configure.tgt.orig 2025-04-25 11:18:04.000000000 +0300
++++ libgomp/configure.tgt
+@@ -158,6 +158,11 @@
+ XLDFLAGS="${XLDFLAGS} -lpthread"
+ ;;
+
++ *-*-netbsd*)
++ # Need to link with -lpthread so libgomp.so is self-contained.
++ XLDFLAGS="${XLDFLAGS} -lpthread"
++ ;;
++
+ *-*-aix*)
+ config_path="posix"
+ # Need to link with -lpthread so libgomp.so is self-contained.
diff --git a/gcc15-gnat/patches/patch-libquadmath_printf_quadmath-printf.c b/gcc15-gnat/patches/patch-libquadmath_printf_quadmath-printf.c
new file mode 100644
index 0000000000..d7edf0cc75
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libquadmath_printf_quadmath-printf.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-libquadmath_printf_quadmath-printf.c,v 1.1 2025/04/25 19:35:10 dkazankov 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/gcc15-gnat/patches/patch-libquadmath_strtod_strtod__l.c b/gcc15-gnat/patches/patch-libquadmath_strtod_strtod__l.c
new file mode 100644
index 0000000000..3e92cd8873
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libquadmath_strtod_strtod__l.c
@@ -0,0 +1,23 @@
+$NetBSD: patch-libquadmath_strtod_strtod__l.c,v 1.1 2025/04/25 19:35:10 dkazankov 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/gcc15-gnat/patches/patch-libstdc++-v3_libsupc++_new__opa.cc b/gcc15-gnat/patches/patch-libstdc++-v3_libsupc++_new__opa.cc
new file mode 100644
index 0000000000..cfa49aa1b5
--- /dev/null
+++ b/gcc15-gnat/patches/patch-libstdc++-v3_libsupc++_new__opa.cc
@@ -0,0 +1,17 @@
+$NetBSD: patch-libstdc++-v3_libsupc++_new__opa.cc,v 1.1 2025/04/25 19:35:10 dkazankov Exp $
+
+Ensure we can find SunOS std::aligned_alloc if using it.
+
+--- libstdc++-v3/libsupc++/new_opa.cc.orig 2024-05-21 10:47:42.000000000 +0300
++++ libstdc++-v3/libsupc++/new_opa.cc
+@@ -62,6 +62,10 @@
+ }
+ #endif
+
++#if defined(__sun) && _GLIBCXX_HAVE_ALIGNED_ALLOC
++using std::aligned_alloc;
++#endif
++
+ namespace __gnu_cxx {
+ // Prefer posix_memalign if available, because it's older than aligned_alloc
+ // and so more likely to be provided by replacement malloc libraries that
Home |
Main Index |
Thread Index |
Old Index