]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
gcc: Fix compilation.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Apr 2011 23:38:56 +0000 (01:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Apr 2011 23:38:56 +0000 (01:38 +0200)
gcc was built without proper SSP and PIE support and the compiler
itself was compiled without PIE as well.

pkgs/gcc/gcc.nm

index e30eff4f3edc3b74d22781fa8bddde4329a46bb9..5332ff54e12ba4ac1ee7534c42b2f59751aa30a8 100644 (file)
@@ -26,7 +26,7 @@ include $(PKGROOT)/Include
 
 PKG_NAME       = gcc
 PKG_VER        = 4.6.0
-PKG_REL        = 1
+PKG_REL        = 2
 
 PKG_MAINTAINER = Michael Tremer <michael.tremer@ipfire.org>
 PKG_GROUPS     = Development/Compilers
@@ -39,9 +39,12 @@ define PKG_DESCRIPTION
        You'll need this package in order to compile C code.
 endef
 
-PKG_BUILD_DEPS+= autogen cloog-devel dejagnu elfutils-devel expect gmp-devel \
-       libffi-devel mpc-devel mpfr-devel ppl-devel=0.10.2-0.ip3 texinfo zlib-devel
-PKG_DEPS-gcc  += binutils libgcc-devel cloog>=0.15
+BINUTILS_VER = 2.21.51.0.8-1
+
+PKG_BUILD_DEPS+= autogen binutils>=$(BINUTILS_VER) cloog-devel dejagnu \
+       elfutils-devel expect flex gmp-devel libffi-devel mpc-devel mpfr-devel \
+       ppl-devel=0.10.2-0.ip3 texinfo zlib-devel
+PKG_DEPS-gcc  += binutils>=$(BINUTILS_VER) libgcc-devel cloog>=0.15
 
 # Make the GCC target platform
 GCC_TARGET_PLATFORM = $(subst -gnu,,$(DISTRO_MACHINE))
@@ -61,6 +64,8 @@ CFLAGS := $(subst -m64,,$(CFLAGS))
 #  Remove -march=i686
 CFLAGS := $(subst -march=i686,,$(CFLAGS))
 
+HARD_CFLAGS = -DEFAULT_PIE_SSP -DEFAULT_RELRO -DEFAULT_BIND_NOW
+
 export CFLAGS
 export CXXFLAGS = $(subst -Wall,,$(CFLAGS))
 
@@ -162,6 +167,20 @@ define STAGE_PREPARE_CMDS
 
        cd $(DIR_APP) && sed -i gcc/Makefile.in \
                -e "s/-fno-exceptions/& -fno-asynchronous-unwind-tables/"
+
+       # we want to be able to control the pie patch logic via something other
+       # than ALL_CFLAGS...
+       cd $(DIR_APP) && sed -i gcc/Makefile.in \
+               -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
+               -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $$(HARD_CFLAGS) |'
+
+       # Enable the GCC hardening by default.
+       cd $(DIR_APP) && sed -i gcc/Makefile.in \
+               -e "s|^HARD_CFLAGS = |HARD_CFLAGS = $(HARD_CFLAGS) |"
+
+       # Compile the compile with -fPIC as well.
+       cd $(DIR_APP) && sed -i gcc/Makefile.in \
+               -e "s|^ESP_NOPIE_CFLAGS = .*|ESP_NOPIE_CFLAGS =|"
 endef
 
 define STAGE_BUILD
@@ -195,7 +214,7 @@ define STAGE_BUILD
                        --enable-linker-build-id \
                        $(CONFIGURE_ARGS)
 
-       cd $(DIR_SRC)/gcc-build && make $(PARALLELISMFLAGS)
+       cd $(DIR_SRC)/gcc-build && make profiledbootstrap #$(PARALLELISMFLAGS)
 endef
 
 #define STAGE_TEST