-
Notifications
You must be signed in to change notification settings - Fork 2k
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/feature_precheck: check libc availability prior deciding usage #15993
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks much less scary that I had imagined :-)
makefiles/features_precheck.inc.mk
Outdated
@@ -0,0 +1,17 @@ | |||
# Check if provided features are available | |||
|
|||
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED)) $(filter newlib,$(FEATURES_PROVIDED))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer if can be dropped, can't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it can (i wanted to avoid the rest of the check if not nesecary but the shell checks a only done if the feature is provided).
I will remove it
makefiles/features_precheck.inc.mk
Outdated
# Check if provided features are available | ||
|
||
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED)) $(filter newlib,$(FEATURES_PROVIDED))) | ||
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to white-list this file in dist/tools/buildsystem_sanity_check/check.sh:75
. Please also update the comment in the line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to white-list this file in
dist/tools/buildsystem_sanity_check/check.sh:75
. Please also update the comment in the line above.
Huh? This completely bypasses the intention of the check...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this was added when FEAUTES_OPTIONAL
was added to replace the paddern
ifneq (,$(filter foo,$(FEAUTRES_PROVIDES)))
USEMODULE += optional_submodule
endif
The intention was to enforce the use of FEATURES_OPTIONAL
instead. But this here is unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this was added when
FEAUTES_OPTIONAL
was added to replace the paddernifneq (,$(filter foo,$(FEAUTRES_PROVIDES))) USEMODULE += optional_submodule endifThe intention was to enforce the use of
FEATURES_OPTIONAL
instead. But this here is unrelated.
I'm not sure I understand, FEATURES_OPTIONAL
should not be checked either, only FEATURES_USED
. The buildsystem check is there so that there are no conditionals against FEATURES_OPTIONAL
, FEATURES_PROVIDED
, FETURES_REQUIRED
, see original or #10179 and
RIOT/dist/tools/buildsystem_sanity_check/check.sh
Lines 56 to 75 in 3a9f8d5
# Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL | |
# Handling specific behaviors/dependencies should by checking the content of: | |
# * `USEMODULE` | |
# * maybe `FEATURES_USED` if it is not a module (== not a periph_) | |
check_not_parsing_features() { | |
local patterns=() | |
local pathspec=() | |
patterns+=(-e 'if.*filter.*FEATURES_PROVIDED') | |
patterns+=(-e 'if.*filter.*FEATURES_REQUIRED') | |
patterns+=(-e 'if.*filter.*FEATURES_OPTIONAL') | |
# Pathspec with exclude should start by an inclusive pathspec in git 2.7.4 | |
pathspec+=('*') | |
# Ignore this file when matching as it self matches | |
pathspec+=(":!${SCRIPT_PATH}") | |
# These two files contain sanity checks using FEATURES_ so are allowed | |
pathspec+=(':!Makefile.include' ':!makefiles/info-global.inc.mk') |
makefiles/features_precheck.inc.mk
Outdated
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED))) | ||
# Test if picolibc.specs is available | ||
ifneq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
FEATURES_PROVIDED := $(filter-out picolibc,$(FEATURES_PROVIDED)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just use FEATURES_BLACKLIST
? That way it would be more obvious that the feature is not provided due to the setup, rather than due to missing upstream support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seem reasonable i test if it keeps working and change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BLACKLISTING does not work as intended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as i just saw you also fixed the Blacklist problem i had in #15973
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NACK, didn't look at the other changes yet, but I'm against moving the include order.
# Include Board and CPU configuration | ||
INCLUDES += $(addprefix -I,$(wildcard $(BOARDDIR)/include)) | ||
include $(BOARDDIR)/Makefile.include | ||
INCLUDES += -I$(RIOTCPU)/$(CPU)/include | ||
include $(RIOTCPU)/$(CPU)/Makefile.include | ||
|
||
# Import all toolchain settings | ||
include $(RIOTMAKE)/toolchain/$(TOOLCHAIN).inc.mk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reverting a long effort of changing the order of inclusion: #9913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also have a error message telling the user that he has to blacklist the provided but not exiting toolchain that the dependency solver prefered for a reason unknown to the user (maybe it was listed first somewhere, or it is alphanumerical first)
makefiles/features_precheck.inc.mk
Outdated
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED))) | ||
# Test if picolibc.specs is available | ||
ifneq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
FEATURES_PROVIDED := $(filter-out picolibc,$(FEATURES_PROVIDED)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not declarative, FEATURES so far are declarative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think: I fixed that with blacklisting as @maribu suggested
@kfessel can you explain the reasoning for this change better? |
@@ -413,8 +421,6 @@ endif | |||
# Assume GCC/GNU as supported toolchain if CPU's Makefile.include doesn't | |||
# provide this macro | |||
TOOLCHAINS_SUPPORTED ?= gnu | |||
# Import all toolchain settings | |||
include $(RIOTMAKE)/toolchain/$(TOOLCHAIN).inc.mk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this is the only thing that needs to be moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we need access to the specific toolchain therefore the cpu prefix definition has to move up
(can't ask x86 gcc if picolibc for arm is available)
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED))) | ||
# Test if picolibc.specs is available | ||
ifneq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
FEATURES_BLACKLIST += picolibc | ||
endif | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a need to check if the FEATURE is provided? Can't you simply blacklist if not present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you guessed it is to avoid the shell call, if not need, and why should we auto blacklist something no one is talking about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I mean BTW:
Lines 176 to 179 in a5b9136
# UNAME is always needed so use simple variable expansion so only evaluated once | |
UNAME := $(shell uname -m -s) | |
OS = $(word 1, $(UNAME)) | |
OS_ARCH = $(word 2, $(UNAME)) |
picolibc
most of the time anyway, we will want to call this at least once.
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED))) | ||
# Test if picolibc.specs is available | ||
ifneq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
FEATURES_BLACKLIST += picolibc | ||
endif | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifneq (,$(filter picolibc,$(FEATURES_PROVIDED))) | |
# Test if picolibc.specs is available | |
ifneq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | |
FEATURES_BLACKLIST += picolibc | |
endif | |
endif | |
# Test if picolibc.specs is available | |
ifneq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | |
FEATURES_BLACKLIST += picolibc | |
endif |
Is it as it is now to avoid the shell call? In that case, I would assign it to a variable once and the check that variable, similar to what is done with OS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should but i do not see a huge performance penalty atm.
I will have a look at OS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this can be used to opportunistically enable picolibc and fall back to newlib if it's not installed?
Shouldn't the first step be testing it as the default libc in the ci?
will rebase to solve for conflicting change in master |
1d9b00b
to
94bb72d
Compare
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. |
So this can be used to opportunistically enable picolibc and fall back to newlib if it's not installed? |
yes this was the intention the stall:bot is digging deep :nice: without picolibc-arm... on the system:
since #16008 got merged is at least failing loud providing a kinda fix with this PR it would just fallback to use newlibc |
Can you give it a rebase? |
My change requests still stand here. |
Thinking about this again I'm still against it, if we change to have If we move to Features so far are all declarative, I do not see the need to change because of |
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. |
94bb72d
to
29d5dfe
Compare
Contribution description
Add a feature pre-check for picolibc and newlibc into the make process
Testing procedure
make things with either having or not having picolibc or newlib installed
Issues/PRs references
Fixes #15325
@maribu , @nmeum , @benpicco : might what to have a look at it