linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1] x86/build: add -fno-builtin flag to prevent shadowing
@ 2022-03-06 17:10 Vincent Mailhol
  2022-05-08 10:09 ` [RESEND " Vincent Mailhol
  0 siblings, 1 reply; 11+ messages in thread
From: Vincent Mailhol @ 2022-03-06 17:10 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H . Peter Anvin
  Cc: linux-kernel, Vincent Mailhol

Aside of the __builtin_foo() ones, x86 does not directly rely on any
builtin functions.

However, such builtin functions are not explicitly deactivated,
creating some collisions, concrete example being ffs() from bitops.h,
c.f.:

| ./arch/x86/include/asm/bitops.h:283:28: warning: declaration of 'ffs' shadows a built-in function [-Wshadow]
|   283 | static __always_inline int ffs(int x)

This patch adds -fno-builtin to KBUILD_CFLAGS for the x86
architectures in order to prevent shadowing of builtin functions.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
FYI, I tested this patch on a "make allyesconfig" for both x86_32 and
x86_64.

arch/x86/Makefile.um already adds the -fno-builtin but
does not get included in arch/x86/Makefile (the only consumer of
Makefile.um is arch/um/Makefile). I do not understand what is the role
of Makefile.um here.

Because of my lack of confidence on this Makefile.um, and because it
is the first time for me to send a patch for x86/build I am sending
this as an RFC.

Regarless, this patch is my best shot on this issue. I hope I did not
miss anything obvious.
---
 arch/x86/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index e84cdd409b64..5ff7b6571dd2 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -53,6 +53,8 @@ export REALMODE_CFLAGS
 # e.g.: obj-y += foo_$(BITS).o
 export BITS
 
+KBUILD_CFLAGS += -fno-builtin
+
 #
 # Prevent GCC from generating any FP code by mistake.
 #
-- 
2.34.1


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

end of thread, other threads:[~2022-05-10 15:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-06 17:10 [RFC PATCH v1] x86/build: add -fno-builtin flag to prevent shadowing Vincent Mailhol
2022-05-08 10:09 ` [RESEND " Vincent Mailhol
2022-05-08 10:27   ` Arnd Bergmann
2022-05-08 12:37     ` Vincent MAILHOL
2022-05-08 23:51       ` Nathan Chancellor
2022-05-09 15:00         ` Vincent MAILHOL
2022-05-09 19:50           ` Nick Desaulniers
2022-05-09 23:12             ` Vincent MAILHOL
2022-05-09 23:26               ` Nick Desaulniers
2022-05-10  1:10                 ` Vincent MAILHOL
2022-05-10 14:33                   ` Vincent MAILHOL

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).