Detect incorrect dependencies
v5 cover Detect incorrect dependencies
Hello,
This is the fifth version of the small patch series to detect incorrect dependencies (i.e a package that depends on another in its .mk file, but that forgets to do so in its Config.in).
Compared to the previous version, this new version:
- Use $($(PKG)_TYPE) and $($(PKG)_KCONFIG)_VAR) instead of target-specific variables, as suggested by Arnout.
- Move the "culprit listing" logic into a separate patch, so that it can be considered separately, suggested by Yann E. Morin.
- Makes some other trivial adjustements suggested by Yann and Arnout.
- Is rebased on top of master.
Thanks,
Thomas
Thomas Petazzoni (2):
pkg-generic: detect incorrectly used package
pkg-generic: improve incorrectly used package detection
package/pkg-generic.mk | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Signature · 1 line
2.6.1
PATCH v5 1/2 pkg-generic: detect incorrectly used package
In Buildroot, the selection of a package from a Config.in level and from a Makefile level are completely disconnected. This can lead to issues where the build of a package is triggered at the Makefile level due to the package being listed in another package <pkg>_DEPENDENCIES variable, even if that package is not enabled in the configuration.
This has for example been the case recently with python-can having 'python' in its <pkg>_DEPENDENCIES, while python-can could be enabled when Python 3.x is used, in which case the 'python' package should not be built.
To detect such issues more easily, this patch adds a check in the package infrastructure. When the build process of a package is being triggered, we verify that the package is enabled in the configuration. We do this check in the "configure" step, since this step is the first common step between the normal download case and the "local site method" / "package override" case.
---
Changes since v4:
- Use $($(PKG)_KCONFIG_VAR) and $($(PKG)_TYPE) as suggested by Arnout.
- Split the "potential culprit" mechanism into a separate commit, as suggested by Yann.
Changes since v3:
- Add the DEPENDENT_OF mechanism to display which packages are mistakenly depending on a package without selecting it. Suggested and implement by Yann E. Morin.
Changes since v2:
- Only do the check if MAKECMDGOALS is empty, i.e if a "default" build is being done. This allows advanced users to continue doing "make <pkg>" to forcefully build a package even if not enabled in the configuration. Suggested by Peter Korsgaard.
- Add @ in front of the test command so that it doesn't get displayed. Suggested by Peter Korsgaard.
- Improve error message, as suggested by Peter Korsgaard.
Changes since v1:
- Use KCONFIG_VAR in order to make the thing work for toolchain packages, bootloaders and Linux. Issue reported by Vicente.
--- package/pkg-generic.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)
package/pkg-generic.mk +10 -0
@@ -143,6 +143,16 @@ $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\ # Configure $(BUILD_DIR)/%/.stamp_configured: +# Only trigger the check for default builds. If the user forces +# building a package, even if not enabled in the configuration, we +# want to accept it. +ifeq ($(MAKECMDGOALS),) + @if test "$($(PKG)_TYPE)" = "target" -a -z "$($($(PKG)_KCONFIG_VAR))" ; then \ + echo "ERROR: A package must have added $($(PKG)_NAME) to its _DEPENDENCIES line but" ; \ + echo "forgot to add the corresponding select / depends on $($(PKG)_KCONFIG_VAR)." ; \ + exit 1 ; \ + fi +endif @$(call step_start,configure) @$(call MESSAGE,"Configuring") $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
Signature · 1 line
2.6.1
PATCH v5 1/2 pkg-generic: detect incorrectly used package
Thomas, All,
On 2015-10-09 11:15 +0200, Thomas Petazzoni spake thusly:
Quoted 18 lines
In Buildroot, the selection of a package from a Config.in level and from a
Makefilelevel are completely disconnected. This can lead to issues where the build of a package is triggered at theMakefilelevel due to the package being listed in another package <pkg>_DEPENDENCIES variable, even if that package is not enabled in the configuration.This has for example been the case recently with python-can having 'python' in its <pkg>_DEPENDENCIES, while python-can could be enabled when Python 3.x is used, in which case the 'python' package should not be built.
To detect such issues more easily, this patch adds a check in the package infrastructure. When the build process of a package is being triggered, we verify that the package is enabled in the configuration. We do this check in the "configure" step, since this step is the first common step between the normal download case and the "local site method" / "package override" case.
Quoted 2 lines
Signed-off-by Thomas Petazzoni <[email protected]>---
[--SNIP--]
Quoted 5 lines
package/pkg-generic.mk +0
-0
package/pkg-generic.mk $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\ · line 151
Quoted 9 lines
package/pkg-generic.mk +6
-0@@ -143,6 +143,16 @@ $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\ # Configure $(BUILD_DIR)/%/.stamp_configured: +# Only trigger the check for default builds. If the user forces +# building a package, even if not enabled in the configuration, we +# want to accept it. +ifeq ($(MAKECMDGOALS),) + @if test "$($(PKG)_TYPE)" = "target" -a -z "$($($(PKG)_KCONFIG_VAR))" ; then \ + echo "ERROR: A package must have added $($(PKG)_NAME) to its _DEPENDENCIES line but" ; \
As I reported in the second patch of this series, the package being build might second-or-deeper in the dependency chain.
So, if we have the existing _correct_ dependencies:
foo -> bar
bar -> buz
buz -> daz
and we then add an incorrect dependency;
alpha -> foo
then the build order guranatees that daz is built first, and the we report that something is incorrectly selecting daz, while the reall issue is that something is incorrectly selecting foo.
So, we'd probably need to state something like:
ERROR: $(1) is in the dependency chain of a package that has added it to is _DEPENDENCIES line (directly or indirectly) without selecting it from Config.in.
I'm not too happy with that phrasing, because it is still obscur for a new-comer. But we would instantly recognise the pattern and it would be relatively easy to spot the real culprit.
Thoughts?
Regards,
Yann E. MORIN.
Quoted 14 lines
package/pkg-generic.mk +4
-0+ echo "forgot to add the corresponding select / depends on $($(PKG)_KCONFIG_VAR)." ; \ + exit 1 ; \ + fi +endif @$(call step_start,configure) @$(call MESSAGE,"Configuring") $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))Signature · 6 lines
2.6.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v5 1/2 pkg-generic: detect incorrectly used package
In reply to Thomas PetazzoniHello,
Quoted 18 lines · Thomas Petazzoni
In Buildroot, the selection of a package from a Config.in level and from a
Makefilelevel are completely disconnected. This can lead to issues where the build of a package is triggered at theMakefilelevel due to the package being listed in another package <pkg>_DEPENDENCIES variable, even if that package is not enabled in the configuration.This has for example been the case recently with python-can having 'python' in its <pkg>_DEPENDENCIES, while python-can could be enabled when Python 3.x is used, in which case the 'python' package should not be built.
To detect such issues more easily, this patch adds a check in the package infrastructure. When the build process of a package is being triggered, we verify that the package is enabled in the configuration. We do this check in the "configure" step, since this step is the first common step between the normal download case and the "local site method" / "package override" case.
Quoted 6 lines
Signed-off-by Thomas Petazzoni <[email protected]>---
Changes since v4:
- Use $($(PKG)_KCONFIG_VAR) and $($(PKG)_TYPE) as suggested by Arnout.
- Split the "potential culprit" mechanism into a separate commit, as suggested by Yann.
I've applied, after taking into account the comment from Yann (and fixing a minor issue with it: $(1) cannot be used, it should have been $($(PKG)_NAME)).
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v5 2/2 pkg-generic: improve incorrectly used package detection
In reply to Thomas PetazzoniThe package infrastructure now detects when a target package is being built even if its corresponding Config.in option is not enabled, and aborts with an error. However, it does not indicate *which* package is improperly depending on the current package without selecting it at the kconfig level.
So, in this commit, in addition to displaying an error, we try to help the user by saying which packages could be the culprit. To achieve this, we register the reverse dependencies of each package in a variable called <pkg>_DEPENDENT_OF, and display this variable for the problematic package when the error is detected. Many thanks to Yann E. Morin for the idea and implementation!
--- package/pkg-generic.mk | 8 ++++++++ 1 file changed, 8 insertions(+)
package/pkg-generic.mk +8 -0
@@ -150,6 +150,8 @@ ifeq ($(MAKECMDGOALS),) @if test "$($(PKG)_TYPE)" = "target" -a -z "$($($(PKG)_KCONFIG_VAR))" ; then \ echo "ERROR: A package must have added $($(PKG)_NAME) to its _DEPENDENCIES line but" ; \ echo "forgot to add the corresponding select / depends on $($(PKG)_KCONFIG_VAR)." ; \ + echo "Potential culprits:" ; \ + for p in $($(PKG)_DEPENDENT_OF) ; do echo " - $$p" ; done ; \ exit 1 ; \ fi endif
@@ -777,6 +779,12 @@ endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),) # configuration ifeq ($$($$($(2)_KCONFIG_VAR)),y) +# Store reverse build-dependency information: we add the name of the +# current package to the <pkg>_DEPENDENT_OF variable of all packages +# the current package depends on. +$$(eval $$(foreach d,$$($(2)_FINAL_ALL_DEPENDENCIES),\ + $$(call UPPERCASE,$$(d))_DEPENDENT_OF += $(1)$$(sep))) + # Ensure the calling package is the declared provider for all the virtual # packages it claims to be an implementation of. ifneq ($$($(2)_PROVIDES),)
Signature · 1 line
2.6.1
PATCH v5 2/2 pkg-generic: improve incorrectly used package detection
Thomas, All,
On 2015-10-09 11:15 +0200, Thomas Petazzoni spake thusly:
Quoted 23 lines
The package infrastructure now detects when a target package is being built even if its corresponding Config.in option is not enabled, and aborts with an error. However, it does not indicate *which* package is improperly depending on the current package without selecting it at the kconfig level.
So, in this commit, in addition to displaying an error, we try to help the user by saying which packages could be the culprit. To achieve this, we register the reverse dependencies of each package in a variable called <pkg>_DEPENDENT_OF, and display this variable for the problematic package when the error is detected. Many thanks to Yann E. Morin for the idea and implementation!
Signed-off-by Thomas Petazzoni <[email protected]>--- package/pkg-generic.mk | 8 ++++++++ 1 file changed, 8 insertions(+)package/pkg-generic.mk +0
-0
package/pkg-generic.mk ifeq ($(MAKECMDGOALS),) · line 154
Quoted 5 lines
package/pkg-generic.mk +2
-0@@ -150,6 +150,8 @@ ifeq ($(MAKECMDGOALS),) @if test "$($(PKG)_TYPE)" = "target" -a -z "$($($(PKG)_KCONFIG_VAR))" ; then \ echo "ERROR: A package must have added $($(PKG)_NAME) to its _DEPENDENCIES line but" ; \ echo "forgot to add the corresponding select / depends on $($(PKG)_KCONFIG_VAR)." ; \ + echo "Potential culprits:" ; \ + for p in $($(PKG)_DEPENDENT_OF) ; do echo " - $$p" ; done ; \
This does only work for first-level culprits.
For example, I added;
BUSYBOX_DEPENDENCIES += eximAnd I get:
Quoted 1 line
Quoted 1 line
Quoted 1 line
berkeleydb 5.3.28 Patching libtool
ERROR: A package must have added berkeleydb to its _DEPENDENCIES line but forgot to add the corresponding select / depends on BR2_PACKAGE_BERKELEYDB. Potential culprits:
make[1]: *** [.../berkeleydb-5.3.28/.stamp_configured] Error 1
make: *** [_all] Error 2
That's because the real culprit is not directly the cause of the berkeleydb dependency; the depenency chain is two-or-more levels deep.
So, NAK on this patch (even though that was my idea originally, IIRC).
I'll (later!) to find a solution...
Regards,
Yann E. MORIN.
Quoted 23 lines
package/pkg-generic.mk +6
-0exit 1 ; \ fi endif@@ -777,6 +779,12 @@ endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),) # configuration ifeq ($$($$($(2)_KCONFIG_VAR)),y) +# Store reverse build-dependency information: we add the name of the +# current package to the <pkg>_DEPENDENT_OF variable of all packages +# the current package depends on. +$$(eval $$(foreach d,$$($(2)_FINAL_ALL_DEPENDENCIES),\ + $$(call UPPERCASE,$$(d))_DEPENDENT_OF += $(1)$$(sep))) + # Ensure the calling package is the declared provider for all the virtual # packages it claims to be an implementation of. ifneq ($$($(2)_PROVIDES),)Signature · 6 lines
2.6.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'