From c5230a9f0dec063b3ad76d4776a4646f3608856d Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 10 Apr 2024 16:40:33 +0200 Subject: [PATCH] smart-amp-test: add support for the Cadence toolchain The Cadence Xtensa cross-toolchain cannot build shared libraries, when using it we build relocatable ELF objects instead. Update smart-amp-test to support both formats. Signed-off-by: Guennadi Liakhovetski --- src/samples/audio/smart_amp_llext/CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/samples/audio/smart_amp_llext/CMakeLists.txt b/src/samples/audio/smart_amp_llext/CMakeLists.txt index ded003b1e..2e57380bf 100644 --- a/src/samples/audio/smart_amp_llext/CMakeLists.txt +++ b/src/samples/audio/smart_amp_llext/CMakeLists.txt @@ -53,7 +53,16 @@ target_compile_options(${MODULE} PRIVATE -save-temps -O2 ) +if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr") set(MODULE_LINKER_PARAMS -nostdlib -nodefaultlibs) +set(EXTRA_LINKED_PARAMS -shared) +set(COPY_CMD ${CMAKE_STRIP} -R .xt.* -o ${MODULE}_out.so ${MODULE}_llext.so) +else() +set(MODULE_LINKER_PARAMS -nostdlib -nodefaultlibs -r) +set(EXTRA_LINKED_PARAMS) +set(COPY_CMD ${CMAKE_OBJCOPY} -R .xt.* ${MODULE}_llext.so ${MODULE}_out.so) +endif() + target_link_options(${MODULE} PRIVATE ${MODULE_LINKER_PARAMS} ) @@ -62,9 +71,9 @@ add_custom_command(OUTPUT lib${MODULE}_out.so DEPENDS ${MODULE} COMMAND ${SOF_BASE}scripts/llext_link_helper.py -f lib${MODULE}.so -t "0xa06ca000" ${CMAKE_C_COMPILER} -- - ${MODULE_LINKER_PARAMS} -shared -fPIC - -o lib${MODULE}_llext.so $ - COMMAND ${CMAKE_STRIP} -R .xt.* -o lib${MODULE}_out.so lib${MODULE}_llext.so + ${MODULE_LINKER_PARAMS} ${EXTRA_LINKED_PARAMS} -fPIC + -o ${MODULE}_llext.so $ + COMMAND ${COPY_CMD} COMMAND_EXPAND_LISTS )