Skip to content

Commit

Permalink
Add build support for xt-clang compiler
Browse files Browse the repository at this point in the history
Add xt-clang compiler build support for platform ACP_7_0.

Signed-off-by: SaiSurya Ch <saisurya.chakkaveeravenkatanaga@amd.com>
  • Loading branch information
saisurya-ch committed Aug 6, 2024
1 parent 5307fee commit 34e5f7a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
2 changes: 1 addition & 1 deletion scripts/cmake/xtensa-toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ 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)
set(CMAKE_C_COMPILER ${CROSS_COMPILE}${COMPILER})
else()
set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc)
endif()
Expand Down
20 changes: 17 additions & 3 deletions scripts/xtensa-build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ SUPPORTED_PLATFORMS=( "${DEFAULT_PLATFORMS[@]}" )
# Container work is in progress
SUPPORTED_PLATFORMS+=( acp_6_3 acp_7_0 )

# Platforms support xt-clang compiler build
CLANG_BUILD_PLATFORMS=( acp_7_0 )

BUILD_ROM=no
BUILD_DEBUG=no
BUILD_FORCE_UP=no
Expand Down Expand Up @@ -213,7 +216,12 @@ do
# make sure the required version of xtensa tools is installed
if [ -d "$XTENSA_TOOLS_DIR" ]
then
XCC="xt-xcc"
if [[ ${CLANG_BUILD_PLATFORMS[@]} =~ $platform ]]
then
XCC="xt-clang"
else
XCC="xt-xcc"
fi
else
XCC="none"
>&2 printf 'WARNING: %s
Expand All @@ -225,7 +233,7 @@ do
# --sysroot would.
ROOT="$SOF_TOP/../xtensa-root/$HOST"

if [ "$XCC" == "xt-xcc" ]
if [ "$XCC" == "xt-xcc" ] || [ "$XCC" == "xt-clang" ]
then
TOOLCHAIN=xt
ROOT="$XTENSA_BUILDS_DIR/$XTENSA_CORE/xtensa-elf"
Expand All @@ -234,7 +242,12 @@ do
export XTENSA_SYSTEM=$XTENSA_BUILDS_DIR/$XTENSA_CORE/config
printf 'XTENSA_SYSTEM=%s\n' "${XTENSA_SYSTEM}"
PATH=$XTENSA_TOOLS_DIR/XtensaTools/bin:$OLDPATH
COMPILER="xcc"
if [ "$XCC" == "xt-clang" ]
then
COMPILER="clang"
else
COMPILER="xcc"
fi
else
TOOLCHAIN=$HOST
PATH=$SOF_TOP/../$HOST/bin:$OLDPATH
Expand All @@ -253,6 +266,7 @@ do
printf 'PATH=%s\n' "$PATH"
( set -x # log the main commands and their parameters
cmake -DTOOLCHAIN="$TOOLCHAIN" \
-DCOMPILER="$COMPILER" \
-DROOT_DIR="$ROOT" \
-DMEU_OPENSSL="${MEU_OPENSSL}" \
"${MEU_PATH_OPTION}" \
Expand Down
39 changes: 27 additions & 12 deletions src/arch/xtensa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,33 @@ separate_arguments(EXTRA_CFLAGS_AS_LIST NATIVE_COMMAND ${EXTRA_CFLAGS})

# No space between -imacros and its argument to avoid CMake
# de-duplication "feature"
target_compile_options(sof_options INTERFACE
$<$<COMPILE_LANGUAGE:C>:
-${optimization_flag} -g
-Wall -Werror
-Wl,-EL
-Wmissing-prototypes
-Wpointer-arith
${XTENSA_C_FLAGS}
${EXTRA_CFLAGS_AS_LIST}
>
-imacros${CONFIG_H_PATH}
)
if(CMAKE_C_COMPILER MATCHES "xt-clang")
target_compile_options(sof_options INTERFACE
$<$<COMPILE_LANGUAGE:C>:
-${optimization_flag} -g
-Wall -Werror
-EL
-Wmissing-prototypes
-Wpointer-arith
${XTENSA_C_FLAGS}
${EXTRA_CFLAGS_AS_LIST}
>
-imacros${CONFIG_H_PATH}
)
else()
target_compile_options(sof_options INTERFACE
$<$<COMPILE_LANGUAGE:C>:
-${optimization_flag} -g
-Wall -Werror
-Wl,-EL
-Wmissing-prototypes
-Wpointer-arith
${XTENSA_C_FLAGS}
${EXTRA_CFLAGS_AS_LIST}
>
-imacros${CONFIG_H_PATH}
)
endif()

if(BUILD_UNIT_TESTS)
# rest of this file is not needed for unit tests
Expand Down
8 changes: 8 additions & 0 deletions src/arch/xtensa/include/xtensa/config/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@

#endif

#if defined(CONFIG_ACP_7_0)

#ifndef UINT32_C
#define UINT32_C(x) x
#endif

#endif

/* CONFIGURATION INDEPENDENT DEFINITIONS: */
#ifdef __XTENSA__
#include <xtensa/hal.h>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static void validate_memory(void *ptr, size_t size)
}
#endif

#ifndef CONFIG_ACP_7_0
/* total size of block */
static inline uint32_t block_get_size(struct block_map *map)
{
Expand All @@ -92,6 +93,7 @@ static inline uint32_t heap_get_size(struct mm_heap *heap)

return size;
}
#endif

#if CONFIG_DEBUG_BLOCK_FREE
static void write_pattern(struct mm_heap *heap_map, int heap_depth,
Expand Down

0 comments on commit 34e5f7a

Please sign in to comment.