Skip to content
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

makefiles: add FEATURES_OPTIONAL_ANY #15855

Closed
wants to merge 3 commits into from

Conversation

fjmolinas
Copy link
Contributor

Contribution description

From looking at #15836 and #15817, it's clear that some dependencies are better modeled in Kconfig with choices. This PR looks to give a similar option to model this behavior in make while the migration is ongoing.

So similar to #13349:

  • FEATURES_OPTIONAL_ALT are nice to have FEATURES that fulfill a similar
    function. Alternatives are separated by a pipe (|) in order of preference,
    e.g.: FEATURES_OPTIONAL_ALT += puf_sram|periph_hwrng if both are provided
    then only puf_sram will be used.

Testing procedure

#12166 Shows a test case for this (I want to rebase that one on top of #15836 and this one)

The save_all_dependencies script should have the same output as before, as this PR does not make use of the feature.

Issues/PRs references

Taken from #12166
Related to #15836

@fjmolinas fjmolinas added Area: build system Area: Build system Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Jan 26, 2021
@fjmolinas fjmolinas added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 2, 2021
Comment on lines 32 to 45
# Additionally optional features due to the "one out of" dependencies,
# For each features list in $(FEATURES_OPTIONAL_ALT):
# ==> If one (or more) features is usable select the first one in list
# ==> If no feature is usable return the list
FEATURES_OPTIONAL_ONE_OUT_OF := $(call _features_one_out_of,\
$(FEATURES_OPTIONAL_ALT),\
$(FEATURES_OPTIONAL) \
$(FEATURES_USABLE))

FEATURES_OPTIONAL_ONLY := $(sort $(filter-out $(FEATURES_REQUIRED),\
$(FEATURES_OPTIONAL) \
$(FEATURES_OPTIONAL_ONE_OUT_OF)))
FEATURES_OPTIONAL_USED := $(sort $(filter $(FEATURES_PROVIDED), \
$(FEATURES_OPTIONAL_ONLY)))
Copy link
Contributor Author

@fjmolinas fjmolinas Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a comment from @leandrolanzieri offline, this should probably be:

Suggested change
# Additionally optional features due to the "one out of" dependencies,
# For each features list in $(FEATURES_OPTIONAL_ALT):
# ==> If one (or more) features is usable select the first one in list
# ==> If no feature is usable return the list
FEATURES_OPTIONAL_ONE_OUT_OF := $(call _features_one_out_of,\
$(FEATURES_OPTIONAL_ALT),\
$(FEATURES_OPTIONAL) \
$(FEATURES_USABLE))
FEATURES_OPTIONAL_ONLY := $(sort $(filter-out $(FEATURES_REQUIRED),\
$(FEATURES_OPTIONAL) \
$(FEATURES_OPTIONAL_ONE_OUT_OF)))
FEATURES_OPTIONAL_USED := $(sort $(filter $(FEATURES_PROVIDED), \
$(FEATURES_OPTIONAL_ONLY)))
# FEATURES_OPTIONAL that have not been required
FEATURES_OPTIONAL_ONLY_SO_FAR := $(sort $(filter-out $(FEATURES_REQUIRED),\
$(FEATURES_OPTIONAL)))
# Only add FEATURES that are usable
FEATURES_OPTIONAL_USED_SO_FAR := $(sort $(filter $(FEATURES_USABLE) \
$(FEATURES_OPTIONAL_ONLY_SO_FAR)))
# Additionally optional features due to the "one out of" dependencies,
# For each features list in $(FEATURES_OPTIONAL_ALT):
# ==> If one (or more) features is already added to OPTIONAL_USED
then the firs of the used ones is returned
# ==> If one (or more) features is usable select the first one in list
# ==> If no feature is usable return the list
FEATURES_OPTIONAL_ONE_OUT_OF := $(call _features_one_out_of,\
$(FEATURES_OPTIONAL_ALT),\
$(FEATURES_OPTIONAL_USED_SO_FAR) \
$(FEATURES_USABLE))
# FEATURES_OPTIONAL that have not been required
FEATURES_OPTIONAL_ONLY := $(sort $(filter-out $(FEATURES_REQUIRED),\
$(FEATURES_OPTIONAL_ONE_OUT_OF)))
# Only add FEATURES that are usable
FEATURES_OPTIONAL_USED := $(sort $(filter $(FEATURES_USABLE) \
$(FEATURES_OPTIONAL_ONLY )))

This way do not add to FEATURES_OPTIONAL_USED non-usable features, and do not add with the FEATURES_OPTIONAL_ALT a feature that will be added bt the OPTIONAL mechanism. In other words:

FEATURES_OPTIONAL has precedence over FEATURES_OPTIONAL_ALT

Copy link
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quickly tried this on the hello-world example (samr21-xpro), and I am not getting the expected result, the last feature of the list is selected. Am I using it wrongly?

Normal used features
arch_32bit
arch_arm
cpu_core_cortexm
no_idle_thread
periph_gpio
periph_pm
periph_uart

After adding FEATURES_OPTIONAL_ALT += periph_cpuid|periph_timer|periph_i2c to the application Makefile:

New used features
arch_32bit
arch_arm
cpu_core_cortexm
no_idle_thread
periph_gpio
periph_i2c
periph_pm
periph_uart

