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

Allow tests to filter on availability of full C library #54637

Merged
merged 12 commits into from
Apr 27, 2023

Conversation

keith-packard
Copy link
Collaborator

Some tests are filtering on not CONFIG_MINIMAL_LIBC and others on TOOLCHAIN_HAS_NEWLIB || CONFIG_PICOLIBC_SUPPORTED, both of which have issues in correctly identifying the desired targets. Instead, create a new hidden Kconfig value, SUPPORT_FULL_LIBC, which currently depends on NATIVE_APPLICATION || TOOLCHAIN_HAS_NEWLIB.

When picolibc is added as a default in LIBC_IMPLEMENTATION , SUPPORT_FULL_LIBC can be updated which will automagically allow those tests to run using picolibc if available.

lib/libc/Kconfig Outdated Show resolved Hide resolved
@keith-packard keith-packard marked this pull request as draft February 8, 2023 23:50
@keith-packard
Copy link
Collaborator Author

Converted to draft; I don't know how to detect NEWLIB support in Kconfig.

@keith-packard
Copy link
Collaborator Author

Ok, I've added Kconfig symbol NEWLIB_SUPPORTED that parallels PICOLIBC_SUPPORTED. Of course, this requires a patch to sdk-ng as that includes its own Kconfig bits. zephyrproject-rtos/sdk-ng#626

nordicjm
nordicjm previously approved these changes Feb 9, 2023
dcpleung
dcpleung previously approved these changes Feb 9, 2023
galak
galak previously requested changes Feb 9, 2023
Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

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

Would like to see a bit of change to the Kconfig structure.

lib/libc/Kconfig Outdated Show resolved Hide resolved
cmake/toolchain/gnuarmemb/Kconfig Outdated Show resolved Hide resolved
lib/libc/Kconfig Outdated Show resolved Hide resolved
lib/libc/Kconfig Outdated Show resolved Hide resolved
lib/libc/Kconfig Outdated Show resolved Hide resolved
Switch from using a generator expression to computing the value with a
conditional so that it is available during the execution of kconfig instead
of only being available while generating the build script.

Signed-off-by: Keith Packard <[email protected]>
Restructure the file so that the only elements within 'menu "C Library"'
are the library choices.

Signed-off-by: Keith Packard <[email protected]>
Add a prompt to the Kconfig symbol so that applications can select this in
their configuration to guide C library selection away from the minimal C
library.

Signed-off-by: Keith Packard <[email protected]>
Clean up libc-related symbols to use a common pattern.

Signed-off-by: Keith Packard <[email protected]>
This reflects whether newlib is available in the environment. This
symbol should be used in place of TOOLCHAIN_HAS_NEWLIB.

Signed-off-by: Keith Packard <[email protected]>
Label espressif, gnuarmemd and xtools toolchains with newlib support using
the Kconfig variable rather than relying on the TOOLCHAIN_HAS_NEWLIB
value.

Signed-off-by: Keith Packard <[email protected]>
Before allowing newlib to be selected as the C library, ensure that it is
available for the target.

Signed-off-by: Keith Packard <[email protected]>
@keith-packard
Copy link
Collaborator Author

I added one more commit to this PR which will select picolibc as the default C library when a full C library is required and newlib isn't available. Now that crosstool-ng has configurations which provide only picolibc, this will be useful there.

lib/libc/Kconfig Outdated Show resolved Hide resolved
This symbol is selected when the target has any full libc available. This
allows tests to filter on this condition. It doesn't depend on whether the
application actually selects that library, only whether requesting a full C
library would work.

Signed-off-by: Keith Packard <[email protected]>
This symbol detects whether there is any available full libc for a
particular target, allowing tests to filter on this condition.

Signed-off-by: Keith Packard <[email protected]>
When the only C library available is the minimal one, this test cannot
work. Accept only platforms with full C library support to prevent build
failures.

Signed-off-by: Keith Packard <[email protected]>
These tests all require a full C library to run. Replace the condition
checking for either newlib or picolibc with a check for
CONFIG_FULL_LIBC_SUPPORTED instead, then add CONFIG_REQUIRES_FULL_LIBC=y to
ensure a full libc is used.

Signed-off-by: Keith Packard <[email protected]>
Select FULL_LIBC_SUPPORTED when picolibc is available.

Add picolibc as a secondary default C library when REQUIRES_FULL_LIBC is
selected. This is necessary as tests gated on FULL_LIBC_SUPPORTED need to
be sure that a full C library will be selected -- if only picolibc is
available, those tests will need to select that.

This should permit use of a picolibc-only crosstool-ng toolchain in
testing.

Signed-off-by: Keith Packard <[email protected]>
Copy link
Member

@stephanosio stephanosio left a comment

Choose a reason for hiding this comment

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

LGTM

@stephanosio
Copy link
Member

@yperess @galak PTAL

@stephanosio
Copy link
Member

@galak ping

@stephanosio
Copy link
Member

Dismissing @galak's change request since his concern has been addressed (see #54637 (comment)).

@stephanosio stephanosio merged commit e0b540d into zephyrproject-rtos:main Apr 27, 2023
@keith-packard keith-packard deleted the filter-on-full-libc branch April 27, 2023 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants