package/pkg-kconfig: fix bad config with per-package-dirs
PATCH 1/1 package/pkg-kconfig: fix bad config with per-package-dirs
If BR2_PER_PACKAGE_DIRECTORIES is enabled and Buildroot is using HOST_MAKE for a Kconfig package. The $(1)_KCONFIG_RULES does not work correctly, and kconfig-package-regen-dot-config will always run the 'oldconfig' target.
This is because $(1)_KCONFIG_RULES expands before the first recipe line of .stamp_dotconfig. $(1)_KCONFIG_RULES attempts to call $(HOST_MAKE), which requires that the per-package/<pkg>/host directory has been setup. But that directory is not setup until a later recipe line. This results in $(1)_KCONFIG_RULES silently failing, and so always configuring with 'oldconfig'.
Fix the issue by calling the command as part of the recipe, so $(HOST_MAKE) will be ready in time. As the comment on $(1)_KCONFIG_RULES describes, we should not use backticks. Use an intermediary file to store the output of the command, so that backticks are not needed.
--- package/pkg-kconfig.mk | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
package/pkg-kconfig.mk +10 -18
@@ -45,11 +45,16 @@ endef # only, as this can fail in complex cases. # $(1): the name of the package in upper-case letters define kconfig-package-regen-dot-config - $(if $(filter olddefconfig,$($(1)_KCONFIG_RULES)), - $(Q)$($(1)_KCONFIG_MAKE) olddefconfig, - $(if $(filter oldnoconfig,$($(1)_KCONFIG_RULES)), - $(Q)$($(1)_KCONFIG_MAKE) oldnoconfig, - $(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig))) + $(Q)[ -e $($(1)_DIR)/.br_regen_dot_config ] || \ + $($(1)_KCONFIG_MAKE) -pn config 2>/dev/null \ + | sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d' >$($(1)_DIR)/.br_regen_dot_config + $(Q)if grep -q '\bolddefconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \ + $($(1)_KCONFIG_MAKE) olddefconfig; \ + elif grep -q '\boldnoconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \ + $($(1)_KCONFIG_MAKE) oldnoconfig; \ + else \ + yes "" | $($(1)_KCONFIG_MAKE) oldconfig; \ + fi endef # Macro to create a .config file where all given fragments are merged into.
@@ -147,19 +152,6 @@ $(2)_KCONFIG_MAKE = \ $$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \ $$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS) -# $(2)_KCONFIG_MAKE may already rely on shell expansion. As the $() syntax -# of the shell conflicts with Make's own syntax, this means that backticks -# are used with those shell constructs. Unfortunately, the backtick syntax -# does not nest, and we need to use Make instead of the shell to handle -# conditions. - -# A recursively expanded variable is necessary, to be sure that the shell -# command is called when the rule is processed during the build and not -# when the rule is created when parsing all packages. -$(2)_KCONFIG_RULES = \ - $$(shell $$($(2)_KCONFIG_MAKE) -pn config 2>/dev/null | \ - sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d') - # The specified source configuration file and any additional configuration file # fragments are merged together to .config, after the package has been patched. # Since the file could be a defconfig file it needs to be expanded to a
Signature · 6 lines
2.38.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 12 lines · Brandon Maier via buildroot
If
BR2_PER_PACKAGE_DIRECTORIESis enabled and Buildroot is usingHOST_MAKEfor aKconfigpackage. The $(1)_KCONFIG_RULES does not work correctly, and kconfig-package-regen-dot-config will always run the 'oldconfig' target.This is because $(1)_KCONFIG_RULES expands before the first recipe line of .stamp_dotconfig. $(1)_KCONFIG_RULES attempts to call $(HOST_MAKE), which requires that the per-package/<pkg>/host directory has been setup. But that directory is not setup until a later recipe line. This results in $(1)_KCONFIG_RULES silently failing, and so always configuring with 'oldconfig'.
Quoted 6 lines
Fix the issue by calling the command as part of the recipe, so $(HOST_MAKE) will be ready in time. As the comment on $(1)_KCONFIG_RULES describes, we should not use backticks. Use an intermediary file to store the output of the command, so that backticks are not needed.
Signed-off-by Brandon Maier <[email protected]>
Although this is a fix (normally for master), it's not a regression and the
issue has been there for years already. In addition, it's not something that is very well tested, so it's a risky change. Therefore, I applied to next, thanks.
Regards,
Arnout
Quoted 40 lines
--- package/pkg-kconfig.mk | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)package/pkg-kconfig.mk +10
-11@@ -45,11 +45,16 @@ endef # only, as this can fail in complex cases. # $(1): the name of the package in upper-case letters define kconfig-package-regen-dot-config - $(if $(filter olddefconfig,$($(1)_KCONFIG_RULES)), - $(Q)$($(1)_KCONFIG_MAKE) olddefconfig, - $(if $(filter oldnoconfig,$($(1)_KCONFIG_RULES)), - $(Q)$($(1)_KCONFIG_MAKE) oldnoconfig, - $(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig))) + $(Q)[ -e $($(1)_DIR)/.br_regen_dot_config ] || \ + $($(1)_KCONFIG_MAKE) -pn config 2>/dev/null \ + | sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d' >$($(1)_DIR)/.br_regen_dot_config + $(Q)if grep -q '\bolddefconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \ + $($(1)_KCONFIG_MAKE) olddefconfig; \ + elif grep -q '\boldnoconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \ + $($(1)_KCONFIG_MAKE) oldnoconfig; \ + else \ + yes "" | $($(1)_KCONFIG_MAKE) oldconfig; \ + fi endef # Macro to create a .config file where all given fragments are merged into.@@ -147,19 +152,6 @@ $(2)_KCONFIG_MAKE = \ $$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \ $$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS) -# $(2)_KCONFIG_MAKE may already rely on shell expansion. As the $() syntax -# of the shell conflicts with Make's own syntax, this means that backticks -# are used with those shell constructs. Unfortunately, the backtick syntax -# does not nest, and we need to use Make instead of the shell to handle -# conditions. -
package/pkg-kconfig.mk $(2)_KCONFIG_MAKE = \ · line 157
Quoted 10 lines
package/pkg-kconfig.mk +0
-7-# A recursively expanded variable is necessary, to be sure that the shell -# command is called when the rule is processed during the build and not -# when the rule is created when parsing all packages. -$(2)_KCONFIG_RULES = \ - $$(shell $$($(2)_KCONFIG_MAKE) -pn config 2>/dev/null | \ - sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d') - # The specified source configuration file and any additional configuration file # fragments are merged together to .config, after the package has been patched. # Since the file could be a defconfig file it needs to be expanded to a
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot