mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] powerpc: use __clang__ instead of CONFIG_CC_IS_CLANG
@ 2025-02-18  4:48 Shung-Hsi Yu
  2025-02-18  7:54 ` Michal Suchánek
  0 siblings, 1 reply; 3+ messages in thread
From: Shung-Hsi Yu @ 2025-02-18  4:48 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Michael Ellerman
  Cc: Madhavan Srinivasan, Nicholas Piggin, Christophe Leroy,
	Naveen N Rao, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Segher Boessenkool, Vitaly Chikunov,
	Michal Suchánek, Abhishek Dubey, Yonghong Song,
	Shung-Hsi Yu

Due to include chain (below), powerpc's asm-compat.h is part of UAPI,
thus it should use the __clang__ macro to directly detect whether Clang
is used rather then relying on the kernel config setting. The later is
unreliable because the userspace tools that uses UAPI may be compile
with a different compiler than the one used for the kernel, leading to
incorrect constrain selection (see link for an example of such).

  include/uapi/linux/ptrace.h
  arch/powerpc/include/asm/ptrace.h
  arch/powerpc/include/asm/paca.h
  arch/powerpc/include/asm/atomic.h
  arch/powerpc/include/asm/asm-compat.h

Link: https://github.com/iovisor/bcc/issues/5172
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
 arch/powerpc/include/asm/asm-compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index f48e644900a2..34f8740909a9 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -37,7 +37,7 @@
 #define STDX_BE	stringify_in_c(stdbrx)
 #endif
 
-#ifdef CONFIG_CC_IS_CLANG
+#ifdef __clang__
 #define DS_FORM_CONSTRAINT "Z<>"
 #else
 #define DS_FORM_CONSTRAINT "YZ<>"
-- 
2.48.1


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

* Re: [PATCH 1/1] powerpc: use __clang__ instead of CONFIG_CC_IS_CLANG
  2025-02-18  4:48 [PATCH 1/1] powerpc: use __clang__ instead of CONFIG_CC_IS_CLANG Shung-Hsi Yu
@ 2025-02-18  7:54 ` Michal Suchánek
  2025-02-18  9:03   ` Shung-Hsi Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Suchánek @ 2025-02-18  7:54 UTC (permalink / raw)
  To: Shung-Hsi Yu
  Cc: linuxppc-dev, linux-kernel, Michael Ellerman,
	Madhavan Srinivasan, Nicholas Piggin, Christophe Leroy,
	Naveen N Rao, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Segher Boessenkool, Vitaly Chikunov,
	Abhishek Dubey, Yonghong Song

Hello,

how does this happen?

On Tue, Feb 18, 2025 at 12:48:01PM +0800, Shung-Hsi Yu wrote:
> Due to include chain (below), powerpc's asm-compat.h is part of UAPI,
> thus it should use the __clang__ macro to directly detect whether Clang
> is used rather then relying on the kernel config setting. The later is
> unreliable because the userspace tools that uses UAPI may be compile
> with a different compiler than the one used for the kernel, leading to
> incorrect constrain selection (see link for an example of such).
> 
>   include/uapi/linux/ptrace.h
>   arch/powerpc/include/asm/ptrace.h

There is arch/powerpc/include/uapi/asm/ptrace.h

and if the installed header is used this is what should be included.

That does no include other asm headers.

Thanks

Michal

>   arch/powerpc/include/asm/paca.h
>   arch/powerpc/include/asm/atomic.h
>   arch/powerpc/include/asm/asm-compat.h
> 
> Link: https://github.com/iovisor/bcc/issues/5172
> Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
> ---
>  arch/powerpc/include/asm/asm-compat.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
> index f48e644900a2..34f8740909a9 100644
> --- a/arch/powerpc/include/asm/asm-compat.h
> +++ b/arch/powerpc/include/asm/asm-compat.h
> @@ -37,7 +37,7 @@
>  #define STDX_BE	stringify_in_c(stdbrx)
>  #endif
>  
> -#ifdef CONFIG_CC_IS_CLANG
> +#ifdef __clang__
>  #define DS_FORM_CONSTRAINT "Z<>"
>  #else
>  #define DS_FORM_CONSTRAINT "YZ<>"
> -- 
> 2.48.1
> 

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

* Re: [PATCH 1/1] powerpc: use __clang__ instead of CONFIG_CC_IS_CLANG
  2025-02-18  7:54 ` Michal Suchánek
@ 2025-02-18  9:03   ` Shung-Hsi Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Shung-Hsi Yu @ 2025-02-18  9:03 UTC (permalink / raw)
  To: Michal Suchánek
  Cc: linuxppc-dev, linux-kernel, Michael Ellerman,
	Madhavan Srinivasan, Nicholas Piggin, Christophe Leroy,
	Naveen N Rao, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Segher Boessenkool, Vitaly Chikunov,
	Abhishek Dubey, Yonghong Song

On Tue, Feb 18, 2025 at 08:54:03AM +0100, Michal Suchánek wrote:
> Hello,
> 
> how does this happen?
> 
> On Tue, Feb 18, 2025 at 12:48:01PM +0800, Shung-Hsi Yu wrote:
> > Due to include chain (below), powerpc's asm-compat.h is part of UAPI,
...
> >   include/uapi/linux/ptrace.h
> >   arch/powerpc/include/asm/ptrace.h
> 
> There is arch/powerpc/include/uapi/asm/ptrace.h
> 
> and if the installed header is used this is what should be included.
> 
> That does no include other asm headers.

Ah. Then asm-compat.h not, my bad.

I thought bcc[1] was pulling the kernel headers like a userspace
program, but it's actually pulling them in as if building a kernel
module, thus include path has arch/powerpc/include/asm/ptrace.h before
arch/powerpc/include/uapi/asm/ptrace.h[2].

> Thanks
> 
> Michal
...

1: https://github.com/iovisor/bcc
2: https://github.com/iovisor/bcc/blob/5bc97bb/src/cc/frontends/clang/kbuild_helper.cc#L81-L120

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

end of thread, other threads:[~2025-02-18  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-18  4:48 [PATCH 1/1] powerpc: use __clang__ instead of CONFIG_CC_IS_CLANG Shung-Hsi Yu
2025-02-18  7:54 ` Michal Suchánek
2025-02-18  9:03   ` Shung-Hsi Yu

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

all inboxes | Powered by JetHome®