[OpenWrt-Devel] [PATCH v3] toolchain/gcc: switch to version 8 by default

Paul Spooren mail at aparcar.org
Tue Oct 8 06:50:00 EDT 2019


Main motivation for this commit is the introduction of
`-ffile-prefix-map=` which alows reproducible build path.

The usage of `-ffile-prefix-map=` in include/kernel.mk adds
reproducibility to kmods like gpio-hotplug and wireguard which before
stored the build path as debug information in .rodata.

Compiling tested without errors on the following targets:

* ath79
* brcm2708
* brcm63xx
* ixp4xx
* ramips
* sunxi
* x86

CC: Andre Heider <a.heider at gmail.com>
CC: Petr Štetiar <ynezz at true.cz>

Thanks to Andre for the iremap fixup
Thanks to Petr for his patience on helping which screws to tweak

Signed-off-by: Paul Spooren <mail at aparcar.org>
---
v3: add KCFLAGS to make kmods reproducible                                              

 config/Config-build.in                             |  2 --
 include/kernel.mk                                  |  1 +
 .../patches/120-strip-cflags-from-binary.patch     |  2 +-
 rules.mk                                           |  8 ++++----
 toolchain/gcc/Config.in                            |  8 ++++++--
 toolchain/gcc/Config.version                       | 14 ++++----------
 6 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/config/Config-build.in b/config/Config-build.in
index 9669fc86c7..872e5c12ab 100644
--- a/config/Config-build.in
+++ b/config/Config-build.in
@@ -243,7 +243,6 @@ menu "Global build settings"
 		config PKG_CC_STACKPROTECTOR_STRONG
 			bool "Strong"
 			select GCC_LIBSSP if !USE_MUSL
-			depends on !GCC_VERSION_4_8
 			depends on KERNEL_CC_STACKPROTECTOR_STRONG
 	endchoice
 
@@ -258,7 +257,6 @@ menu "Global build settings"
 		config KERNEL_CC_STACKPROTECTOR_REGULAR
 			bool "Regular"
 		config KERNEL_CC_STACKPROTECTOR_STRONG
-			depends on !GCC_VERSION_4_8
 			bool "Strong"
 	endchoice
 
diff --git a/include/kernel.mk b/include/kernel.mk
index 97d23661c9..451f5bdee3 100644
--- a/include/kernel.mk
+++ b/include/kernel.mk
@@ -104,6 +104,7 @@ endif
 KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
 
 KERNEL_MAKE_FLAGS = \
+	KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \
 	HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
 	CROSS_COMPILE="$(KERNEL_CROSS)" \
 	ARCH="$(LINUX_KARCH)" \
diff --git a/package/libs/openssl/patches/120-strip-cflags-from-binary.patch b/package/libs/openssl/patches/120-strip-cflags-from-binary.patch
index 75fb9d1684..7faec9ab88 100644
--- a/package/libs/openssl/patches/120-strip-cflags-from-binary.patch
+++ b/package/libs/openssl/patches/120-strip-cflags-from-binary.patch
@@ -17,7 +17,7 @@ index 2c619c62e8..893128345a 100644
  
  DEPEND[cversion.o]=buildinf.h
 -GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
-+GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(filter-out -I% -iremap% -fmacro-prefix-map%,$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q))" "$(PLATFORM)"
++GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(filter-out -I% -iremap% -fmacro-prefix-map% -ffile-prefix-map%,$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q))" "$(PLATFORM)"
  DEPEND[buildinf.h]=../configdata.pm
  
  GENERATE[uplink-x86.s]=../ms/uplink-x86.pl $(PERLASM_SCHEME)
diff --git a/rules.mk b/rules.mk
index b140fbca70..7063cf3ad6 100644
--- a/rules.mk
+++ b/rules.mk
@@ -139,11 +139,11 @@ else
   TOOLCHAIN_DIR_NAME:=toolchain-$(GNU_TARGET_NAME)
 endif
 
-ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_GCC_VERSION_4_8),$(CONFIG_TARGET_uml)),)
-  ifeq ($(CONFIG_GCC_USE_EMBEDDED_PATH_REMAP),y)
-    iremap = -fmacro-prefix-map=$(1)=$(2)
-  else
+ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_TARGET_uml)),)
+  ifeq ($(CONFIG_GCC_USE_IREMAP),y)
     iremap = -iremap$(1):$(2)
+  else
+    iremap = -ffile-prefix-map=$(1)=$(2)
   endif
 endif
 
diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in
index 0977f9b4e7..3882815d7f 100644
--- a/toolchain/gcc/Config.in
+++ b/toolchain/gcc/Config.in
@@ -2,8 +2,7 @@
 
 choice
 	prompt "GCC compiler Version" if TOOLCHAINOPTS
-	default GCC_USE_VERSION_8 if arc
-	default GCC_USE_VERSION_7
+	default GCC_USE_VERSION_8
 	help
 	  Select the version of gcc you wish to use.
 
@@ -22,6 +21,11 @@ choice
 		bool "gcc 9.x"
 endchoice
 
+config GCC_USE_IREMAP
+	default y if ( GCC_USE_VERSION_5 || GCC_USE_VERSION_7 )
+	default n
+	bool
+
 config GCC_USE_GRAPHITE
 	bool
 	prompt "Compile in support for the new Graphite framework in GCC 4.4+" if TOOLCHAINOPTS
diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version
index d9732b3e0d..0658f3d52b 100644
--- a/toolchain/gcc/Config.version
+++ b/toolchain/gcc/Config.version
@@ -2,23 +2,17 @@ config GCC_VERSION_5
 	default y if GCC_USE_VERSION_5
 	bool
 
-config GCC_VERSION_8
-	default y if GCC_USE_VERSION_8
-	default y if arc && !GCC_USE_VERSION_9
+config GCC_VERSION_7
+	default y if GCC_USE_VERSION_7
 	bool
 
 config GCC_VERSION_9
 	default y if GCC_USE_VERSION_9
 	bool
 
-config GCC_USE_EMBEDDED_PATH_REMAP
-	default y if ( GCC_VERSION_8 || GCC_VERSION_9 )
-	default n
-	bool
-
 config GCC_VERSION
 	string
 	default "5.5.0"		if GCC_VERSION_5
-	default "8.3.0"		if GCC_VERSION_8
+	default "7.4.0"		if GCC_VERSION_7
 	default "9.2.0"		if GCC_VERSION_9
-	default "7.4.0"
+	default "8.3.0"
-- 
2.23.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list