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:           Wed Aug  2 15:59:58 UTC 2023

Modified Files:
        pkgsrc/doc/guide/files: fixes.xml
        pkgsrc/mk: compiler.mk
        pkgsrc/mk/compiler: gcc-style-args.mk

Log Message:
mk: Add support for FORCE_C_STD and FORCE_CXX_STD as discussed on tech-pkg.k


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 pkgsrc/doc/guide/files/fixes.xml
cvs rdiff -u -r1.106 -r1.107 pkgsrc/mk/compiler.mk
cvs rdiff -u -r1.2 -r1.3 pkgsrc/mk/compiler/gcc-style-args.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/guide/files/fixes.xml
diff -u pkgsrc/doc/guide/files/fixes.xml:1.190 pkgsrc/doc/guide/files/fixes.xml:1.191
--- pkgsrc/doc/guide/files/fixes.xml:1.190      Wed Jul 26 22:41:02 2023
+++ pkgsrc/doc/guide/files/fixes.xml    Wed Aug  2 15:59:57 2023
@@ -1,4 +1,4 @@
-<!-- $NetBSD: fixes.xml,v 1.190 2023/07/26 22:41:02 gutteridge Exp $ -->
+<!-- $NetBSD: fixes.xml,v 1.191 2023/08/02 15:59:57 nia Exp $ -->
 
 <chapter id="fixes"> <?dbhtml filename="fixes.html"?>
 <title>Making your package work</title>
@@ -1433,19 +1433,12 @@ MESON_ARGS+=    -Dx11=false
     the <varname>USE_LANGUAGES</varname> variable. Allowed values
     currently are:
 <programlisting>
-c99, 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++, and ada.
+c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
 </programlisting>
     (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.
-    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>
@@ -1462,6 +1455,28 @@ charconv, parallelism_ts, unique_ptr, pu
 is_trivially_copy_constructible
 </programlisting>
     </para>
+
+    <para>Language variants like <literal>gnu99</literal> and
+    <literal>c++11</literal> can be specified in <varname>FORCE_C_STD</varname>
+    and <varname>FORCE_CXX_STD</varname> 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>Allowed values for <varname>FORCE_C_STD</varname> are
+    currently:
+<programlisting>
+c90, c99, c11, gnu90, gnu99, gnu11
+</programlisting></para>
+    </para>
+
+    <para>Allowed values for <varname>USE_CXX_FEATURES</varname> are
+    currently:
+<programlisting>
+c++03, c++11, c++14, c++17, c++20,
+gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
+</programlisting></para>
+    </para>
   </sect2>
 
   <sect2 id="java-programming-language">

Index: pkgsrc/mk/compiler.mk
diff -u pkgsrc/mk/compiler.mk:1.106 pkgsrc/mk/compiler.mk:1.107
--- pkgsrc/mk/compiler.mk:1.106 Sun Jul 30 21:47:44 2023
+++ pkgsrc/mk/compiler.mk       Wed Aug  2 15:59:58 2023
@@ -1,4 +1,4 @@
-# $NetBSD: compiler.mk,v 1.106 2023/07/30 21:47:44 ryoon Exp $
+# $NetBSD: compiler.mk,v 1.107 2023/08/02 15:59:58 nia Exp $
 #
 # This Makefile fragment implements handling for supported C/C++/Fortran
 # compilers.
@@ -84,6 +84,29 @@
 #      regex, filesystem, unique_ptr, charconv, parallelism_ts,
 #      put_time, is_trivially_copy_constructible.
 #
+# FORCE_C_STD
+#
+#      Overrides the compiler's default C dialect to ensure that a
+#      specific language variant is used.  This is useful if a package
+#      uses features from a later or earlier C standard but doesn't set
+#      -std=cXX, since the default dialect choice of different compiler
+#      versions is not consistent.  It is also useful if a package
+#      wants to use GNU language extensions without setting -std=gnuXX.
+#
+#      Valid values are: c90, c99, c11, gnu90, gnu99, gnu11
+#
+# FORCE_CXX_STD
+#
+#      Overrides the compiler's default C++ dialect to ensure that a
+#      specific language variant is used.  This is useful if a package
+#      uses features from a later or earlier C++ standard but doesn't set
+#      -std=c++XX, since the default dialect choice of different compiler
+#      versions is not consistent.  It is also useful if a package
+#      wants to use GNU language extensions without setting -std=gnu++XX.
+#
+#      Valid values are: c++03, c++11, c++14, c++17, c++20, gnu++03,
+#      gnu++11, gnu++17, gnu++20
+#
 # The following variables are defined, and available for testing in
 # package Makefiles:
 #

Index: pkgsrc/mk/compiler/gcc-style-args.mk
diff -u pkgsrc/mk/compiler/gcc-style-args.mk:1.2 pkgsrc/mk/compiler/gcc-style-args.mk:1.3
--- pkgsrc/mk/compiler/gcc-style-args.mk:1.2    Sun Jul 30 18:57:44 2023
+++ pkgsrc/mk/compiler/gcc-style-args.mk        Wed Aug  2 15:59:58 2023
@@ -1,4 +1,4 @@
-# $NetBSD: gcc-style-args.mk,v 1.2 2023/07/30 18:57:44 nia Exp $
+# $NetBSD: gcc-style-args.mk,v 1.3 2023/08/02 15:59:58 nia Exp $
 
 #
 # Some compilers (e.g. clang) share command line argument formats with GCC.
@@ -16,6 +16,38 @@ _CTF_CFLAGS=         -gdwarf-2
 _WRAP_EXTRA_ARGS.cc+=  -fcommon
 CWRAPPERS_PREPEND.cc+= -fcommon
 
+
+#
+# Language dialects
+#
+
+_GCC_C_DIALECTS=       c89 c90 c99 c9x c11 c1x c17 c18 c2x
+
+_GCC_C_DIALECTS+=      gnu89 gnu90 gnu99 gnu9x gnu11 gnu1x gnu17 gnu18 \
+                       gnu2x
+
+_GCC_CXX_DIALECTS=     c++98 c++03 c++0x c++11 c++1y c++14 \
+                       c++1z c++17 c++2a c++20
+
+_GCC_CXX_DIALECTS+=    gnu++98 gnu++03 gnu++0x gnu++11 gnu++1y gnu++14 \
+                       gnu++1z gnu++17 gnu++2a gnu++20
+
+.if !empty(FORCE_C_STD)
+.  for std in ${_GCC_C_DIALECTS}
+.    if !empty(FORCE_C_STD:M${std})
+CWRAPPERS_APPEND.cc+=  -std=${std}
+.    endif
+.  endfor
+.endif
+
+.if !empty(FORCE_CXX_STD)
+.  for std in ${_GCC_CXX_DIALECTS}
+.    if !empty(FORCE_CXX_STD:M${std})
+CWRAPPERS_APPEND.cxx+= -std=${std}
+.    endif
+.  endfor
+.endif
+
 #
 # Hardening features
 #



Home | Main Index | Thread Index | Old Index