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

kernel kconfig: Do not enable STATIC_INIT_GNU w the old native_posix #75404

Merged
merged 1 commit into from
Jul 6, 2024

Conversation

aescolar
Copy link
Member

@aescolar aescolar commented Jul 3, 2024

native_posix (unlike native_sim) or its brethren (NATIVE_APPLICATION) link together the "runner" code and the embedded code in one pass. This means that when CONFIG_STATIC_INIT_GNU is set, any host library code (like the llvm fuzzer) constructors will get postponed to the Zephyr initialization.
These libraries are unlikely to work if we do this. (the llvm fuzzer does not)

So let's instead not enable STATIC_INIT_GNU for these targets. This means possible embedded library constructors will continue to be picked during the link and be still called during the native runner initialization instead of during the Zephyr OS initialization as they were just before we introduced STATIC_INIT_GNU in
6e977ae

Note that native_posix will be deprecated shortly and its users are strongly encouraged to move to native_sim.

Fixes #75407
Related to #74682

native_posix (unlike native_sim) or its breathen (NATIVE_APPLICATION)
link together the "runner" code and the embedded code.
This means that when CONFIG_STATIC_INIT_GNU is set,
any host library code (like the llvm fuzzer) constructors will get
postponed to the Zephyr initialization.
These libraries are unlikely to work if we do this.
(the llvm fuzzer does not)

So let's instead not enable STATIC_INIT_GNU for these targets.
This means possible embedded library constructors will continue to be
picked during the link and be still called during the native runner
initialization instead of during the Zephyr OS initialization as they
were just before we introduced STATIC_INIT_GNU in
6e977ae

Note that native_posix will be deprecated shortly and its users
are strongly encouraged to move to native_sim.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

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

Works for me.

@aescolar aescolar added this to the v3.7.0 milestone Jul 3, 2024
@andyross
Copy link
Contributor

andyross commented Jul 3, 2024

Note the board swap seems to be working in SOF for me (thesofproject/sof#9280), so no rush on this. Whether it's worth merging for any other hypothetical native_posix users is not something I'll argue about. :)

@aescolar
Copy link
Member Author

aescolar commented Jul 4, 2024

Note the board swap seems to be working in SOF for me (thesofproject/sof#9280), so no rush on this. Whether it's worth merging for any other hypothetical native_posix users is not something I'll argue about. :)

Thanks @andyross I think it will be best to merge this before 3.7. We still support native_posix, and just like the fuzzer failed, other host libraries may also.
And just like SOF was still using native_posix I expect some other projects will still be using it or whatever derivatives they built over the years.
This just reverts this constructor initialization behavior to what it was before, but only for native_posix and its old family of boards. So it should be safe enough (I run a full twister run on native_posix and this did not introduce any regression).

@aescolar aescolar requested a review from keith-packard July 4, 2024 07:31
@aescolar aescolar merged commit 3da87b9 into zephyrproject-rtos:main Jul 6, 2024
36 checks passed
@aescolar aescolar deleted the fuzzer_native_posix_fix branch July 6, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel area: Linker Scripts bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fuzzer not working in native_posix
5 participants