* [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks
@ 2025-02-05 18:10 Mike Gilbert
2025-02-05 18:39 ` James Le Cuirot
2025-02-05 19:06 ` Ionen Wolkens
0 siblings, 2 replies; 4+ messages in thread
From: Mike Gilbert @ 2025-02-05 18:10 UTC (permalink / raw
To: gentoo-dev; +Cc: toolchain, Mike Gilbert
We usually want to invoke cc -E rather than cpp directly. We should not
rely on the quirk of tc-getCPP defaulting to "cc -E" when CPP is unset.
Resolves a warning when CPP is set to llvm-cpp, which does not accept
the -E option.
Closes: https://bugs.gentoo.org/949340
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
---
eclass/toolchain-funcs.eclass | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 0abed5b8d75e..754d23f91c06 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1,4 +1,4 @@
-# Copyright 2002-2024 Gentoo Authors
+# Copyright 2002-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: toolchain-funcs.eclass
@@ -900,7 +900,7 @@ tc-get-compiler-type() {
HAVE_GCC
#endif
'
- local res=$($(tc-getCPP "$@") -E -P - <<<"${code}")
+ local res=$($(tc-getCC "$@") -E -P - <<<"${code}")
case ${res} in
*HAVE_PATHCC*) echo pathcc;;
@@ -927,7 +927,7 @@ tc-is-clang() {
# compilers rather than maintaining a --version flag matrix, bug #335943.
_gcc_fullversion() {
local ver="$1"; shift
- set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__")
+ set -- $($(tc-getCC "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__")
eval echo "${ver}"
}
@@ -960,7 +960,7 @@ gcc-micro-version() {
# Internal func. Based on _gcc_fullversion() above.
_clang_fullversion() {
local ver="$1"; shift
- set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__")
+ set -- $($(tc-getCC "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__")
eval echo "${ver}"
}
@@ -1347,14 +1347,14 @@ tc-get-c-rtlib() {
# @FUNCTION: tc-get-ptr-size
# @RETURN: Size of a pointer in bytes for CHOST (e.g. 4 or 8).
tc-get-ptr-size() {
- $(tc-getCPP) -P - <<< __SIZEOF_POINTER__ ||
+ $(tc-getCC) -E -P - <<< __SIZEOF_POINTER__ ||
die "Could not determine CHOST pointer size"
}
# @FUNCTION: tc-get-build-ptr-size
# @RETURN: Size of a pointer in bytes for CBUILD (e.g. 4 or 8).
tc-get-build-ptr-size() {
- $(tc-getBUILD_CPP) -P - <<< __SIZEOF_POINTER__ ||
+ $(tc-getBUILD_CC) -E -P - <<< __SIZEOF_POINTER__ ||
die "Could not determine CBUILD pointer size"
}
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks
2025-02-05 18:10 [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks Mike Gilbert
@ 2025-02-05 18:39 ` James Le Cuirot
2025-02-05 19:06 ` Ionen Wolkens
1 sibling, 0 replies; 4+ messages in thread
From: James Le Cuirot @ 2025-02-05 18:39 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 2674 bytes --]
On Wed, 2025-02-05 at 13:10 -0500, Mike Gilbert wrote:
> We usually want to invoke cc -E rather than cpp directly. We should not
> rely on the quirk of tc-getCPP defaulting to "cc -E" when CPP is unset.
>
> Resolves a warning when CPP is set to llvm-cpp, which does not accept
> the -E option.
>
> Closes: https://bugs.gentoo.org/949340
> Signed-off-by: Mike Gilbert <floppym@gentoo.org>
> ---
> eclass/toolchain-funcs.eclass | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
> index 0abed5b8d75e..754d23f91c06 100644
> --- a/eclass/toolchain-funcs.eclass
> +++ b/eclass/toolchain-funcs.eclass
> @@ -1,4 +1,4 @@
> -# Copyright 2002-2024 Gentoo Authors
> +# Copyright 2002-2025 Gentoo Authors
> # Distributed under the terms of the GNU General Public License v2
>
> # @ECLASS: toolchain-funcs.eclass
> @@ -900,7 +900,7 @@ tc-get-compiler-type() {
> HAVE_GCC
> #endif
> '
> - local res=$($(tc-getCPP "$@") -E -P - <<<"${code}")
> + local res=$($(tc-getCC "$@") -E -P - <<<"${code}")
>
> case ${res} in
> *HAVE_PATHCC*) echo pathcc;;
> @@ -927,7 +927,7 @@ tc-is-clang() {
> # compilers rather than maintaining a --version flag matrix, bug #335943.
> _gcc_fullversion() {
> local ver="$1"; shift
> - set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__")
> + set -- $($(tc-getCC "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__")
> eval echo "${ver}"
> }
>
> @@ -960,7 +960,7 @@ gcc-micro-version() {
> # Internal func. Based on _gcc_fullversion() above.
> _clang_fullversion() {
> local ver="$1"; shift
> - set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__")
> + set -- $($(tc-getCC "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__")
> eval echo "${ver}"
> }
>
> @@ -1347,14 +1347,14 @@ tc-get-c-rtlib() {
> # @FUNCTION: tc-get-ptr-size
> # @RETURN: Size of a pointer in bytes for CHOST (e.g. 4 or 8).
> tc-get-ptr-size() {
> - $(tc-getCPP) -P - <<< __SIZEOF_POINTER__ ||
> + $(tc-getCC) -E -P - <<< __SIZEOF_POINTER__ ||
> die "Could not determine CHOST pointer size"
> }
>
> # @FUNCTION: tc-get-build-ptr-size
> # @RETURN: Size of a pointer in bytes for CBUILD (e.g. 4 or 8).
> tc-get-build-ptr-size() {
> - $(tc-getBUILD_CPP) -P - <<< __SIZEOF_POINTER__ ||
> + $(tc-getBUILD_CC) -E -P - <<< __SIZEOF_POINTER__ ||
> die "Could not determine CBUILD pointer size"
> }
>
I'm slightly unsure, but this has always confused me. If it works for you...
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 858 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks
2025-02-05 18:10 [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks Mike Gilbert
2025-02-05 18:39 ` James Le Cuirot
@ 2025-02-05 19:06 ` Ionen Wolkens
2025-02-05 19:41 ` Mike Gilbert
1 sibling, 1 reply; 4+ messages in thread
From: Ionen Wolkens @ 2025-02-05 19:06 UTC (permalink / raw
To: gentoo-dev; +Cc: toolchain, Mike Gilbert
[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]
On Wed, Feb 05, 2025 at 01:10:10PM -0500, Mike Gilbert wrote:
> We usually want to invoke cc -E rather than cpp directly. We should not
> rely on the quirk of tc-getCPP defaulting to "cc -E" when CPP is unset.
I think it's a good change, but just to note it could break things
that relied on CPP being what's used.
Aka these don't have a proper way to say "test this compiler" and,
given it uses CPP, it's what I ended up setting:
CPP="${KERNEL_CC} -E" tc-is-clang ...
That's from nvidia-drivers ebuilds, which I'll fix real soon so no
need to worry about these. But I don't know what else may have done
this, not that I think it's going to be common.
I did something similar in linux-mod-r1.eclass but I took more
precaution there so it's not affected:
# for toolchain-funcs, uses CPP > CC but set both not to make assumptions
local CC=${KERNEL_CC} CPP="${KERNEL_CC} -E" LD=${KERNEL_LD}
I could cleanup the CPP bit if this is merged though. That it doesn't
use CC was confusing if anything thus needing a comment to explain
why it's being set.
Hopefully haven't forgot anything else I did, think wine & mingw things
are fine.
--
ionen
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks
2025-02-05 19:06 ` Ionen Wolkens
@ 2025-02-05 19:41 ` Mike Gilbert
0 siblings, 0 replies; 4+ messages in thread
From: Mike Gilbert @ 2025-02-05 19:41 UTC (permalink / raw
To: gentoo-dev
On Wed, Feb 5, 2025 at 2:06 PM Ionen Wolkens <ionen@gentoo.org> wrote:
>
> On Wed, Feb 05, 2025 at 01:10:10PM -0500, Mike Gilbert wrote:
> > We usually want to invoke cc -E rather than cpp directly. We should not
> > rely on the quirk of tc-getCPP defaulting to "cc -E" when CPP is unset.
>
> I think it's a good change, but just to note it could break things
> that relied on CPP being what's used.
Thanks for that reminder.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-05 19:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 18:10 [gentoo-dev] [PATCH] toolchain-funcs.eclass: avoid using tc-getCPP in compiler checks Mike Gilbert
2025-02-05 18:39 ` James Le Cuirot
2025-02-05 19:06 ` Ionen Wolkens
2025-02-05 19:41 ` Mike Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox