pkgsrc-Changes archive

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

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   nia
Date:           Tue Jul 18 12:49:46 UTC 2023

Modified Files:
        pkgsrc/doc: NEWS
        pkgsrc/doc/guide/files: fixes.xml
        pkgsrc/mk: bsd.prefs.mk compiler.mk
        pkgsrc/mk/compiler: gcc.mk

Log Message:
mk: Add support for USE_CC_FEATURES and USE_CXX_FEATURES to the pkgsrc
infrastructure, as discussed on tech-pkg@.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 pkgsrc/doc/NEWS
cvs rdiff -u -r1.185 -r1.186 pkgsrc/doc/guide/files/fixes.xml
cvs rdiff -u -r1.434 -r1.435 pkgsrc/mk/bsd.prefs.mk
cvs rdiff -u -r1.99 -r1.100 pkgsrc/mk/compiler.mk
cvs rdiff -u -r1.253 -r1.254 pkgsrc/mk/compiler/gcc.mk

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

Modified files:

Index: pkgsrc/doc/NEWS
diff -u pkgsrc/doc/NEWS:1.27 pkgsrc/doc/NEWS:1.28
--- pkgsrc/doc/NEWS:1.27        Thu Jun 30 13:08:25 2022
+++ pkgsrc/doc/NEWS     Tue Jul 18 12:49:46 2023
@@ -1,4 +1,4 @@
-# $NetBSD: NEWS,v 1.27 2022/06/30 13:08:25 nia Exp $
+# $NetBSD: NEWS,v 1.28 2023/07/18 12:49:46 nia Exp $
 
 PKGSRC NEWS
 ===========
@@ -7,6 +7,16 @@ PKGSRC NEWS
   pkgsrc. The intended readers are the pkgsrc developers as well as anyone
   tracking pkgsrc-current.
 
+Support for USE_CC_FEATURES and USE_CXX_FEAUTRES [nia 2023-07-18]
+
+       USE_CC_FEATURES and USE_CXX_FEATURES can now be used
+       to specify a minimum level of C and C++ support required
+       to compile a package, including specific libstdc++ features.
+
+       ALLOW_NEWER_COMPILER can be set to no in mk.conf to skip
+       building packages that require a newer compiler than the system
+       provides.
+
 Default versions bumped [nia 2022-06-30]
 
        PYTHON_VERSION_DEFAULT is now 310.

Index: pkgsrc/doc/guide/files/fixes.xml
diff -u pkgsrc/doc/guide/files/fixes.xml:1.185 pkgsrc/doc/guide/files/fixes.xml:1.186
--- pkgsrc/doc/guide/files/fixes.xml:1.185      Thu Jul 13 13:14:41 2023
+++ pkgsrc/doc/guide/files/fixes.xml    Tue Jul 18 12:49:46 2023
@@ -1,4 +1,4 @@
-<!-- $NetBSD: fixes.xml,v 1.185 2023/07/13 13:14:41 nia Exp $ -->
+<!-- $NetBSD: fixes.xml,v 1.186 2023/07/18 12:49:46 nia Exp $ -->
 
 <chapter id="fixes"> <?dbhtml filename="fixes.html"?>
 <title>Making your package work</title>
@@ -1428,7 +1428,8 @@ MESON_ARGS+=      -Dx11=false
     is written in C and will hide all other compilers (via the wrapper
     framework, see <xref linkend="buildlink" />).</para>
 
-    <para>To declare which language's compiler a package needs, set
+    <para>To declare which languages should be made available through
+    pkgsrc's compiler wrappers, use 
     the <varname>USE_LANGUAGES</varname> variable. Allowed values
     currently are:
 <programlisting>
@@ -1439,7 +1440,28 @@ fortran77, java, objc, obj-c++, and ada.
     (and any combination).  The default is
     <quote>c</quote>.  Packages using GNU configure scripts, even if
     written in C++, usually need a C compiler for the configure
-    phase.</para>
+    phase.
+    Language variants like <literal>c++11</literal>
+    can be specified if the package does not explicitly set
+    <literal>-std=...</literal> when compiling (i.e. the package
+    assumes the compiler defaults to C++11 or some other standard).
+    This is a common bug in upstream build systems.</para>
+
+    <para>To declare which features a package requies from the
+    compiler, set either <varname>USE_CC_FEATURES</varname>
+    or <varname>USE_CXX_FEATURES</varname>. Allowed values for
+    <varname>USE_CC_FEATURES</varname> are currently:
+<programlisting>
+c11, c99, has_include
+</programlisting>
+    Allowed values for <varname>USE_CXX_FEATURES</varname> are
+    currently:
+<programlisting>
+c++11, c++14, c++17, c++20, has_include, regex, filesystem,
+charconv, parallelism_ts, unique_ptr
+</programlisting>
+    .</para>
+    </para>
   </sect2>
 
   <sect2 id="java-programming-language">

