Skip to content

llext: merge .cold sections and forward Clang linker target - #11600

Open
lgirdwood wants to merge 1 commit into
thesofproject:mainfrom
lgirdwood:topic/llext-cold-clang-link
Open

lgirdwood wants to merge 1 commit into
thesofproject:mainfrom
lgirdwood:topic/llext-cold-clang-link

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Summary

  • Merge .cold and .cold.literal sections in scripts/llext_merge_sections.ld so cold functions placed by __cold attributes or Clang/LLVM optimization do not remain unmerged in relocatable LLEXT ELFs.
  • Forward --target=${CMAKE_C_COMPILER_TARGET} and --ld-path= (when present in CMAKE_EXE_LINKER_FLAGS) inside sof_llext_build() in zephyr/CMakeLists.txt so Clang-based Xtensa LLEXT links invoke the configured target triple and linker rather than falling back to the host linker.

Testing

  • Verified GCC build for intel_adsp/ace15_mtpm with relocatable LLEXTs (llext_relocatable.conf + webrtc_overlay.conf).
  • Validated on Clang/LLVM (sof-llvm v0.7) relocatable LLEXT firmware on Intel ARL-S (Dragon Fly) and PTL (Aphid).

Merge .cold and .cold.literal sections in scripts/llext_merge_sections.ld
so cold functions emitted by Zephyr __cold attributes or Clang/LLVM
profile-guided section placement do not remain as orphan unmerged sections
in relocatable LLEXT ELFs.

Also forward --target=${CMAKE_C_COMPILER_TARGET} and --ld-path= (when
configured in CMAKE_EXE_LINKER_FLAGS) in sof_llext_build() so Clang-based
Xtensa LLEXT links use the configured target triple and lld linker rather
than falling back to the host linker.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood
lgirdwood marked this pull request as ready for review December 2, 2026 21:56
Copilot AI balanced review requested due to automatic review settings December 2, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

This PR improves relocatable LLEXT linking by consolidating Clang-generated “cold” sections in the linker script and ensuring Clang-based Xtensa LLEXT links honor the configured target triple and linker path.

Changes:

  • Add forwarding of --target=${CMAKE_C_COMPILER_TARGET} and --ld-path=... into sof_llext_build() linker parameters.
  • Merge .cold and .cold.literal input sections into a single output section in llext_merge_sections.ld.
File Description
zephyr/​CMakeLists.txt Propagates Clang target/linker selection into LLEXT link invocation.
scripts/​llext_merge_sections.ld Adds an output .cold section to merge .cold* and .cold.literal* inputs.

Review effort: Lite

Comment thread zephyr/CMakeLists.txt
Comment on lines +108 to +110
if(CMAKE_EXE_LINKER_FLAGS MATCHES "--ld-path=([^ ]+)")
list(APPEND EXTRA_LINKER_PARAMS --ld-path=${CMAKE_MATCH_1})
endif()
Comment thread zephyr/CMakeLists.txt
Comment on lines +106 to +111
if(CMAKE_C_COMPILER_TARGET)
list(PREPEND EXTRA_LINKER_PARAMS --target=${CMAKE_C_COMPILER_TARGET})
if(CMAKE_EXE_LINKER_FLAGS MATCHES "--ld-path=([^ ]+)")
list(APPEND EXTRA_LINKER_PARAMS --ld-path=${CMAKE_MATCH_1})
endif()
endif()
@intel-sofci

Copy link
Copy Markdown

PR 11600: test results

Run date: 2026-12-02 23:13 UTC

Tested commit: 92897566619330a07342b1bc00e4219d876b2d65

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

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.

4 participants