Messages in this thread Patches in this message | | | Date | Fri, 28 Aug 2009 08:29:54 -0500 | From | "Jory A. Pratt" <> | Subject | [PATCH] fix Makefile to ensure proper options get passed from gcc |
| |
if -D__KERNEL__ is not passed via KBUILD_CFLAGS the compiler can have options passed by default that will unset other options such as -ffreestanding or -fno-toplevel-reorder if the compiler is passing -fPIE.
refer to fix-fpie-from-being-used.diff
Another option that was suggested from another user was to pass -D__KERNEL__ via Kbuild.include, patch is also attached. either patch would work, There is no risk of breakage, benefit is for those who use a hardened toolchain.
fix-cc-options-check.patch
I believe we should pass the option via KBUILD_CFLAGS as to not confuse the fact that we are not building CPP code, but rather C code.
Also correct me if I am wrong but last I knew only part of kernel that was cpp was qconfig.
-Jory signed off by: Jory A. Pratt <anarchy@gentoo.org>
When -fPIE is pass to cc1 it can't use -ffreestanding or -fno-toplevel-reorder. This will cause issues in video-vga.c when compiled leaving a user with no video modes avaliable when booting system. Many thanks to Vinky for tracking down bug.
--- Makefile~ 2009-08-27 21:38:59.809945943 -0500 +++ Makefile 2009-08-27 21:40:04.204922755 -0500 @@ -348,7 +348,8 @@ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ -Wno-format-security \ - -fno-delete-null-pointer-checks + -fno-delete-null-pointer-checks \ + -D__KERNEL__ KBUILD_AFLAGS := -D__ASSEMBLY__ # Read KERNELRELEASE from include/config/kernel.release (if it exists)2009-08-28 Magnus Granberg <zorry@ume.nu>
#282201 * scripts/Kbuild.incude add $(KBUILD_CPPFLAGS)
--- scripts/Kbuild.include.zorry 2009-08-28 01:50:41.000000000 +0000 +++ scripts/Kbuild.include 2009-08-28 01:50:31.000000000 +0000 @@ -105,12 +105,12 @@ # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call try-run,\ - $(CC) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) # cc-option-align # Prefix align with either -falign or -malign
| |