@@ -249,7 +249,7 @@ export PKG_CONFIG
HOSTCC:=gcc
HOSTCXX:=g++
HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include)
-HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS)
+HOST_CFLAGS:=$(if $(CONFIG_BUILD_NATIVE_ARCH),-march=native) -O2 $(HOST_CPPFLAGS)
HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib)
ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
@@ -164,6 +164,14 @@ menuconfig TOOLCHAINOPTS
bool "Toolchain Options" if DEVEL
depends on NEED_TOOLCHAIN
+config BUILD_NATIVE_ARCH
+ def_bool n
+ prompt "Build the toolchain with -march=native" if TOOLCHAINOPTS
+ help
+ When building the toolchain, optimize for the CPU in this specific machine.
+ Only choose Y if you're not going to run the compiled toolchain on any other
+ system.
+
menuconfig EXTRA_TARGET_ARCH
bool
prompt "Enable an extra toolchain target architecture" if TOOLCHAINOPTS
If the toolchain will only be executed on the system where it is built (or a system with the exact same CPU), this will squeeze out the last few (single digit) percent of performance. Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com> --- rules.mk | 2 +- toolchain/Config.in | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)