[xenial/master-next 1/1] UBUNTU: SAUCE: (no-up) disable -pie when gcc has it enabled by default

Andy Whitcroft apw at canonical.com
Tue May 10 11:44:04 UTC 2016

From: Steve Beattie <steve.beattie at canonical.com>

In Ubuntu 16.10, gcc's defaults have been set to build Position
Independent Executables (PIE) on amd64 and ppc64le (gcc was configured
this way for s390x in Ubuntu 16.04 LTS). This breaks the kernel build on
amd64. The following patch disables pie for x86 builds (though not yet
verified to work with gcc configured to build PIE by default i386 --
we're not planning to enable it for that architecture).

The intent is for this patch to go upstream after expanding it to
additional architectures where needed, but I wanted to ensure that
we could build 16.10 kernels first. I've successfully built kernels
and booted them with this patch applied using the 16.10 compiler.

Patch is against yakkety.git, but also applies with minor movement
(no fuzz) against current linus.git.

Signed-off-by: Steve Beattie <steve.beattie at canonical.com>
[apw at canonical.com: shifted up so works in arch/<arch/Makefile.]
BugLink: http://bugs.launchpad.net/bugs/1574982
Signed-off-by: Andy Whitcroft <apw at canonical.com>
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Makefile b/Makefile
index dda982c..f96b174 100644
--- a/Makefile
+++ b/Makefile
@@ -608,6 +608,12 @@ endif # $(dot-config)
 # Defaults to vmlinux, but the arch makefile usually adds further targets
 all: vmlinux
+# force no-pie for distro compilers that enable pie by default
+KBUILD_CFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CFLAGS += $(call cc-option, -no-pie)
+KBUILD_AFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
 # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
 # values of the respective KBUILD_* variables

More information about the kernel-team mailing list