-
Notifications
You must be signed in to change notification settings - Fork 2.1k
makefiles: cleanup DEFAULT_MODULE, introduce DEFAULT_MODULE_DELAYED #13785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Could you rebase? |
Before DEFAULT_MODULEs where recursiverly added to USEMODULE. This led to undefined behaviour where DEFAULT_MODULEs added in the first iteration through MAKEFILE.dep would end up in USEMODULE but if conditionally added during the recursion they would not be converted to USEMODULE. They are now added through simple expansion so that they are only added once before the parsing of Makefile.dep.
Allow for BOARDs and CPUs to declare DEFAULT_MODULEs that might have dependencies and therefore require being handled before parsing Makefile.dep. DEFAULT_MODULEs declared in %/defaultmodules.inc.mk can only be disabled at application level. In other cases the behaviour is undefined.
Now that auto_init and periph_init modules are added only once, they can be silently disabled in Makefile.dep, with no risk of them being added early to USEMODULE.
Introduce DEFAULT_MODULE_DELAYED for modules that do not have dependencies and therefore can be resolved after Makefile.dep. These modules can be disabled with DISABLE_MODULE during dependency resolution as well as before.
Use DEFAULT_MODULE_DELAYED and remove second inclusion of DEFAULT_MODULEs
0f356be
to
39e5ca2
Compare
Rebased, the PR is no longer waiting. Maybe it makes sense to split the first three commits out of this one? |
These two are causing problems.
I'll need to figure those out.. |
I was thinking if instead of naming it And I think that those should be part of the recursion to allow them to have dependencies themselves. I guess if we forbid this, it is only a matter of time someone can present a use case for an optional module which has dependencies on its own. But in order to prevent this from introducing subtle issues depending on the position in I'm not sure how much overhead this adds. But that approach seems to be rock-solid. If the overhead of this would be too much, I think it would be worth the overhead. |
I think that would work as long as there are no negative dependencies. None of these modules could
And
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
This PR attempts to cleanup, limits and documents the use of
DEFAULT_MODULE
andDISABLE_MODULE
. It is the result of findings in #13651, as well as as findings and discussion while reviewing #13349.(a) This PR includes
DEFAULT_MODULE
s only once to avoid undefined behavior whereDEFAULT_MODULES
added during the first dependency resolution iteration would be converted toUSEMODULE
and others wouldn't. If aBOARD
orCPU
needs aDEFAULT_MODULE
added before dependency resolution it may add it to a$(RIOTCPU)/$(CPU)/defaultmodules.inc.mk
file.DEFAULT_MODULE
s added here can have dependencies, as they are resolved before dependency resolution (although there is currently no use case for this). This also means they can only be disabled in a declarative way (noifneq
) by anAPPLICATION
,CPU
orBOARD
.This means that current handling ofNow removedstdio_%
is not allowed, but we keep it as is until another solution is proposed.The case where a
DEFAULT_MODULE
needs conditional disabling will be unsupported, and with no intentions to support through this mechanism.(b) Any
DEFAULT_MODULE
added in aMakefile.dep
will only be added at the end of dependency resolution process. They MAY not have any dependencies as they will never be converted during resolution. This Modules MAY be DISABLED at any time, since they are only resolved once at the end of dependency resolution.This PR also introduces a new
DEFAULT_MODULE_DELAYED
. This variable allows making a difference between the two cases mentioned above.DEFAULT_MODULE
is used for (a) and the newDEFAULT_MODULE_DELAYED
for (b).Adding the new variable allows to document the expected properties of that module. It would make it easier to add static checks verifying allowed behaviors easier. But if deemed unnecessary the last two commits adding and using
DEFAULT_MODULE_DELAYED
could be removed. I could also split that change as well as theauto_init
/periph_init
change.Here is a debrief of the changes commit by commit.
converts
DEFAULT_MODULE
toUSEMODULE
only before and after dependency resolution. This avoid undefined behaviour where depending on order on inclusion some modules would be added asUSEMODULE
during dependency resolution and others wouldn't.DEFAULT_MODULE
atBOARD
andCPU
level, this wants to get ready for whenDEFAULT_MODULE
addition is limitedauto_init
andperiph_init
module disabling. Removes application wildcard disable.DEFAULT_MODULE_DELAYED
variable and all required modifications to support it.DEFAULT_MODULE
not indefaultmodules.in.mk
byDEFAULT_MODULE_DELAYED
TODO (as follow-ups):
build-system-basics
stdio_%
special handlingTo not conflict with #13349 this PR is based on it, although the changes and objectives are orthogonal.Therefore this PR is reviewed better commit by commit, to not mix the changes in #13349.
I'll rebase as soon as possible to remove those.rebasedTesting procedure
green murdock
save_all_dependencies
should be ran but there will be many differences because of variable change. I would suggest removing 1ea4fc4 to reduce noise. There should not be any difference with regard toUSEMODULE
s, differences should show up only inDEFAULT_MODULE
andDEFAULT_MODULE_DELAYED
feedback on naming for
DEFAULT_MODULE_DELAYED
all
periph_init_%
andauto_init_%
modules are still present and can be removed:BOARD=nucleo-l152re make -C tests/xtimer_usleep/ info-debug-variable-USEMODULE --no-print-directory
DISABLE_MODULE="periph_init_gpio auto_init" BOARD=nucleo-l152re make -C tests/xtimer_usleep/ info-debug-variable-USEMODULE --no-print-directory
Issues/PRs references
Addresses part of #13651, will be finished when TODO list is completed.