[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCHv4 14/43] build: Override default pie option of GCC if possible
Hi Wei, On 06.07.2018 11:03, Wei Chen wrote: 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=noneCFLAGS-$(CONFIG_OPTIMIZE_NONE) += -O0 -fno-optimize-sibling-calls -fno-tree-vectorizeCXXFLAGS-$(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),) Hum, do you think we really need this check? +$(call error_if_gcc_version_lt,6,1) ..and this crash if GCC was configured with enable-default-pie. Is it the case that GCC < 6.1 can have this configuration option but does not provide the runtime option to disable it again with -no-pie? +ASFLAGS += -no-pie +CFLAGS += -no-pie +CXXFLAGS += -no-pie +LIBLDFLAGS += -no-pie +LDFLAGS += -no-pie +endif If yes, we need to do it in the way you propose. Otherwise, I would just add the -no-pie option irregardless how GCC was configured. Just set add the flag starting with the first GCC version that it provides. Something like: ASFLAGS-$(call gcc_version_ge,6,1) += -no-pie CFLAGS-$(call gcc_version_ge,6,1) += -no-pie CXXFLAGS-$(call gcc_version_ge,6,1) += -no-pie LIBLDFLAGS-$(call gcc_version_ge,6,1) += -no-pie LDFLAGS-$(call gcc_version_ge,6,1) += -no-pie What do you think? Thanks, Simon _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |