diff --git a/config/Config-devel.in b/config/Config-devel.in index cbac91c09da..3fe78f325bc 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -62,6 +62,60 @@ menuconfig DEVEL Compile all host host tools even if not needed. This is needed to prepare a universal precompiled host tools archive to use in another buildroot. + menuconfig OPTIMIZE_HOST_TOOLS + bool "Host Tools compile options" if DEVEL + + if OPTIMIZE_HOST_TOOLS + + config HOST_FLAGS_OPT + string "Host Tools optimization flags" + default "-O2" + help + Compiler flags which are used to build host tools. + + E.g.: "-O2", "-O3 -fno-tree-vectorize". + + Default is "-O2". + + config HOST_TOOLS_STRIP + bool "Strip Host Tools" + help + Instructs compiler/linker to use flags from HOST_FLAGS_STRIP + in order to reduce binary size of host tools. + + config HOST_FLAGS_STRIP + string "Host Tools compiler/linker flags for stripping symbols" + depends on HOST_TOOLS_STRIP + default "-Wl,-s" + help + Compiler flags which are used to strip symbols from host tools. + + Each flag should be prefixed with "-Wl," string + because compiler (GCC) passes this value to linker. + + Default is "-Wl,-s" which means "strip all symbols" - specifically, + debug symbols and other symbols not needed for relocation processing. + + comment "Host Tools miscellaneous flags" + + config HOST_EXTRA_CFLAGS + string "Host Tools extra CFLAGS" + default "" + + config HOST_EXTRA_CXXFLAGS + string "Host Tools extra CXXFLAGS" + default "" + + config HOST_EXTRA_CPPFLAGS + string "Host Tools extra CPPFLAGS" + default "" + + config HOST_EXTRA_LDFLAGS + string "Host Tools extra LDFLAGS" + default "" + + endif + config BUILD_SUFFIX string "Build suffix to append to the target BUILD_DIR variable" if DEVEL default "" diff --git a/rules.mk b/rules.mk index dbc448e1a43..ccf97fe7b7b 100644 --- a/rules.mk +++ b/rules.mk @@ -278,12 +278,19 @@ PKG_CONFIG:=$(STAGING_DIR_HOST)/bin/pkg-config export PKG_CONFIG +HOST_FLAGS_OPT:=$(call qstrip,$(CONFIG_HOST_FLAGS_OPT)) +HOST_FLAGS_STRIP:=$(call qstrip,$(CONFIG_HOST_FLAGS_STRIP)) +HOST_EXTRA_CFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_CFLAGS)) +HOST_EXTRA_CXXFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_CXXFLAGS)) +HOST_EXTRA_CPPFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_CPPFLAGS)) +HOST_EXTRA_LDFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_LDFLAGS)) + HOSTCC:=$(STAGING_DIR_HOST)/bin/gcc HOSTCXX:=$(STAGING_DIR_HOST)/bin/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_CXXFLAGS:=$(HOST_CFLAGS) -HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib) +HOST_CPPFLAGS:=$(strip -I$(STAGING_DIR_HOST)/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include) $(HOST_EXTRA_CPPFLAGS)) +HOST_CFLAGS:=$(strip $(HOST_FLAGS_OPT) $(HOST_EXTRA_CFLAGS) $(HOST_CPPFLAGS) $(HOST_FLAGS_STRIP)) +HOST_CXXFLAGS:=$(strip $(HOST_CFLAGS) $(HOST_EXTRA_CXXFLAGS)) +HOST_LDFLAGS:=$(strip -L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib) $(HOST_EXTRA_LDFLAGS) $(HOST_FLAGS_STRIP)) BUILD_KEY=$(TOPDIR)/key-build BUILD_KEY_APK_SEC=$(TOPDIR)/private-key.pem