Skip to content

llvm patches for SOF xtensa#1

Merged
lgirdwood merged 2 commits into
lgirdwood:clang-upstreamfrom
hliao8:llvm10
May 20, 2026
Merged

llvm patches for SOF xtensa#1
lgirdwood merged 2 commits into
lgirdwood:clang-upstreamfrom
hliao8:llvm10

Conversation

@hliao8
Copy link
Copy Markdown

@hliao8 hliao8 commented May 19, 2026

Hope this PR is OK I used AI. Had to add some code so I could use my llvm patches on SOF and Zephyr.

@hliao8 hliao8 requested a review from lgirdwood as a code owner May 19, 2026 11:24
hliao8 added 2 commits May 19, 2026 19:45
Zephyr's FindZephyr-sdk.cmake intentionally skips auto-discovery
when ZEPHYR_TOOLCHAIN_VARIANT=llvm, expecting the user to point
ZEPHYR_SDK_INSTALL_DIR at the SDK that provides the GNU Xtensa
binutils / sysroot the LLVM clang driver wraps around.

When neither the user nor the environment supplies that variable
the build fails late with confusing 'string.h: file not found' /
malformed -isystem errors. Auto-detect a zephyr-sdk-* directory
under $HOME, /opt, or /usr/local (highest version wins) and export
ZEPHYR_SDK_INSTALL_DIR before invoking west when the user passes
--llvm-clang.

This keeps the LLVM build flow as one command for the common case
while still respecting any value the user has already exported.

Signed-off-by: Henry Liao <hliao8@proton.me>
The HiFi3 / HiFi4 / HiFi5 sources unconditionally include
<xtensa/config/defs.h>, a header that ships only with the Cadence
xt-clang / xt-gcc toolchains. The LLVM clang toolchain variant uses
the Zephyr SDK GNU Xtensa binutils for assembly/linking but does
not expose that Cadence-internal header, so every HiFi
translation unit fails to find it even though the body of the file
is guarded by SOF_USE_HIFI(...) and is unreachable for the LLVM
build.

Wrap the include in __has_include so the compiler silently skips
it on toolchains that lack the header. The HiFi intrinsics are
already supplied by <xtensa/tie/xt_hifiN.h>, which the LLVM
toolchain does provide.

No functional change for the Cadence toolchain path.

Signed-off-by: Henry Liao <hliao8@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants