Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtensa: enhanced handling of toolchain environment variables #79573

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/xtensa/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ set(CORE_ISA_DM ${CMAKE_BINARY_DIR}/zephyr/include/generated/zephyr/core-isa-dM.
set(CORE_ISA_IN ${CMAKE_BINARY_DIR}/zephyr/include/generated/core-isa-dM.c)
file(WRITE ${CORE_ISA_IN} "#include <xtensa/config/core-isa.h>\n")
add_custom_command(OUTPUT ${CORE_ISA_DM}
COMMAND ${CMAKE_C_COMPILER} -E -dM -U__XCC__
COMMAND ${CMAKE_C_COMPILER} -E -dM -U__XCC__ ${XTENSA_CORE_LOCAL_C_FLAG}
-I${ZEPHYR_XTENSA_MODULE_DIR}/zephyr/soc/${CONFIG_SOC}
-I${SOC_FULL_DIR}
${CORE_ISA_IN} -o ${CORE_ISA_DM})
Expand Down
4 changes: 2 additions & 2 deletions cmake/compiler/xcc/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ TOOLCHAIN_VER: ${TOOLCHAIN_VER}
endif()

execute_process(
COMMAND ${CMAKE_C_COMPILER} --version
COMMAND ${CMAKE_C_COMPILER} --version ${XTENSA_CORE_LOCAL_C_FLAG}
RESULT_VARIABLE ret
OUTPUT_VARIABLE stdoutput
)
if(ret)
message(FATAL_ERROR "Executing the below command failed. Are permissions set correctly?
${CMAKE_C_COMPILER} --version
${CMAKE_C_COMPILER} --version ${XTENSA_CORE_LOCAL_C_FLAG}
${stdoutput}
"
)
Expand Down
19 changes: 18 additions & 1 deletion cmake/toolchain/xcc/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ if(NOT EXISTS ${XTENSA_TOOLCHAIN_PATH})
message(FATAL_ERROR "Nothing found at XTENSA_TOOLCHAIN_PATH: '${XTENSA_TOOLCHAIN_PATH}'")
endif()

set(TOOLCHAIN_HOME ${XTENSA_TOOLCHAIN_PATH}/$ENV{TOOLCHAIN_VER}/XtensaTools)
if(DEFINED ENV{TOOLCHAIN_VER})
set(XTENSA_TOOLCHAIN_VER $ENV{TOOLCHAIN_VER})
elseif(DEFINED ENV{TOOLCHAIN_VER_${NORMALIZED_BOARD_TARGET}})
set(XTENSA_TOOLCHAIN_VER $ENV{TOOLCHAIN_VER_${NORMALIZED_BOARD_TARGET}})
else()
message(FATAL "Environment variable TOOLCHAIN_VER must be set")
endif()

if(DEFINED ENV{XTENSA_CORE_${NORMALIZED_BOARD_TARGET}})
set(XTENSA_CORE_LOCAL_C_FLAG "--xtensa-core=$ENV{XTENSA_CORE_${NORMALIZED_BOARD_TARGET}}")
list(APPEND TOOLCHAIN_C_FLAGS "--xtensa-core=$ENV{XTENSA_CORE_${NORMALIZED_BOARD_TARGET}}")
else()
# Not having XTENSA_CORE is not necessarily fatal as
# the toolchain can have a default core configuration to use.
set(XTENSA_CORE_LOCAL_C_FLAG)
endif()

set(TOOLCHAIN_HOME ${XTENSA_TOOLCHAIN_PATH}/${XTENSA_TOOLCHAIN_VER}/XtensaTools)

set(LINKER ld)
set(BINTOOLS gnu)
Expand Down
10 changes: 10 additions & 0 deletions cmake/toolchain/xt-clang/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ set(CC clang)
set(C++ clang++)
set(LINKER xt-ld)

# xt-clang uses GNU Assembler (xt-as) based on binutils.
# However, CMake doesn't recognize it when invoking through xt-clang.
# This results in CMake going through all possible combinations of
# command line arguments while invoking xt-clang to determine
# assembler vendor. This multiple invocation of xt-clang unnecessarily
# lengthens the CMake phase of build, especially when xt-clang needs to
# obtain license information from remote licensing servers. So here
# forces the assembler ID to be GNU to speed things up a bit.
set(CMAKE_ASM_COMPILER_ID "GNU")

message(STATUS "Found toolchain: xt-clang (${XTENSA_TOOLCHAIN_PATH})")
Loading