-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
cmake: add llext compilation module #67431
Merged
henrikbrixandersen
merged 3 commits into
zephyrproject-rtos:main
from
pillo79:llext-test-rework
Jan 21, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 file contains 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
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.
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.
Just curious, what would be wrong with trying/wanting to generate an llext for a project that doesn't have LLEXT enabled. One needn't enable LLEXT in a project if they only care about having "snippets" of it built as llext, no?
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.
Well, indeed you could compile only the llext, since there's no real technical barrier. However, the generated file would not work with the same Zephyr core with which it was built (no exported symbols or machinery to load it), so it looked like a config error in my eyes.
Now that I look at it again, the converse is useful though - if you know what you are doing and purposefully disable
CONFIG_LLEXT
on a project that defines such targets, it makes sense not to build them and not complain, unless they are required by other parts in the project.Taking into account your other comment on dependencies ("why isn't a llext built if it's defined as part of a project?"), I think the most appropriate way to deal with all this should be:
CONFIG_LLEXT
is not enabled, do not complain inadd_llext_target
and define an empty target instead, so otherllext_
* APIs don't break as well.This would result in an actual build error only when LLEXT is disabled and the output file is a required dependency (for example by
generate_inc_file_for_target
) - or if the Zephyr code actually calls llext APIs, obviously.@teburd, what do you think about this?
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.
Sorry for the belated reply and - much worse - sorry for not being @teburd.
I probably (!) disagree with that? The main purpose of Kconfig is to turn software features on and off. But "llext" isn't really a software feature, it's more about HOW you want some of those features to be delivered: as a separate module or built-in? So CONFIG_LLEXT is more like a "dependency" of real features.
Consider the Linux kernel, which many
llext
aspects take inspiration from. It had to already deal with this problem. If you turn off Linux CONFIG_MODULES inmake menuconfig
then it immediately forces you to make all features built-in. Editing the .config and runningmake oldefconfig
does the same thing.Of course there's a massive difference: the Linux kernel can very quickly and easily flip drivers that support between module and built-in, whereas
llext
does not do that all. But that "inspiration" is still useful IMHO.So if you:
... then you have a configuration error and the build should 1) fail, 2) fail as soon as possible, not wait until compilation whether some symbol is used maybe, maybe not.
In other words, if you turn off CONFIG_LLEXT then you MUST also turn off all features that depend on it - and maybe Kconfig can/should help with that but either way CMake should fail ASAP if you feed it an inconsistent configuration.
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.
In fact, llext is only the implementation enabling the "dynamic loading" feature. The HOW you want [features] to be delivered part is
CONFIG_MODULES
, which was recently merged in Zephyr. No actual in-tree users yet though - having dynamically loadable parts of the Zephyr core is still far out.Given that discussion and the existence of both
MODULES
andLLEXT
, I think what you are describing above is a strict dependency between them: eitherMODULES
impliesLLEXT
, or depends on it, or there's a config error. Absolutely agree with that!However, and this is when
MODULES=n
, I still maintain there is merit in building llext-related projects withLLEXT=n
without complaining. This would enable scenario 1 of the following 3:#ifdef CONFIG_LLEXT
they are able to build either way;prj.conf
;OT: We need an RFC / implementation plan on llext pronto! 😅 . I'll try to draft one shortly and share it so we can all agree on the long term path. 👍
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.
Thank you so much for leading here again. Whatever are the use cases and intended Kconfig interactions, I think we all agree they cannot just be inferred from scattered comments in source and code reviews. Some high-level design documentation is required indeed.