Repository navigation
Resurrect windows build - rewrite xtensa-build-zephyr.sh to Python - #5299
Conversation
f314fca to
4f8614a
Compare
lgirdwood
left a comment
There was a problem hiding this comment.
@aborisovich I'm guessing the shell script is not working on Windows ?
These scripts are developer aids only (e.g. should not really be used as part of build infra) so the only issue here is keeping this aligned with shell version or deprecate the shell version ? @marc-hb any comments.
|
@lgirdwood yes, unfortunately xtensa-build-zephyr.sh does not work on Windows thus I made this counterpart.
In my opinion this script should be thoroughly tested by end-users and when proved working replace existing xtensa-build-zephyr.sh. I did not remove it in this commit (xtensa-build-zephyr.sh) as I did not know that it is not used in processes or VMs. |
|
Everyone are welcome to test this script against bugs since I surely did not find all flaws. |
Best to put this in the commit message so it's obvious. |
kv2019i
left a comment
There was a problem hiding this comment.
Thanks @aborisovich ! This looks very nice. I think we might want to keep both scripts in parallel for a while to get some mileage in various Linux systems. I do have a few minor questions on the earlier two patches, please see inline.
There was a problem hiding this comment.
Very incomplete review sorry, not enough time right now. Will get back to it soon.
Thanks for this rewrite, impressive effort! Yes all Zephyr users should be cherry-picking this (git fetch origin pull/5299/head && git cherry-pick FETCH_HEAD) and start using it ASAP - even before it gets merged.
An important, future and post-merge test will be to switch CI to it but many people in our CI team are out this week for Chinese New Year. Later after some transition period we can delete the shell script.
One important feature missing is logging. This is very important not just to help resolve bugs in this script but even more importantly to quickly assess what went wrong in its environment (there is always something going wrong somewhere). The log level should always be increased in CI.
With the shell script you could quickly insert a set -x and get some logging anywhere. The script already has some set -x in some critical places.
A hopefully quick way to get a lot of useful logs with minimal code changes is to add a simple wrapper for all calls to subprocess.run(). That wrapper uses logging.info() to print all its arguments and then passes them all through to subprocess.run(). This is one of the things west -v does BTW.
Tested example:
def run_command(*args, **kwargs):
logging.warning("Running " + " ".join(args[0]))
return subprocess.run(*args, **kwargs) 4f8614a to
bb833f6
Compare
92de063 to
60870c5
Compare
|
@aborisovich I will rerun CI this afternoon, looks like a server error for the container and some DUTs were not available. QB issue looks like a false positive. |
|
SOFCI TEST |
|
@marc-hb @greg-intel this PR has failed Zephyr/Fuzzer build twice on what looks like container network issues. Should be completely unrelated to this PR. Other PRs have been building the container OK today. Can you take a quick check and rerun CI if you think this is just bad luck here. Thanks |
60870c5 to
655662c
Compare
|
New fixes:
|
Always share URLs to test failures as Github does not support force pushes (it only tolerates them) |
|
I am able to see the errors. Looks temporary network glitch. Coincidentally we had sof docker image update in yesterday, I don't think this is direct reason for network failure, but I will take a look for any suspicious warning or error. |
|
@marc-hb Resolved issues:
|
|
Thanks, I will test again in the next 24h |
Ok sorry I will not resolve them. I just did not get your point fully and I am also getting confused in all this. It is a complex script no doubt. I also got carried away for a while with that argparser subparser idea. For some reason I imagined for a while that we need both -p argument signaling that we actually want to rebuild and another -P argument giving a path to zephyr project. |
|
@aborisovich @marc-hb Lets merge and fix as we go since we have an existing shell script that can be used on Linux/CI. This script is working on Windows so we can log bugs against it for Linux and deprecate the shell version when this is working well for all OSes. |
|
I don't mind merging even with some bugs or room for improvement. I mind merging with a different user interface / "API" (at least not without some strong reason) because bringing everyone on the same page again will disrupt at least half the users. I will give this another quick try today as promised. |
marc-hb
left a comment
There was a problem hiding this comment.
Thanks for the cloning fixes.
Tried it again, now clones but fails to build with:
raise RuntimeError(f"Platform {platform} uses Xtensa toolchain."
RuntimeError: Platform apl uses Xtensa toolchain.
Please set your XTENSA_TOOLS_ROOT environmental variable
There is no platform that requires XCC.
Again this would have not happened if you had simply copied the original logic.
We're making progress but using me as CI is really not efficient. Try this tiny test hack instead and github will test the most basic features (clone and build) for you:
diff --git a/zephyr/docker-build.sh b/zephyr/docker-build.sh
index 0700cbaa780b..d04ea21be028 100755
--- a/zephyr/docker-build.sh
+++ b/zephyr/docker-build.sh
@@ -36,5 +36,5 @@ else
stat .
sudo chgrp -R 1000 .
sudo chmod -R g+rwX .
- ./scripts/xtensa-build-zephyr.sh -a -c "$@"
+ ./scripts/xtensa-build-zephyr.py -a -c "$@"
fiThere was a problem hiding this comment.
This makes it impossible to build with the Zephyr SDK.
So far we've been able to build every platform with either the Zephyr SDK or XCC, both work fine. The Zephyr SDK requires zero license and zero configuration, install it in the HOME directory and that's it, job done. Nothing to do in this script to support it (besides removing this RunTimeError)
Newer gcc compilers 9.1+ issue a W-char-subscripts warning when argument type passed to isspace is not explicitly int. Added cast to int. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
Windows users building with MSYS2 need to provide additional include path to the POSIX standard headers to build sof-logger with GCC. Added this include directory when environmental variable MSYS_INSTALL_DIR is set. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
Building with GCC on Windows using MSYS caused errors related to macros redefinition in compile_attributes.h due to GCC using its standard headers. Added #ifndef guards. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
551f2ea to
18206a0
Compare
18206a0 to
4fcd51b
Compare
|
@marc-hb fixed exception issue with XTENSA_TOOLS_ROOT - now when XTENSA_TOOLS_ROOT environmental variable is set it is a signal to use user installed custom Xtensa installation. When not assume user has Zephyr SDK installed.
Added new features:
Created test PR replacing invocation of the xtensa-build-zephyr.sh with new script. Build Zephyr workflow is passing. Currently Windows build encountered regression as I am failing to build sof sources due to zephyr libc clashes when using standard gcc. I would submit this script for now without replacing existing xtensa-build-zephyr.sh. Passing CI build does not mean this script is fully mature and tested taking into consideration its complexity... |
4fcd51b to
57389dc
Compare
|
Minor update - installed files are not presented when platforms were not built (no need to do that when somebody uses only -c flag). |
marc-hb
left a comment
There was a problem hiding this comment.
All basic features work for me, thanks @aborisovich very impressive effort.
I will help start the transition away from the .sh and we can refine if needed.
57389dc to
6bfbb22
Compare
Created new script with similar functionality to allow SOF + Zephyr builds on both Windows and Linux operating systems. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
6bfbb22 to
5897bbe
Compare
When neither -c nor -p is passed, the script defaults to '-p SOF_TOP/zephyrproject', initializing the `west_top` global with that. When everything is already cloned, this becomes zephyrproject/modules/audio/sof/zephyrproject which is really not a `west topdir`. Then west is pointed at: real_west_top/modules/audio/sof/zephyrproject/zephyr/samples/subsys/audio/sof which obviously fails. This was found while testing https://thesofproject.github.io/latest/getting_started/build-guide/build-with-zephyr.html and trying (and failing) to switch away from the older .sh script. Fix find_west_workspace() to return the output of `west topdir` and use that to update the `west_top` global. This bug was introduced from the very start when the script was converted from shell to python. The shell script did not have this problem because it could be used without using neither -c nor -p. This logical difference was mentioned in the code review: thesofproject#5299 (comment) Also remove a couple of accidental creations of a sof/zephyrproject/ directory when sof is already inside a higher zephyrproject. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
When neither -c nor -p is passed, the script defaults to '-p SOF_TOP/zephyrproject', initializing the `west_top` global with that. When everything is already cloned, this becomes zephyrproject/modules/audio/sof/zephyrproject which is really not a `west topdir`. Then west is pointed at: real_west_top/modules/audio/sof/zephyrproject/zephyr/samples/subsys/audio/sof which obviously fails. This was found while testing https://thesofproject.github.io/latest/getting_started/build-guide/build-with-zephyr.html and trying (and failing) to switch away from the older .sh script. Fix find_west_workspace() to return the output of `west topdir` and use that to update the `west_top` global. This bug was introduced from the very start when the script was converted from shell to python. The shell script did not have this problem because it could be used without using neither -c nor -p. This logical difference was mentioned in the code review: #5299 (comment) Also remove a couple of accidental creations of a sof/zephyrproject/ directory when sof is already inside a higher zephyrproject. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Four commits:
Signed-off-by: Andrey Borisovich andrey.borisovich@intel.com