All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix Makefile to ensure proper options get passed from gcc
@ 2009-08-28 13:29 Jory A. Pratt
  0 siblings, 0 replies; only message in thread
From: Jory A. Pratt @ 2009-08-28 13:29 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 746 bytes --]

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

[-- Attachment #2: fix-fpie-from-being-used.diff --]
[-- Type: text/plain, Size: 735 bytes --]

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)

[-- Attachment #3: fix-cc-options-check.patch --]
[-- Type: text/plain, Size: 843 bytes --]

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-28 13:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-28 13:29 [PATCH] fix Makefile to ensure proper options get passed from gcc Jory A. Pratt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.