[gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.ecla
From
Andreas Sturmlechner@21:1/5 to
All on Fri Dec 13 23:31:54 2024
Every once in a while, a package requires a really up to date active compiler in order to build successfully. ecm.eclass had inherited such a mechanism, albeit GCC specific, from older kde* eclasses. I don't think that is a good place for it so I suggest to add a more universal function to toolchain-funcs.eclass.
Similar to tc-check-openmp.
eclass/toolchain-funcs.eclass | 44 +++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 2911ed66e63c..cd3dcf000db7 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -647,6 +647,50 @@ _tc-has-openmp() {
return ${ret}
}
+# @FUNCTION: tc-check-min_ver
+# @USAGE: <gcc or clang> <minimum version>
+# @DESCRIPTION:
+# Minimum version of active GCC or Clang to require.
+#
+# You should test for any necessary minimum version in pkg_pretend in order to +# warn the user of required toolchain changes. You must still check for it at +# build-time, e.g.
+# @CODE
+# pkg_pretend() {
+# [[ ${MERGE_TYPE} != binary ]] && tc-check-min_ver gcc 13.2.0
+# }
+#
+# pkg_setup() {
+# [[ ${MERGE_TYPE} != binary ]] && tc-check-min_ver gcc 13.2.0
+# }
+# @CODE
+tc-check-min_ver() {
+ do_check() {
+ debug-print "Compiler version check for ${1}"
+ debug-print "Detected: ${2}"
+ debug-print "Required: ${3}"
+ if ver_test ${2} -lt ${3}; then
+ eerror "Your current compiler is too old for this package!"
+ die "Active compiler is too old for this package (found ${2})."
+ fi
+ }
+
+ cas