public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver()
@ 2024-12-13 22:31 Andreas Sturmlechner
  2024-12-15  8:22 ` Mickaël Bucas
  2024-12-16 16:43 ` Sam James
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Sturmlechner @ 2024-12-13 22:31 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]

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
+	}
+
+	case ${1} in
+		gcc)
+			tc-is-gcc || return
+			do_check GCC $(gcc-version) ${2}
+			;;
+		clang)
+			tc-is-clang || return
+			do_check Clang $(clang-version) ${2}
+			;;
+		*)
+			eerror "Unknown first parameter for ${FUNCNAME} - must be gcc or clang"
+			die "${FUNCNAME}: Parameter ${1} unknown"
+			;;
+	esac
+}
+
 # @FUNCTION: tc-check-openmp
 # @DESCRIPTION:
 # Test for OpenMP support with the current compiler and error out with


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 789 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver()
  2024-12-13 22:31 [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver() Andreas Sturmlechner
@ 2024-12-15  8:22 ` Mickaël Bucas
  2024-12-15  8:55   ` Ionen Wolkens
  2024-12-16 16:43 ` Sam James
  1 sibling, 1 reply; 4+ messages in thread
From: Mickaël Bucas @ 2024-12-15  8:22 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

Le sam. 14 déc. 2024, 00:32, Andreas Sturmlechner <asturm@gentoo.org> a
écrit :

> 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.


Hi

I was wondering: how is this check different from a version dependency in
any *DEPEND variable?

Thanks

[-- Attachment #2: Type: text/html, Size: 1022 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver()
  2024-12-15  8:22 ` Mickaël Bucas
@ 2024-12-15  8:55   ` Ionen Wolkens
  0 siblings, 0 replies; 4+ messages in thread
From: Ionen Wolkens @ 2024-12-15  8:55 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

On Sun, Dec 15, 2024 at 10:22:06AM +0200, Mickaël Bucas wrote:
> Le sam. 14 déc. 2024, 00:32, Andreas Sturmlechner <asturm@gentoo.org> a
> écrit :
> 
> > 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.
> 
> 
> Hi
> 
> I was wondering: how is this check different from a version dependency in
> any *DEPEND variable?

Different compilers and multiple versions of them can be installed at
same time, and the user can pick them by setting e.g. CC=clang-18,
using gcc-config/eselect, PATH, and such.

A dependency check would only ensure that the compiler is installed,
not that it's the one that's being used, what version of it, or even
what USE is enabled for the used slot/compiler (openmp case). This
would only work if the ebuild is enforcing a specific compiler while
ignoring the user's choice.
-- 
ionen

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver()
  2024-12-13 22:31 [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver() Andreas Sturmlechner
  2024-12-15  8:22 ` Mickaël Bucas
@ 2024-12-16 16:43 ` Sam James
  1 sibling, 0 replies; 4+ messages in thread
From: Sam James @ 2024-12-16 16:43 UTC (permalink / raw
  To: Andreas Sturmlechner; +Cc: gentoo-dev, toolchain

Andreas Sturmlechner <asturm@gentoo.org> writes:

> 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.

LGTM, but please CC eclass maints in future.

>
>
>  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
> +	}
> +
> +	case ${1} in
> +		gcc)
> +			tc-is-gcc || return
> +			do_check GCC $(gcc-version) ${2}
> +			;;
> +		clang)
> +			tc-is-clang || return
> +			do_check Clang $(clang-version) ${2}
> +			;;
> +		*)
> +			eerror "Unknown first parameter for ${FUNCNAME} - must be gcc or clang"
> +			die "${FUNCNAME}: Parameter ${1} unknown"
> +			;;
> +	esac
> +}
> +
>  # @FUNCTION: tc-check-openmp
>  # @DESCRIPTION:
>  # Test for OpenMP support with the current compiler and error out with


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-16 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 22:31 [gentoo-dev] [RFC] [PATCH] toolchain-funcs.eclass: toolchain-funcs.eclass: Add tc-check-min_ver() Andreas Sturmlechner
2024-12-15  8:22 ` Mickaël Bucas
2024-12-15  8:55   ` Ionen Wolkens
2024-12-16 16:43 ` Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox