Repository navigation
Start decentralizing zephyr/CMakeLists.txt #8422
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,33 @@ elseif (CONFIG_IPC_MAJOR_4) | |
| add_subdirectory(ipc4) | ||
| endif() | ||
|
|
||
| add_local_sources(sof | ||
| set(base_files | ||
| ipc-common.c | ||
| ipc-helper.c | ||
| ) | ||
|
|
||
| is_zephyr(it_is) | ||
| if(it_is) ### Zephyr ### | ||
|
|
||
| zephyr_library_sources( | ||
| ${base_files} | ||
| dma-copy.c | ||
| ) | ||
|
|
||
| if (CONFIG_SOC_SERIES_INTEL_CAVS_V25 OR CONFIG_SOC_SERIES_INTEL_ACE) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks strange, but it matches the existing logic, so great to have this become more visible in the cmake code. The long per-product sections in one-giant-zephyr-cmakefile easily hide these things (when we have per-platform compilation of stuff that really shouldn't be per-platform). |
||
| zephyr_library_sources( | ||
| ipc-zephyr.c | ||
| ) | ||
| endif() | ||
|
|
||
|
|
||
| else() ### Not Zephyr ### | ||
|
|
||
|
|
||
| add_local_sources(sof | ||
| ${base_files} | ||
| ) | ||
|
|
||
| if (CONFIG_TRACE) | ||
| add_local_sources(sof | ||
| dma-copy.c) | ||
|
|
@@ -19,3 +41,6 @@ endif() | |
| if (CONFIG_LIBRARY) | ||
| return() | ||
| endif() | ||
|
|
||
|
|
||
| endif() # Zephyr | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,28 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| add_local_sources(sof | ||
| set(common_files | ||
| handler.c | ||
| helper.c | ||
| dai.c | ||
| ) | ||
|
|
||
| is_zephyr(it_is) | ||
| if(it_is) ### Zephyr ### | ||
|
|
||
| zephyr_library_sources( | ||
| ${common_files} | ||
| host-page-table.c | ||
| ) | ||
|
|
||
| else() ### Not Zephyr ### | ||
|
|
||
| add_local_sources(sof | ||
| ${common_files} | ||
| ) | ||
|
|
||
| if (CONFIG_HOST_PTABLE) | ||
| add_local_sources(sof | ||
| host-page-table.c) | ||
| endif() | ||
| endif() | ||
|
|
||
| endif() # Zephyr |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,36 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| add_local_sources(sof | ||
| set(common_files | ||
| dai.c | ||
| handler.c | ||
| helper.c | ||
| logging.c | ||
| notification.c | ||
| ) | ||
|
|
||
|
|
||
| is_zephyr(it_is) | ||
| if(it_is) ### Zephyr ### | ||
|
|
||
|
|
||
| zephyr_library_sources( | ||
| ${common_files} | ||
| ) | ||
|
|
||
| zephyr_library_sources_ifdef(CONFIG_AMS | ||
| ams_helpers.c | ||
| ) | ||
|
|
||
|
|
||
| else() ### Not Zephyr #### | ||
|
|
||
|
|
||
| add_local_sources(sof | ||
| ${common_files} | ||
| ams_helpers.c | ||
| ) | ||
|
|
||
| target_include_directories(sof_options INTERFACE ${RIMAGE_TOP}/src/include) | ||
|
|
||
|
|
||
| endif() # Zephyr |
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 a spot where Zephyr's promiscuous cmake layer hurts pretty badly, because you can't add files to the project in the same way in both modes. Again, maybe work around this by adding yet another layer of indirection and have a "sof_sources()".
Also, FWIW: the "_library_sources" variant really doesn't do anything useful beyond make the build slower by taking the time to create a static library. There is (AFAIK) exactly one spot in Zephyr where we have to do this for obscure linkage reasons[1], but for general C code it's almost always faster and cleaner to link all the object files at once.
I've tried to make that point upstream and basically failed: "zephyr_library_sources()" is a pervasive paradigm. But really it's needless except in specific situations.
(For reference: the reason to use it is that a static library only presents internal files to the link if one of their symbols is accessed, so you can build it and include static stuff like e.g. SYS_INIT() or interrupt declarations, and avoid having those end up in the final output unless something is using the file. But DTS and kconfig are the right mechanisms for that kind of dependency tracking, doing it with the linker is dangerous and surprising.)
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 thought about this and decided against it. There are already layers of indirection-obfuscation in both XTOS and Zephyr, don't want to stack yet another one on top. A dead simple
set(common_files ...)works great and avoids enough duplication.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.
Would you care to change this in
sof/zephyr/CMakeLists.txtright now? Don't mind conflicting with this, I'll happily rebase[*] It's a good time now because:[*] As much as one can be happy resolving git conflicts :-D
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.
Heh, I've spent my bikeshed quota for the month already.
The way this goes is that someone says "libraries make linking faster!" and the response is "only after the ranlib stage builds the table, and in zephyr most symbols are actually needed by the final link", then someone else demands benchmarks, etc...
Really I was mostly just whining about a personal peeve. I've made my peace with it: per-directory/per-app fine grained static libraries are the way zephyr links itself.