xtensa: provide XCC compiler support for Xtensa
This patchset provides Xtensa's xcc compiler support for Xtensa projects in Cmake. This requires the below environment variables to be defined aptly. The appropriate xcc license information also need to be supplied. ZEPHYR_GCC_VARIANT=xcc TOOLCHAIN_VER=RF-2015.3-linux XTENSA_CORE=cavs21_LX6HiFi3_RF3_WB16 XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/tools/ RF-2015.3-linux/XtensaTools/config/ XTENSA_BUILD_PATHS=/opt/xtensa/XtDevTools/install/builds/ Change-Id: Ib3c10e8095439b0e32276ff37c00eca8420773ec Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com> Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
b3153d2405
commit
08172cdf83
|
@ -103,6 +103,7 @@ zephyr_compile_options(
|
|||
-ffreestanding
|
||||
-Wno-main
|
||||
${NOSTDINC_F}
|
||||
${TOOLCHAIN_C_FLAGS}
|
||||
)
|
||||
|
||||
zephyr_compile_options(
|
||||
|
@ -230,6 +231,7 @@ else() # GCC assumed
|
|||
-Wno-unused-but-set-variable
|
||||
-fno-reorder-functions
|
||||
)
|
||||
|
||||
if(NOT ${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "xcc")
|
||||
zephyr_cc_option(-fno-defer-pop)
|
||||
endif()
|
||||
|
@ -637,6 +639,14 @@ set(zephyr_lnk
|
|||
)
|
||||
|
||||
if(CONFIG_GEN_ISR_TABLES)
|
||||
if(CONFIG_GEN_SW_ISR_TABLE)
|
||||
list(APPEND GEN_ISR_TABLE_EXTRA_ARG --sw-isr-table)
|
||||
endif()
|
||||
|
||||
if(CONFIG_GEN_IRQ_VECTOR_TABLE)
|
||||
list(APPEND GEN_ISR_TABLE_EXTRA_ARG --vector-table)
|
||||
endif()
|
||||
|
||||
# isr_tables.c is generated from zephyr_prebuilt by
|
||||
# gen_isr_tables.py
|
||||
add_custom_command(
|
||||
|
@ -653,8 +663,7 @@ if(CONFIG_GEN_ISR_TABLES)
|
|||
--kernel $<TARGET_FILE:zephyr_prebuilt>
|
||||
--intlist isrList.bin
|
||||
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--debug>
|
||||
--sw-isr-table
|
||||
--vector-table
|
||||
${GEN_ISR_TABLE_EXTRA_ARG}
|
||||
DEPENDS zephyr_prebuilt
|
||||
)
|
||||
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_SOURCE_FILES isr_tables.c)
|
||||
|
|
|
@ -15,7 +15,6 @@ endif()
|
|||
|
||||
zephyr_compile_options(
|
||||
-mabi=aapcs
|
||||
${TOOLCHAIN_C_FLAGS}
|
||||
${ARCH_FLAG}
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ zephyr_compile_options(
|
|||
-m32
|
||||
-MMD
|
||||
-MP
|
||||
${TOOLCHAIN_C_FLAGS}
|
||||
${ARCH_FLAG}
|
||||
-include ${PROJECT_SOURCE_DIR}/arch/posix/include/posix_cheats.h
|
||||
)
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
set_ifndef(CC gcc)
|
||||
set_ifndef(C++ g++)
|
||||
|
||||
# Configures CMake for using GCC, this script is re-used by several
|
||||
# GCC-based toolchains
|
||||
|
||||
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_OBJDUMP ${CROSS_COMPILE}objdump PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
#find_program(CMAKE_LINKER ${CROSS_COMPILE}ld PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_AS ${CROSS_COMPILE}as PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_LINKER ${CROSS_COMPILE}ld PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_AR ${CROSS_COMPILE}ar PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_RANLIB ${CROSS_COMPILE}ranlib PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
find_program(CMAKE_READELF ${CROSS_COMPILE}readelf PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
||||
|
@ -22,10 +25,10 @@ TOOLCHAIN_HOME: ${TOOLCHAIN_HOME}
|
|||
endif()
|
||||
|
||||
if(CONFIG_CPLUSPLUS)
|
||||
set(cplusplus_compiler ${CROSS_COMPILE}g++)
|
||||
set(cplusplus_compiler ${CROSS_COMPILE}${C++})
|
||||
else()
|
||||
if(EXISTS ${CROSS_COMPILE}g++)
|
||||
set(cplusplus_compiler ${CROSS_COMPILE}g++)
|
||||
if(EXISTS ${CROSS_COMPILE}${C++})
|
||||
set(cplusplus_compiler ${CROSS_COMPILE}${C++})
|
||||
else()
|
||||
# When the toolchain doesn't support C++, and we aren't building
|
||||
# with C++ support just set it to something so CMake doesn't
|
||||
|
@ -58,56 +61,64 @@ foreach(file_name include include-fixed)
|
|||
list(APPEND NOSTDINC ${_OUTPUT})
|
||||
endforeach()
|
||||
|
||||
include(${ZEPHYR_BASE}/cmake/gcc-m-cpu.cmake)
|
||||
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "xcc")
|
||||
|
||||
if("${ARCH}" STREQUAL "arm")
|
||||
list(APPEND TOOLCHAIN_C_FLAGS
|
||||
-mthumb
|
||||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
LIST(APPEND TOOLCHAIN_LIBS gcc)
|
||||
LIST(APPEND TOOLCHAIN_LIBS hal)
|
||||
|
||||
include(${ZEPHYR_BASE}/cmake/fpu-for-gcc-m-cpu.cmake)
|
||||
else()
|
||||
include(${ZEPHYR_BASE}/cmake/gcc-m-cpu.cmake)
|
||||
|
||||
if(CONFIG_FLOAT)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfpu=${FPU_FOR_${GCC_M_CPU}})
|
||||
if (CONFIG_FP_SOFTABI)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfloat-abi=softfp)
|
||||
elseif(CONFIG_FP_HARDABI)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfloat-abi=hard)
|
||||
if("${ARCH}" STREQUAL "arm")
|
||||
list(APPEND TOOLCHAIN_C_FLAGS
|
||||
-mthumb
|
||||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
|
||||
include(${ZEPHYR_BASE}/cmake/fpu-for-gcc-m-cpu.cmake)
|
||||
|
||||
if(CONFIG_FLOAT)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfpu=${FPU_FOR_${GCC_M_CPU}})
|
||||
if (CONFIG_FP_SOFTABI)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfloat-abi=soft)
|
||||
elseif(CONFIG_FP_HARDABI)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mfloat-abi=hard)
|
||||
endif()
|
||||
endif()
|
||||
elseif("${ARCH}" STREQUAL "arc")
|
||||
list(APPEND TOOLCHAIN_C_FLAGS
|
||||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
endif()
|
||||
elseif("${ARCH}" STREQUAL "arc")
|
||||
list(APPEND TOOLCHAIN_C_FLAGS
|
||||
-mcpu=${GCC_M_CPU}
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
|
||||
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
|
||||
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
assert_exists(LIBGCC_FILE_NAME)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-multi-directory
|
||||
OUTPUT_VARIABLE NEWLIB_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
|
||||
|
||||
assert_exists(LIBGCC_FILE_NAME)
|
||||
assert_exists(LIBGCC_DIR)
|
||||
|
||||
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
|
||||
LIST(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
|
||||
LIST(APPEND TOOLCHAIN_LIBS gcc)
|
||||
|
||||
assert_exists(LIBGCC_DIR)
|
||||
if(SYSROOT_DIR)
|
||||
# The toolchain has specified a sysroot dir that we can use to set
|
||||
# the libc path's
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-multi-directory
|
||||
OUTPUT_VARIABLE NEWLIB_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
LIST(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
|
||||
LIST(APPEND TOOLCHAIN_LIBS gcc)
|
||||
set(LIBC_LIBRARY_DIR "\"${SYSROOT_DIR}\"/lib/${NEWLIB_DIR}")
|
||||
set(LIBC_INCLUDE_DIR ${SYSROOT_DIR}/include)
|
||||
endif()
|
||||
|
||||
if(SYSROOT_DIR)
|
||||
# The toolchain has specified a sysroot dir that we can use to set
|
||||
# the libc path's
|
||||
set(LIBC_INCLUDE_DIR ${SYSROOT_DIR}/include)
|
||||
set(LIBC_LIBRARY_DIR "\"${SYSROOT_DIR}\"/lib/${NEWLIB_DIR}")
|
||||
endif()
|
||||
|
||||
# For CMake to be able to test if a compiler flag is supported by the
|
||||
|
|
18
cmake/toolchain/xcc.cmake
Normal file
18
cmake/toolchain/xcc.cmake
Normal file
|
@ -0,0 +1,18 @@
|
|||
set(TOOLCHAIN_HOME /opt/xtensa/XtDevTools/install/tools/$ENV{TOOLCHAIN_VER}/XtensaTools)
|
||||
|
||||
set(COMPILER gcc)
|
||||
|
||||
set(CROSS_COMPILE_TARGET xt)
|
||||
set(SYSROOT_TARGET xtensa-elf)
|
||||
|
||||
set(CROSS_COMPILE ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-)
|
||||
set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET})
|
||||
set(XCC_BUILD $ENV{XTENSA_BUILD_PATHS}/$ENV{TOOLCHAIN_VER}/${CONFIG_SOC})
|
||||
|
||||
# xt-xcc does not support -Og, so make it -O0
|
||||
set(OPTIMIZE_FOR_DEBUG_FLAG "-O0")
|
||||
|
||||
set(CC xcc)
|
||||
set(C++ xc++)
|
||||
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -fms-extensions)
|
|
@ -36,4 +36,12 @@
|
|||
|
||||
#endif /* __GCC_LINKER_CMD__ */
|
||||
|
||||
#define __builtin_unreachable() __ASSERT(0, "Unreachable code")
|
||||
|
||||
/* TODO: XCC doesn't define the below macros which are useful for checking
|
||||
* overflows. This needs to be fixed.
|
||||
*/
|
||||
#define __builtin_add_overflow(a, b, output) ({ *output = (a) + (b); 0; })
|
||||
#define __builtin_mul_overflow(a, b, output) ({ *output = (a) * (b); 0; })
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue