Skip to content

Conversation

@marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Mar 12, 2023

xtensa-build-zephyr.py has always defined XTENSA_ and other environment variables in the current environment shared by all platforms. This was always bad but apparently never a problem until the addition of the new DEFAULT_TOOLCHAIN_VARIANT (xcc or clang) variable.

Before DEFAULT_TOOLCHAIN_VARIANT, each platform's environment would simply override the previous one. However with the new DEFAULT_TOOLCHAIN_VARIANT, the current environment has precedence for more flexibility. This makes each platform "spill" onto the next one and xtensa-build-zephyr.py -p tgl mtl fail like this:

-- Board: intel_adsp_ace15_mtpm
-- Found toolchain: xcc (/home/XCC/install/tools)
CMake Error at zephyr/cmake/compiler/xcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment
  misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: xcc

  Internal variables:

  CROSS_COMPILE:
  /home/XCC/install/tools/RI-2022.10-linux/XtensaTools/bin/xt-

To fix this, stop modifying the current os.environ and use a new, fresh os.environ.copy() for each platform instead.

Fixes commit 309fa26 ("xtensa-build-zephyr.py: upgraded Xtensa toolchain for MTL")

History repeats itself: commit 6bedd8e ("xtensa-build-zephyr: fix RIMAGE_KEY when building multiple platforms") fixed the same logical error months ago in a different script.

xtensa-build-zephyr.py has always defined XTENSA_ and other environment
variables in the current environment shared by all platforms. This was
always bad but apparently never a problem until the addition of the new
DEFAULT_TOOLCHAIN_VARIANT (xcc or clang) variable.

Before DEFAULT_TOOLCHAIN_VARIANT, each platform's environment would
simply override the previous one. However with the new
DEFAULT_TOOLCHAIN_VARIANT, the current environment has precedence for
more flexibility. This makes each platform "spill" onto the next one and
`xtensa-build-zephyr.py -p tgl mtl` fail like this:

```
-- Board: intel_adsp_ace15_mtpm
-- Found toolchain: xcc (/home/XCC/install/tools)
CMake Error at zephyr/cmake/compiler/xcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment
  misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: xcc

  Internal variables:

  CROSS_COMPILE:
  /home/XCC/install/tools/RI-2022.10-linux/XtensaTools/bin/xt-
```

To fix this, stop modifying the current os.environ and use a new, fresh
os.environ.copy() for each platform instead.

Fixes commit 309fa26 ("xtensa-build-zephyr.py: upgraded Xtensa
toolchain for MTL")

History repeats itself: commit 6bedd8e ("xtensa-build-zephyr: fix
RIMAGE_KEY when building multiple platforms") fixed the same logical
error months ago in a different script.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb marc-hb marked this pull request as ready for review March 12, 2023 06:21
@marc-hb marc-hb requested a review from aborisovich as a code owner March 12, 2023 06:21
@marc-hb marc-hb added bug Something isn't working as expected P2 Critical bugs or normal features labels Mar 12, 2023
@marc-hb
Copy link
Collaborator Author

marc-hb commented Mar 12, 2023

@dbaluta dbaluta merged commit 8aab183 into thesofproject:main Mar 13, 2023
@marc-hb marc-hb deleted the fix-XT-spill branch March 13, 2023 13:37
@marc-hb
Copy link
Collaborator Author

marc-hb commented Mar 14, 2023

@singalsu toolchain installation just found a tricky bug in this commit, tentative fix submitted in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected P2 Critical bugs or normal features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants