-
Notifications
You must be signed in to change notification settings - Fork 8.1k
net + posix: avoid host includes when building for native_sim #75849
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
Merged
nashif
merged 5 commits into
zephyrproject-rtos:main
from
cfriedt:issues/75319/fix-cpp-posix-net-native-sim-build
Jul 27, 2024
Merged
net + posix: avoid host includes when building for native_sim #75849
nashif
merged 5 commits into
zephyrproject-rtos:main
from
cfriedt:issues/75319/fix-cpp-posix-net-native-sim-build
Jul 27, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 269729a. Signed-off-by: Chris Friedt <[email protected]>
A corner case involving C++, posix, networking, and native_sim was causing problems. Even though C and C++ builds should include zephyr/posix/.. in the default search path with `CONFIG_POSIX_API=y`, for some reason, the native compiler pulls in /usr/include first anyway. The stat.h header pulled in <sys/types.h> (which is normally fine) but due to the native build, it was pulling in /usr/include/sys/types.h, from the host toolchain. Explicitly include <zephyr/posix/posix_types.h> instead of <sys/types.h> from stat.h, and continue using the workarounds for native builds (explicitly including zephyr/posix/arpa/net.h from net/sockets.h . Signed-off-by: Chris Friedt <[email protected]>
4c4cddd to
d6fe2fc
Compare
A number of types such as uid_t, gitd_t, etc, were defined in sys/stat.h to workaround compatibility issues many years ago. Since posix_types.h is slated to become equivalent to sys/types.h in terms of standard headers, move these types to where they belong. For more information, please see https://pubs.opengroup.org/onlinepubs/9699919799/\ basedefs/sys_types.h.html Signed-off-by: Chris Friedt <[email protected]>
3258021 to
8467129
Compare
Simplify the conditions for pthread type declaration Signed-off-by: Chris Friedt <[email protected]>
Prior to the fixes in the previous commits, combining a build for native_sim with CONFIG_CPP=y CONFIG_POSIX_API=y CONFIG_STD_CPP20=y CONFIG_REQUIRES_FULL_LIBCPP=y would fail. It succeeds now. This change adds a testcase to monitor that scenario in CI. Note: this was partially necessary because the deprecation of CONFIG_NET_SOCKETS_POSIX_NAMES is not yet complete, so there is a dependency cycle, and also because <sys/types.h> was pulling in the host <sys/types.h> instead of Zephyr's or one of the embedded OSes we support. Signed-off-by: Chris Friedt <[email protected]>
8467129 to
9914838
Compare
ycsin
approved these changes
Jul 15, 2024
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.
Thanks
rlubos
approved these changes
Jul 15, 2024
jukkar
approved these changes
Jul 15, 2024
|
Thank you, I can confirm that #75319 is fixed when this PR is checked out. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: Networking
area: POSIX
POSIX API Library
backport v3.7-branch
Request backport to the v3.7-branch
bug
The issue is a bug, or the PR is fixing a bug
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A corner case involving C++, posix, networking, and native_sim was causing problems.
Even though C and C++ builds should include zephyr/posix/.. in the default search path with
CONFIG_POSIX_API=y, for some reason, the native compiler pulls in /usr/include first anyway.The stat.h header pulled in <sys/types.h> (which is normally fine) but due to the native build, it was pulling in /usr/include/sys/types.h, from the host toolchain.
Explicitly include <zephyr/posix/posix_types.h> instead of <sys/types.h> from stat.h, and continue using the workarounds for native builds (explicitly including zephyr/posix/arpa/net.h etc from net/sockets.h, etc).
The workaround must be left in the tree until the deprecated option
CONFIG_NET_SOCKETS_POSIX_NAMESis removed, at which point Zephyr's POSIX API will be a consumer of the network subsystem, eliminating one of the few remaining dependency cycles in Zephyr.Fixes #75319