All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jory A. Pratt" <anarchy@gentoo.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] fix Makefile to ensure proper options get passed from gcc
Date: Fri, 28 Aug 2009 08:29:54 -0500	[thread overview]
Message-ID: <4A97DBD2.903@gentoo.org> (raw)

[-- 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


                 reply	other threads:[~2009-08-28 13:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A97DBD2.903@gentoo.org \
    --to=anarchy@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.