Index: pkgsrc/mk/bsd.prefs.mk
diff -u pkgsrc/mk/bsd.prefs.mk:1.434 pkgsrc/mk/bsd.prefs.mk:1.435
--- pkgsrc/mk/bsd.prefs.mk:1.434        Tue Jun 27 10:36:40 2023
+++ pkgsrc/mk/bsd.prefs.mk      Tue Jul 18 12:49:46 2023
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.434 2023/06/27 10:36:40 riastradh Exp $
+# $NetBSD: bsd.prefs.mk,v 1.435 2023/07/18 12:49:46 nia Exp $
 #
 # This file includes the mk.conf file, which contains the user settings.
 #
@@ -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: pkgsrc/mk/compiler.mk
diff -u pkgsrc/mk/compiler.mk:1.99 pkgsrc/mk/compiler.mk:1.100
--- pkgsrc/mk/compiler.mk:1.99  Wed Nov 23 13:30:38 2022
+++ pkgsrc/mk/compiler.mk       Tue Jul 18 12:49:46 2023
@@ -1,4 +1,4 @@
-# $NetBSD: compiler.mk,v 1.99 2022/11/23 13:30:38 jperkin Exp $
+# $NetBSD: compiler.mk,v 1.100 2023/07/18 12:49:46 nia Exp $
 #
 # This Makefile fragment implements handling for supported C/C++/Fortran
 # compilers.
@@ -41,20 +41,47 @@
 #      If set to yes, fail early if the compiler.mk variables are not
 #      set correctly.
 #
+# ALLOW_NEWER_COMPILER
+#      If set to no, fail early if a package requires newer compiler
+#      features than supported by the system's compiler. If set to
+#      yes (the default), pkgsrc may attempt to build a newer compiler
+#      to use instead.
+#
 # The following variables may be set by a package:
 #
 # USE_LANGUAGES
-#      Declares the languages used in the source code of the package.
-#      This is used to determine the correct compilers to make
-#      visible to the build environment, installing them if
-#      necessary.  Flags such as -std=c++99 are also added.
+#      Declares the languages that should be made available via
+#      pkgsrc's compiler wrappers.
+#
+#      If the package assumes the compiler defaults to a specific
+#      language version, the USE_LANGUAGES variable can also be used
+#      to force the inclusion of flags such as -std=c++11. In this case,
+#      USE_CC_FEATURES/USE_CXX_FEATURES should also be set.
+#
 #      Valid values are: c, c99, gnu99, c11, gnu11, c17, gnu17, c++, c++03,
 #      gnu++03, c++0x, gnu++0x, c++11, gnu++11, c++14, gnu++14, c++17,
 #      gnu++17, c++20, gnu++20, fortran, fortran77, java, objc, obj-c++, ada.
+#
 #      The default is "c".
 #
-#       The above is partly aspirational.  As an example c++11 does
-#       not force a new enough version of gcc.
+# USE_CC_FEATURES
+#
+#      Declares the C compiler features required by the package.
+#
+#      This is used to (optionally) install a newer compiler
+#      than provided by the system, or to skip building the package.
+#
+#      Valid values are: c11, c99, has_include.
+#
+# USE_CXX_FEATURES
+#
+#      Declares the C++ compiler features required by the package.
+#
+#      This is used to (optionally) install a newer compiler
+#      than provided by the system, to or skip building the package.
+#
+#      Valid values are: c++11, c++14, c++17, c++20, has_include,
+#      regex, filesystem, unique_ptr, charconv, parallelism_ts.
 #
 # The following variables are defined, and available for testing in
 # package Makefiles:

Index: pkgsrc/mk/compiler/gcc.mk
diff -u pkgsrc/mk/compiler/gcc.mk:1.253 pkgsrc/mk/compiler/gcc.mk:1.254
--- pkgsrc/mk/compiler/gcc.mk:1.253     Tue Jun 27 10:27:21 2023
+++ pkgsrc/mk/compiler/gcc.mk   Tue Jul 18 12:49:46 2023
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.253 2023/06/27 10:27:21 riastradh Exp $
+# $NetBSD: gcc.mk,v 1.254 2023/07/18 12:49:46 nia Exp $
 #
 # This is the compiler definition for the GNU Compiler Collection.
 #
@@ -150,6 +150,90 @@ GCC_REQD+= 2.8.0
 .  endif
 .endif
 
+#
+# 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:Munique_ptr)
+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
+
+.if !empty(USE_CXX_FEATURES:Mparallelism_ts)
+GCC_REQD+=     10
+.endif
+
+.if !empty(USE_CXX_FEATURES:Mcharconv)
+GCC_REQD+=     8
+.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 +388,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 +400,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 +413,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 +426,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 +439,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