Uh oh!
There was an error while loading. Please reload this page.
add sparse build support - #5984
Conversation
add a function to get overlays of each platform. Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
add a new option -s/--sparse to support sparse build for Zephyr. Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
There was a problem hiding this comment.
50 lines of code is a lot to just build with -DSPARSE=y.
I don't think this belongs to this script, I see almost nothing in common with the rest of the script.
Sparse is never going to work on Windows, we don't need the overhead and verbosity of python to run a few west commands, a shell script is enough.
The iteration over all platforms can be done only in CI, it does not need to be in this repo (it can be in .github/)
We don't need full overlay flexibility to build sparse; we will always stick to a couple of configurations so they can be hardcoded. If someone wants to try something locally they can edit the hardcoding locally.
We should try to make this wrapper script smaller, not bigger; moving features to Zephyr's CMake and the rest of the Zephyr build.
This was confirmed in a meeting this morning: a lot of the overlays logic in this script should be moved ASAP to Zephyr "applications" (whatever that means, I believe @aborisovich understands this well). Wrapper scripts add layers of obfuscations and the less often people have to use this script and the more often they can invoke west directly, the better. west is already a wrapper! On top of git and CMake, which is itself on top of ninja... EDIT1: it's started happening now: EDIT2: adding link to: |
| sparse_build_cmd.append('--') | ||
| if args.cmake_args: | ||
| build_cmd += args.cmake_args | ||
| sparse_build_cmd += ["-DSPARSE=y"] |
There was a problem hiding this comment.
Is it possible to just pass -DSPARSE=y to cmake_args in the command line when we want Sparse build.
There was a problem hiding this comment.
@lyakh I assume Zephyr has a build option to enable sparse at the top level we should reuse here ? Can you comment.
There was a problem hiding this comment.
west (= Zephyr's "top-level") has the ability to passthrough anything to CMake, which is what @keqiaozhang did here: https://docs.zephyrproject.org/latest/develop/west/build-flash-debug.html#one-time-cmake-arguments
This is infinitely scalable and saves west the need to add a new west --sparse option and then a new west --something option and then west --something-else etc.
I think west build ... -- too_long_list_of_overalds -DSPARSE=y is correct, I also think it would be much less code in a semi-hardcoded CI script. No need to add it to this python script (that the Zephyr team does not like)
In the future too_long_list_of_overlays should be gone and usage of this script reduced.
There was a problem hiding this comment.
@lyakh I assume Zephyr has a build option to enable sparse at the top level we should reuse here ? Can you comment.
@lgirdwood sorry, I thought I replied to this: that is the correct way to build with sparse support - by adding the -DSPARSE=y key to cmake
What is the goal/need of building sparse? So, support for sparse build should be done by just calling a command: Then, in |
aborisovich
left a comment
There was a problem hiding this comment.
Please move Sparse build to CMake
marc-hb
commented
Aug 18, 2022
I think @keqiaozhang has already been working on a very different alternative |
lyakh
commented
Aug 19, 2022
@aborisovich my proposal would be to build it for each PR but we could start with just one configuration, e.g. TGL. Ideally we need an "all-yes-config" for this - to build as much of the source base as possible. Then we should add builds for all other architectures - those, that support Zephyr building. I understand, that we don't get a 100% code base coverage unless we actually build all platforms, so that should be something we have to consider too. And yes, I haven't worked with github CI hooks, but I'd expect it to be a separate GH CI "pipeline" (sorry for a gitlab-ism). And - most importantly - we need to parse an evaluate the resulting log - not just check the return code. But that can also be achieved with simple grep commands. We do already have a "GitHub Actions / gcc-build-only" test, maybe we could extend that with this, or even replace plane gcc building with Zephyr+sparse? |
lgirdwood
commented
Aug 19, 2022
@keqiaozhang@lyakh@aborisovich can we have something simple and very similar to the Linux sparse invocation which everyone understands and uses make (cmake in our case). This would also need to align with Zephyr. |
Well I would argue that adding C=1 to make command is intuitive solution... (I'm referring to the link you send). |
lgirdwood
commented
Aug 21, 2022
I'm also good for west support, my ask is that it's a simple command line option. |
lyakh
commented
Aug 26, 2022
@aborisovich@marc-hb@keqiaozhang any progress with this? We really want sparse support in CI - we get code added regularly that involves buffer manipulation and having an automated check for its correctness would be very helpful! |
lgirdwood
commented
Aug 31, 2022
@aborisovich@marc-hb@keqiaozhang ping - do we have some alignment yet ? adding @andyross to see how we can all align Zephyr + SOF on SPARSE usage. |
I'll submit something tomorrow at the latest EDIT: first step in |
@lyakh have you tried EDIT: I tried with other platforms and docker image versions and they all fail like this. |
I haven't, but have you also set the env variable? I.e. I actually tried to automate that export in cmake but haven't been able to achieve that. I did add to cmake/compiler/gcc/target.cmake and at least during my testing it was needed too, but it wasn't enough, so both were needed... |
No I haven't. I'm not a sparse expert. Generally speaking CMake does not play well with environment variables (which are of course evil). Can you please provide somewhere a complete and detailed list of manual steps to compile with sparse? It must be good and complete enough for any reasonably skilled developer to compile with sparse in less than 1h. Trying to automate something that can't be replicated manually is futile and jumping the gun. |
lyakh
commented
Sep 2, 2022
@marc-hb that's all, that's literally what I do to build with sparse: if you still cannot get this to work, I guess I'll have to try to reproduce this in Zephyr's docker image myself |
lyakh
commented
Sep 2, 2022
@marc-hb also, looking at the error log above - is the path |
lyakh
commented
Sep 2, 2022
marc-hb
commented
Sep 2, 2022
There's no Don't bother with the container, I can handle the container but we need to all use reasonably recent parts.
Yes I checked it exists in the container yet CMake fails for some unknown reason. But before we even get into that please upgrade everything to weeks-old versions or even better: days-old versions. Nothing months old. |
lgirdwood
commented
Sep 7, 2022
Are we good @marc-hb@aborisovich@keqiaozhang now ? Do we need to close this ? |
marc-hb
commented
Sep 7, 2022
Sorry for hijacking this Pull Request and using it as an issue instead. It's been surprisingly convenient though. I just had a chat with @lyakh about sparse a couple hours ago. Right now he's busy with other more urgent things so really not in a good place to upgrade his Zephyr SDK. Once he can and we are on the same page then we will resume the troubleshooting together. In the mean time everyone else is more than welcome to give |
keqiaozhang
commented
Sep 13, 2022
Sorry, I was busy with other tasks recently, I will try sparse build with latest SOF/Zephyr SDK. |
keqiaozhang
commented
Sep 13, 2022
I just tried sparse build with latest
The output is attached. I will try to add sparse build support in .github next. |
lyakh
commented
Sep 13, 2022
@keqiaozhang thanks for checking, I just was going to write the same - updated the toolchain to the newest one, set |
aborisovich
commented
Sep 15, 2022
What is current status on this? Anyone can sum up? |
marc-hb
commented
Sep 15, 2022
I will have a look today. |
Finally got it working in the container. Not sure what sort of hacks have been implemented to compile with sparse but the error handling in the sparse build is really the worst I've ever seen. I'll add an error message decoder ring in the PR |
marc-hb
commented
Sep 17, 2022
lyakh
commented
Sep 19, 2022
@marc-hb great, approved, thanks for investigating and fixing it! After that we should add checks for a couple of particularly important for us tests - commented there. |
marc-hb
commented
Sep 27, 2022
@keqiaozhang close? |
keqiaozhang
commented
Sep 27, 2022
Yes, closing this PR. |

No description provided.