From 7a8c1b716dc0b806da3994f76913dabe385b1216 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 9 Aug 2024 22:42:06 +0000 Subject: [PATCH] scripts: add new SOF_CC_BASE={xcc,clang,gcc} variable This is required to allow building XTOS with newer, clang-based, Cadence toolchains as just submitted for ACP_7_0 in #9351 Signed-off-by: Marc Herbert --- scripts/cmake/xtensa-toolchain.cmake | 9 ++++++--- scripts/set_xtensa_params.sh | 9 +++++++++ scripts/xtensa-build-all.sh | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/cmake/xtensa-toolchain.cmake b/scripts/cmake/xtensa-toolchain.cmake index 3e070f7f6982..7bc29be3e434 100644 --- a/scripts/cmake/xtensa-toolchain.cmake +++ b/scripts/cmake/xtensa-toolchain.cmake @@ -49,11 +49,14 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) # xt toolchain only partially follows gcc convention if(TOOLCHAIN STREQUAL "xt") set(XCC 1) - set(CMAKE_C_COMPILER ${CROSS_COMPILE}xcc) -else() - set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc) endif() +if(NOT DEFINED SOF_CC_BASE) +set(SOF_CC_BASE "gcc") +endif() +# e.g.: "xt-" + "xcc" +set(CMAKE_C_COMPILER ${CROSS_COMPILE}${SOF_CC_BASE}) + find_program(CMAKE_LD NAMES "${CROSS_COMPILE}ld" PATHS ENV PATH NO_DEFAULT_PATH) find_program(CMAKE_AR NAMES "${CROSS_COMPILE}ar" PATHS ENV PATH NO_DEFAULT_PATH) find_program(CMAKE_RANLIB NAMES "${CROSS_COMPILE}ranlib" PATHS ENV PATH NO_DEFAULT_PATH) diff --git a/scripts/set_xtensa_params.sh b/scripts/set_xtensa_params.sh index 47853e9fcd29..fd48edf0bc13 100644 --- a/scripts/set_xtensa_params.sh +++ b/scripts/set_xtensa_params.sh @@ -145,6 +145,15 @@ case "$platform" in ;; esac +# Pre-zephyr "XTOS" build +case "$platform" in + none_yet) + SOF_CC_BASE='clang';; + *) + SOF_CC_BASE='xcc';; +esac + +# For Zephyr unit tests, testbench,... case "$platform" in imx8*|mtl|lnl) ZEPHYR_TOOLCHAIN_VARIANT='xt-clang';; diff --git a/scripts/xtensa-build-all.sh b/scripts/xtensa-build-all.sh index a17af0db520e..84b0526e71d1 100755 --- a/scripts/xtensa-build-all.sh +++ b/scripts/xtensa-build-all.sh @@ -231,6 +231,8 @@ do PATH=$XTENSA_TOOLS_DIR/XtensaTools/bin:$OLDPATH build_dir_suffix='xcc' else + # Override SOF_CC_BASE from set_xtensa_params.sh + SOF_CC_BASE='gcc' TOOLCHAIN=$HOST PATH=$SOF_TOP/../$HOST/bin:$OLDPATH build_dir_suffix='gcc' @@ -248,6 +250,7 @@ do printf 'PATH=%s\n' "$PATH" ( set -x # log the main commands and their parameters cmake -DTOOLCHAIN="$TOOLCHAIN" \ + -DSOF_CC_BASE="$SOF_CC_BASE" \ -DROOT_DIR="$ROOT" \ -DMEU_OPENSSL="${MEU_OPENSSL}" \ "${MEU_PATH_OPTION}" \