diff mbox series

[v2,1/2] x86/build: Remove -ffreestanding on i386 with GCC

Message ID 20250308042929.1753543-1-kees@kernel.org (mailing list archive)
State In Next
Commit 16cb16e0d28501f6eef7071675f1ffbceea8dd0d
Headers show
Series hardening: Enable i386 FORTIFY_SOURCE on Clang 16+ | expand

Commit Message

Kees Cook March 8, 2025, 4:29 a.m. UTC
The use of -ffreestanding is a leftover that is only needed for certain
versions of Clang. Adjust this to be Clang-only. A later patch will make
this a versioned check.

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/Makefile | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ingo Molnar March 8, 2025, 8:26 a.m. UTC | #1
* Kees Cook <kees@kernel.org> wrote:

> The use of -ffreestanding is a leftover that is only needed for certain
> versions of Clang. Adjust this to be Clang-only. A later patch will make
> this a versioned check.
> 
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: x86@kernel.org
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> ---
>  arch/x86/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 5b773b34768d..d25ed25fb7d9 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -137,8 +137,10 @@ ifeq ($(CONFIG_X86_32),y)
>          include $(srctree)/arch/x86/Makefile_32.cpu
>          KBUILD_CFLAGS += $(cflags-y)
>  
> +    ifeq ($(CONFIG_CC_IS_CLANG),y)
>          # temporary until string.h is fixed
>          KBUILD_CFLAGS += -ffreestanding
> +    endif

Acked-by: Ingo Molnar <mingo@kernel.org>

	Ingo
Nathan Chancellor March 8, 2025, 9:17 a.m. UTC | #2
On Fri, Mar 07, 2025 at 08:29:25PM -0800, Kees Cook wrote:
> The use of -ffreestanding is a leftover that is only needed for certain
> versions of Clang. Adjust this to be Clang-only. A later patch will make
> this a versioned check.
> 
> Signed-off-by: Kees Cook <kees@kernel.org>

This could also adjust the comment but it is probably not that big of a
deal since the "temporary" is already pretty stale.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: x86@kernel.org
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> ---
>  arch/x86/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 5b773b34768d..d25ed25fb7d9 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -137,8 +137,10 @@ ifeq ($(CONFIG_X86_32),y)
>          include $(srctree)/arch/x86/Makefile_32.cpu
>          KBUILD_CFLAGS += $(cflags-y)
>  
> +    ifeq ($(CONFIG_CC_IS_CLANG),y)
>          # temporary until string.h is fixed
>          KBUILD_CFLAGS += -ffreestanding
> +    endif
>  
>      ifeq ($(CONFIG_STACKPROTECTOR),y)
>          ifeq ($(CONFIG_SMP),y)
> -- 
> 2.34.1
>
Kees Cook March 8, 2025, 5:23 p.m. UTC | #3
On Sat, Mar 08, 2025 at 10:17:46AM +0100, Nathan Chancellor wrote:
> On Fri, Mar 07, 2025 at 08:29:25PM -0800, Kees Cook wrote:
> > The use of -ffreestanding is a leftover that is only needed for certain
> > versions of Clang. Adjust this to be Clang-only. A later patch will make
> > this a versioned check.
> > 
> > Signed-off-by: Kees Cook <kees@kernel.org>
> 
> This could also adjust the comment but it is probably not that big of a
> deal since the "temporary" is already pretty stale.

Ah yeah, good call. I'll fix that up locally.

> 
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>

Thanks!

-Kees
diff mbox series

Patch

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5b773b34768d..d25ed25fb7d9 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -137,8 +137,10 @@  ifeq ($(CONFIG_X86_32),y)
         include $(srctree)/arch/x86/Makefile_32.cpu
         KBUILD_CFLAGS += $(cflags-y)
 
+    ifeq ($(CONFIG_CC_IS_CLANG),y)
         # temporary until string.h is fixed
         KBUILD_CFLAGS += -ffreestanding
+    endif
 
     ifeq ($(CONFIG_STACKPROTECTOR),y)
         ifeq ($(CONFIG_SMP),y)