16.10的gcc的重大改变

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
astolia
论坛版主
帖子: 6574
注册时间: 2008-09-18 13:11

16.10的gcc的重大改变

#1

帖子 astolia » 2016-09-24 0:30

16.10中的gcc包在编译时开启了--enable-default-pie配置项,导致gcc在编译时是默认开启-fPIE和-pie的
对一般用户程序倒没什么,但是如果自己编译内核的话,就会出各种问题
解决方法是给内核的编译参数加上-fno-pie和-no-pie明确禁止pie,下面是ubuntu官方的补丁文件

代码: 全选

From d5281ea1b3cb5a01eda0c2022d2409a2369613a3 Mon Sep 17 00:00:00 2001
From: Steve Beattie <steve.beattie@canonical.com>
Date: Tue, 10 May 2016 12:44:04 +0100
Subject: [PATCH 2/4] UBUNTU: SAUCE: (no-up) disable -pie when gcc has it
 enabled by default

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@canonical.com>
[apw@canonical.com: shifted up so works in arch/<arch/Makefile.]
BugLink: http://bugs.launchpad.net/bugs/1574982
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Makefile b/Makefile
index 66da9a3..64fc2d5 100644
--- a/Makefile
+++ b/Makefile
@@ -611,6 +611,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
 ARCH_CPPFLAGS :=
-- 
2.7.4

onlylove
论坛版主
帖子: 5261
注册时间: 2007-01-14 16:23

Re: 16.10的gcc的重大改变

#2

帖子 onlylove » 2016-09-24 0:48

虽然不太可能去做这件事,不过,debian是不是也这样啊?
头像
astolia
论坛版主
帖子: 6574
注册时间: 2008-09-18 13:11

Re: 16.10的gcc的重大改变

#3

帖子 astolia » 2016-09-24 10:23

debian没有加--enable-default-pie,这是ubuntu自己搞的
头像
YeLee
论坛版主
帖子: 26406
注册时间: 2008-08-13 8:48
系统: Fundu i64
来自: 东海硇州,一双管钥。
联系:

Re: 16.10的gcc的重大改变

#4

帖子 YeLee » 2016-10-03 9:25

Gentoo家的gcc默认是直接把c++11的选项关了的 :Cry
◎当我站在道德的高度上俯视别人的时候,发现自己是多么渺小。
♥执着但不偏激,反对而不排斥,坚决捍卫矛盾体的存在方式。
★★★天气预报★★★
fcitx-yatable一个可以使用的码表输入法
[教程]几个实例攻克软件编译难关
Gentoo Development Guide
字体相关
回复