@fjmolinas
Copy link
Contributor Author

@leandrolanzieri I addressed the issue you pointed out in the first fixup e148d7b, the comment I inlined is addressed in 6c9983b

FEATURES_OPTIONAL_ALT="periph_cpuid|periph_timer|periph_pwm" make -C examples/hello-world/ info-modules
auto_init
board
core
core_idle_thread
core_init
core_msg
core_panic
cpu
native_drivers
periph
periph_common
periph_cpuid
periph_gpio
periph_gpio_linux
periph_init
periph_init_cpuid
periph_init_gpio
periph_init_gpio_linux
periph_init_pm
periph_init_uart
periph_pm
periph_uart
stdio_native
sys

@fjmolinas
Copy link
Contributor Author

Note that in master the issue you pointed out was also present:

FEATURES_REQUIRED_ANY="periph_cpuid|periph_timer|periph_pwm" make -C examples/hello-world/ info-modules
auto_init
board
core
core_idle_thread
core_init
core_msg
core_panic
cpu
native_drivers
periph
periph_common
periph_gpio
periph_gpio_linux
periph_init
periph_init_gpio
periph_init_gpio_linux
periph_init_pm
periph_init_timer
periph_init_uart
periph_pm
periph_timer
periph_uart
stdio_native
sys

@fjmolinas
Copy link
Contributor Author

Note that in master the issue you pointed out was also present:

So nice catch!

Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. I wonder if we shouldn't name it FEATURES_OPTIONAL_ANY for consistency. Otherwise the relation to FEATURES_REQUIRED_ANY is IMO less obvious.

doc/doxygen/src/build-system-basics.md Outdated Show resolved Hide resolved
@maribu maribu added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Feb 9, 2021
@maribu maribu changed the title makefiles: add FEATURES_OPTIONAL_ALT makefiles: add FEATURES_OPTIONAL_ANY Feb 9, 2021
@maribu
Copy link
Member

maribu commented Feb 9, 2021

Please squash :-) (Also note that commit message needs updating.)

@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 9, 2021
@maribu maribu added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Feb 9, 2021
@maribu
Copy link
Member

maribu commented Feb 9, 2021

Wait, I found an issue:

FEATURES_OPTIONAL_ANY="periph_i2c|periph_gpio" BOARD=samr21-xpro make info-modules -C examples/
hello-world/
[...]
periph_gpio
periph_i2c
[...]

The periph_i2c shoudln't be pulled in. Same issue with FEATURES_REQUIRED_ANY. It does work as expected with FEATURES_REQUIRED_ANY in master.

@maribu maribu removed the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Feb 9, 2021
@aabadie
Copy link
Contributor

aabadie commented Feb 9, 2021

I think there's an issue with this PR: the number of jobs on Murdock is suspiciously low. The total run took 20 minutes, compared to the others, some applications are not built anymore.

compile job results (0 failed, 27546 passed, 27546 total)

Nowadays, there +80k jobs on Murdock.

@fjmolinas
Copy link
Contributor Author

I think there's an issue with this PR: the number of jobs on Murdock is suspiciously low. The total run took 20 minutes, compared to the others, some applications are not built anymore.

compile job results (0 failed, 27546 passed, 27546 total)

Nowadays, there +80k jobs on Murdock.

Indeed that is strange, I'll take a look.

@fjmolinas
Copy link
Contributor Author

Hmm In Murdock I see that some jobs did not get built for a bunch of BOARDs, tests/saul does not get built for any Nucleo. But the info-board-supported output matches what is expected. Might it have something to do with the fact that a conflict showed up during the build? I'll rebase and run the dependencies script in any case.

FEATURES_OPTIONAL_ANY are nice to have FEATURES that fulfill a similar
function. Alternatives are separated by a pipe (|) in order of
preference.

e.g.: FEATURES_OPTIONAL_ANY += puf_sram|periph_hwrng if both are
provided then only puf_sram will be used.
@fjmolinas fjmolinas removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 9, 2021
@fjmolinas
Copy link
Contributor Author

After all these bugs were uncovered with the any algorithm I've realized that to implement this some question would need answering first;

In what order should a FEATURES_OPTIONAL_ANY feature be resolved:

  • e.g.: if there is an overlap with FEATURES_REQUIRED_ANY I would expect only the overlap to be selected, but that means resolving OPTIONAL_ANY after REQUIRED_ANY.

But since the dependency process is iterative there are no guarantees of this anyway. So I think this is going to become messy very fast, any I'm not sure its worth the effort anymore. I'll still try to take a look at how it would look as soon as I have some time, but as I said I'm not sure its worth it.

@maribu
Copy link
Member

maribu commented Feb 22, 2021

I think we should aim for best effort here (that is, after FEATURES_REQUIRED_ANY of the same Iteration). Without access to the full dependency graph, we cannot do much bettee anyway IMO.

@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 22, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@stale
Copy link

stale bot commented Mar 2, 2022

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.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Mar 2, 2022
@stale stale bot closed this Apr 16, 2022
@maribu
Copy link
Member

maribu commented Apr 16, 2022

I kind of assumed that this has already landed. @fjmolinas: Will you reboot this, or is it better to get KConfig finished so that we no longer need this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants