[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCHv4 14/43] build: Override default pie option of GCC if possible


  • To: <minios-devel@xxxxxxxxxxxxxxxxxxxx>, <simon.kuenzer@xxxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Fri, 6 Jul 2018 09:03:27 +0000
  • Authentication-results: spf=fail (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Cc: Kaly.Xin@xxxxxxx, nd@xxxxxxx, wei.chen@xxxxxxx
  • Delivery-date: Fri, 06 Jul 2018 09:05:02 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

On recent debian distributions (Debian/Ubuntu), the GCC enabled
"--enable-default-pie" configuration option by default. This will
case Unikraft link failed on debian/ubuntu platforms.
In commit:
"build: Add -no-pie to GCC flags"
"cc7eb555080775cf2cb4a595a07b6121ff0f7361"
I have added -no-pie to GCC flags directly to override the default
pie option. But as Wei Liu reminded, old version GCC doesn't
support -no-pie option.

So in this patch, I checked the enbale-default-pie option and
GCC version, and then added -no-pie to override it.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
 Makefile.uk | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index b3938d0..cea7ac3 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -4,15 +4,15 @@
 #
 
################################################################################
 
-ASFLAGS     += -U __linux__ -U __FreeBSD__ -U __sun__ -D__ASSEMBLY__ -no-pie
+ASFLAGS     += -U __linux__ -U __FreeBSD__ -U __sun__ -D__ASSEMBLY__
 ASINCLUDES  += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 
-CFLAGS      += -U __linux__ -U __FreeBSD__ -U __sun__ -no-pie
+CFLAGS      += -U __linux__ -U __FreeBSD__ -U __sun__
 CFLAGS      += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
 CFLAGS      += -Wall -Wextra
 CINCLUDES   += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 
-CXXFLAGS    += -U __linux__ -U __FreeBSD__ -U __sun__ -no-pie
+CXXFLAGS    += -U __linux__ -U __FreeBSD__ -U __sun__
 CXXFLAGS    += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
 CXXFLAGS    += -Wall -Wextra
 CXXINCLUDES += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
@@ -20,8 +20,8 @@ CXXINCLUDES += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 # Set the text and data sections to be readable and writable. Also,
 # do not page-align the data segment. If the output format supports
 # Unix style magic numbers, mark the output as OMAGIC.
-LIBLDFLAGS  += -nostdinc -nostdlib -Wl,--omagic -Wl,-r -no-pie
-LDFLAGS     += -nostdinc -nostdlib -Wl,--omagic -Wl,--build-id=none -no-pie
+LIBLDFLAGS  += -nostdinc -nostdlib -Wl,--omagic -Wl,-r
+LDFLAGS     += -nostdinc -nostdlib -Wl,--omagic -Wl,--build-id=none
 
 CFLAGS-$(CONFIG_OPTIMIZE_NONE)            += -O0 -fno-optimize-sibling-calls 
-fno-tree-vectorize
 CXXFLAGS-$(CONFIG_OPTIMIZE_NONE)          += -O0 -fno-optimize-sibling-calls 
-fno-tree-vectorize
@@ -56,3 +56,15 @@ endif
 ASFLAGS  += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION) 
-DUK_FULLVERSION=$(UK_FULLVERSION) -DUK_CODENAME="$(UK_CODENAME)"
 CFLAGS   += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION) 
-DUK_FULLVERSION=$(UK_FULLVERSION) -DUK_CODENAME="$(UK_CODENAME)"
 CXXFLAGS += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION) 
-DUK_FULLVERSION=$(UK_FULLVERSION) -DUK_CODENAME="$(UK_CODENAME)"
+
+# Check whether the pie option is enabled by default. If possible,
+# add -no-pie to link flags to override default pie option.
+PIE_ON = $(shell $(CC) -v 2>&1 | grep -Fo "enable-default-pie")
+ifneq ($(PIE_ON),)
+$(call error_if_gcc_version_lt,6,1)
+ASFLAGS     += -no-pie
+CFLAGS      += -no-pie
+CXXFLAGS    += -no-pie
+LIBLDFLAGS  += -no-pie
+LDFLAGS     += -no-pie
+endif
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.