Skip to content

wip: build: add support for llvm clang#10759

Draft
lgirdwood wants to merge 7 commits intothesofproject:mainfrom
lgirdwood:clang-upstream
Draft

wip: build: add support for llvm clang#10759
lgirdwood wants to merge 7 commits intothesofproject:mainfrom
lgirdwood:clang-upstream

Conversation

@lgirdwood
Copy link
Copy Markdown
Member

Just a heads up for anyone interested in llvm clang support to build SOF xtensa targets. Its still very early WIP with lots of work still to do but end result should be a single xtensa clang compiler for all SOF targets for CI, twister etc. Opens door to other non C based languages long term.

Needs zephyrproject-rtos/zephyr#108765

and

llvm/llvm-project@main...lgirdwood:llvm-project:upstream/dev

lrgirdwo added 7 commits May 8, 2026 14:20
Add --llvm-clang LLVM_BUILD_DIR flag to xtensa-build-zephyr.py for
building SOF with a custom LLVM/Clang toolchain instead of xt-clang
or Zephyr SDK GCC.

When specified, the script:
- Auto-generates a platform-specific clang wrapper script that:
  - Filters GCC-only flags (-fno-reorder-functions, -fno-defer-pop,
    --param=*, -fstrict-overflow)
  - Translates -mlongcalls to -mlong-calls
  - Adds --target for the Xtensa SoC triple
  - Adds -fno-integrated-as (GCC external assembler)
  - Adds -B paths for GCC assembler/linker from Zephyr SDK
  - Adds -I path for SoC-specific core-isa.h
- Forces ZEPHYR_TOOLCHAIN_VARIANT=zephyr for GCC assembler/linker
- Overrides CMAKE_C_COMPILER and CMAKE_ASM_COMPILER

Usage:
  scripts/xtensa-build-zephyr.py --llvm-clang ~/llvm-project/build ptl

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Switch from ZEPHYR_TOOLCHAIN_VARIANT=zephyr with wrapper script overrides
to ZEPHYR_TOOLCHAIN_VARIANT=llvm which has native Xtensa Clang support.

The llvm variant (cmake/toolchain/llvm/target.cmake) handles:
- Compiler detection via LLVM_TOOLCHAIN_PATH
- GCC assembler/linker integration via CROSS_COMPILE
- Correct -B paths for assembler and linker discovery
- LLEXT shared library link wrapper

This eliminates the need for the wrapper script and symlink dance
that was required with the zephyr variant to override find_program().

Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
- llext_link_helper.py: Treat .rodata as readonly even when marked
  writable by the Clang/objcopy LLEXT pipeline, and place readonly
  sections BEFORE .text so Xtensa l32r instructions (which can only
  reach backwards up to 256KB) can access .rodata literals.
- zephyr/CMakeLists.txt: Make -mtext-section-literals conditional via
  check_c_compiler_flag (Clang doesn't support it), and force the
  Zephyr SDK GCC linker for the LLEXT shared library link step.

Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Disable the Intel UAOL DAI driver/usage when building with Clang to
work around build failures. UAOL is gated off in the board Kconfig
default and the corresponding DAI dispatch arms are stubbed out with
'#if 0' until a proper Clang-compatible fix lands.

Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
The LOG_CORE_ID_PREFIX default produces logging output paths that
trigger Clang build issues. Disable the board-level default until a
proper fix is in place.

Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Add intel_adsp_ace30_ptl_llvm_qemu.conf overlay config for single-core
LLVM QEMU testing. Applied on top of the base intel_adsp_ace30_ptl.conf
via -DEXTRA_CONF_FILE=.

Key overrides:
- CONFIG_CORE_COUNT=1, CONFIG_SMP=n: avoids SMP sync hang in QEMU
- CONFIG_LLEXT=n: missing TIE headers (xt_FP.h) in LLVM
- CONFIG_FORMAT_CONVERT_HIFI3=n: same TIE dependency
- CONFIG_USERSPACE=n, CONFIG_PM=n: reduces single-core init complexity
- CONFIG_LOG_MODE_DEFERRED=y: avoids z_cbvprintf_impl crash path

Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
@lgirdwood lgirdwood changed the title wip: buiild: add support for llvm clang wip: build: add support for llvm clang May 8, 2026
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