rules.mk: respect the empty CONFIG_HOST_FLAGS_OPT

Currently, the empty CONFIG_HOST_FLAGS_OPT will be overridden by
"-O2". Fix this issue by checking if its parent menuconfig symbol
CONFIG_OPTIMIZE_HOST_TOOLS was defined.

Fixes: e3bec5692c ("rules.mk: set default host tools GCC optimization level to -O2")
Reported-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Link: https://github.com/openwrt/openwrt/pull/18815
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Shiji Yang 2025-05-16 19:30:30 +08:00 committed by Robert Marko
parent f060615a78
commit 17eeb6c3fa
1 changed files with 1 additions and 1 deletions

View File

@ -278,7 +278,7 @@ PKG_CONFIG:=$(STAGING_DIR_HOST)/bin/pkg-config
export PKG_CONFIG
HOST_FLAGS_OPT:=$(if $(CONFIG_HOST_FLAGS_OPT),$(call qstrip,$(CONFIG_HOST_FLAGS_OPT)),"-O2")
HOST_FLAGS_OPT:=$(if $(CONFIG_OPTIMIZE_HOST_TOOLS),$(call qstrip,$(CONFIG_HOST_FLAGS_OPT)),-O2)
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))