Re: [PATCH 11/14] x86/build: Drop unused '-ffreestanding' addition to KBUILD_CFLAGS

Nathan Chancellor
2026-04-29T17:25:01Z

On Tue, Apr 28, 2026 at 10:59:17PM -0400, Nathan Chancellor wrote:
> Now that the minimum supported version of LLVM for building the kernel
> has been raised to 17.0.1, the condition to add '-ffreestanding' to
> KBUILD_CFLAGS for 32-bit x86 is always false, so the if block can be
> removed.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Cc: Thomas Gleixner <tglx@kernel.org>
> 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 | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 46fec0b08487..5720f2470cfc 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -124,11 +124,6 @@ ifeq ($(CONFIG_X86_32),y)
> include $(srctree)/arch/x86/Makefile_32.cpu
> KBUILD_CFLAGS += $(cflags-y)
>
> - ifneq ($(call clang-min-version, 160000),y)

Sashiko points out [1] that the condition of this block, added by

d70da12453ac ("hardening: Enable i386 FORTIFY_SOURCE on Clang 16+")

results in GCC builds still having '-ffreestanding' enabled. I don't
think this should be a problem but if we want to be more conservative, I
could turn this into an

ifdef CONFIG_CC_IS_GCC

block to keep the same behavior for GCC while avoiding the flag
altogether for clang. Regardless, the commit message will need
rewording.

[1]: https://sashiko.dev/#/patchset/14621?part=11

> - # https://github.com/llvm/llvm-project/issues/53645
> - KBUILD_CFLAGS += -ffreestanding
> - endif
> -
> percpu_seg := fs
> else
> BITS := 64
>
> --
> 2.54.0
>