tech-pkg archive

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

Re: A better method to require compiler features



> I am guessing you will prepare a patch for review and people can think
> about something actual; it seems like abstract discussion has been about
> as useful as it can be.
> 
> Others haven't spoken up much; I think where we are satisfies most
> concerns raised earlier, but @all please speak up if not.

Attached.
Index: bsd.prefs.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.prefs.mk,v
retrieving revision 1.434
diff -u -p -u -r1.434 bsd.prefs.mk
--- bsd.prefs.mk	27 Jun 2023 10:36:40 -0000	1.434
+++ bsd.prefs.mk	13 Jul 2023 21:37:55 -0000
@@ -968,5 +968,13 @@ _LITTLEENDIANCPUS+=	${_ARMCPUS}
 BIGENDIANPLATFORMS=	${_BIGENDIANCPUS:S/^/*-*-/}
 LITTLEENDIANPLATFORMS=	${_LITTLEENDIANCPUS:S/^/*-*-/}
 
+#
+# Allow installing a newer C/C++ compiler to build a package
+# than what the system provides.
+#
+# Impact: allowing this can sometimes result in mismatches
+# with libstdc++ versions.
+#
+ALLOW_NEWER_COMPILER?=	yes
 
 .endif	# BSD_PKG_MK
Index: compiler/gcc.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/compiler/gcc.mk,v
retrieving revision 1.253
diff -u -p -u -r1.253 gcc.mk
--- compiler/gcc.mk	27 Jun 2023 10:27:21 -0000	1.253
+++ compiler/gcc.mk	13 Jul 2023 21:37:55 -0000
@@ -150,6 +150,82 @@ GCC_REQD+=	2.8.0
 .  endif
 .endif
 
+#
+# USE_CXX_FEATURES (or USE_CC_FEATURES) allows smarter decisions about
+# when the stock compiler provided by a system is unsuitable for building
+# a package.
+#
+# Most of the time, GCC adds support for features of new C and C++
+# standards incrementally, so USE_CXX_FEATURES=	c++XX is for
+# establishing an idealistic baseline, usually based on compiler
+# versions shipped with NetBSD.
+#
+# Resources:
+# https://gcc.gnu.org/projects/cxx-status.html
+# https://gcc.gnu.org/wiki/C11Status
+# https://gcc.gnu.org/c99status.html
+#
+
+.if !empty(USE_CXX_FEATURES:Mc++20)
+# GCC 10 is chosen because it is planned to be shipped with NetBSD 10,
+# so is fairly battle-hardened with pkgsrc.
+#
+# We hope that it remains OK for most C++20 in the future...
+GCC_REQD+=	10
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mc++17)
+# GCC 7 is chosen because it shipped with NetBSD 9, so is fairly
+# battle-hardened with pkgsrc.
+GCC_REQD+=	7
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mc++14)
+# GCC 5 is chosen because it shipped with NetBSD 8, so is fairly
+# battle-hardened with pkgsrc.
+GCC_REQD+=	5
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mc++11)
+# While gcc "technically" added experimental C++11 support earlier
+# (and there was previously a lot of cargo-culted GCC_REQD in pkgsrc
+# as a result), earlier compiler versions are not so well-tested any more.
+#
+# GCC 4.8 was the version shipped with NetBSD 7 and CentOS 7, so is fairly
+# battle-hardened with pkgsrc.
+#
+# Versions before GCC 4.7 do not accept -std=c++11.
+GCC_REQD+=	4.8
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mhas_include) || \
+    !empty(USE_CC_FEATURES:Mhas_include)
+GCC_REQD+=	5
+.endif
+
+.if !empty(USE_CC_FEATURES:Mc99)
+GCC_REQD+=	3
+.endif
+
+.if !empty(USE_CC_FEATURES:Mc11)
+GCC_REQD+=	4.9
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mregex)
+GCC_REQD+=	4.9
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mfilesystem)
+# std::filesystem was "experimental" in gcc7 and NetBSD 9 shipped
+# GCC without the experimental C++ library headers (a break from
+# upstream).
+.  if ${OPSYS} == "NetBSD"
+GCC_REQD+=	8
+.  else
+GCC_REQD+=	7
+.  endif
+.endif
+
 # Only one compiler defined here supports Ada: lang/gcc6-aux
 # If the Ada language is requested, force lang/gcc6-aux to be selected
 .if !empty(USE_LANGUAGES:Mada)
@@ -304,6 +380,9 @@ _NEED_GCC6?=	no
 #USE_PKGSRC_GCC_RUNTIME=	yes
 #.    endif
 _NEED_GCC6=	yes
+.    if ${ALLOW_NEWER_COMPILER:tl} != "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 6 to build"
+.    endif
 .  endif
 .endfor
 _NEED_GCC7?=	no
@@ -313,6 +392,9 @@ _NEED_GCC7?=	no
 USE_PKGSRC_GCC=		yes
 USE_PKGSRC_GCC_RUNTIME=	yes
 .    endif
+.    if ${ALLOW_NEWER_COMPILER:tl} != "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 7 to build"
+.    endif
 _NEED_GCC7=	yes
 .  endif
 .endfor
@@ -323,6 +405,9 @@ _NEED_GCC8?=	no
 USE_PKGSRC_GCC=		yes
 USE_PKGSRC_GCC_RUNTIME=	yes
 .    endif
+.    if ${ALLOW_NEWER_COMPILER:tl} != "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 8 to build"
+.    endif
 _NEED_GCC8=	yes
 .  endif
 .endfor
@@ -333,6 +418,9 @@ _NEED_GCC9?=	no
 USE_PKGSRC_GCC=		yes
 USE_PKGSRC_GCC_RUNTIME=	yes
 .    endif
+.    if ${ALLOW_NEWER_COMPILER:tl} == "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 9 to build"
+.    endif
 _NEED_GCC9=	yes
 .  endif
 .endfor
@@ -343,18 +431,27 @@ _NEED_GCC10?=	no
 USE_PKGSRC_GCC=		yes
 USE_PKGSRC_GCC_RUNTIME=	yes
 .    endif
+.    if ${ALLOW_NEWER_COMPILER:tl} == "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 10 to build"
+.    endif
 _NEED_GCC10=	yes
 .  endif
 .endfor
 _NEED_GCC12?=	no
 .for _pattern_ in ${_GCC12_PATTERNS}
 .  if !empty(_GCC_REQD:M${_pattern_})
+.    if ${ALLOW_NEWER_COMPILER:tl} == "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 12 to build"
+.    endif
 _NEED_GCC12=	yes
 .  endif
 .endfor
 _NEED_GCC13?=	no
 .for _pattern_ in ${_GCC13_PATTERNS}
 .  if !empty(_GCC_REQD:M${_pattern_})
+.    if ${ALLOW_NEWER_COMPILER:tl} == "yes"
+PKG_FAIL_REASON+=	"Package requires at least gcc 13 to build"
+.    endif
 _NEED_GCC13=	yes
 .  endif
 .endfor


Home | Main Index | Thread Index | Old Index