cmake: llvm: arm64: Set arm64 flags when building with clang

Ensure --target and -mcpu/-mfpu/-mtune are set appropriately when building
with clang targeting arm64/aarch64.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
This commit is contained in:
Jonathon Penix 2024-03-08 16:37:49 -08:00 committed by Alberto Escolar
commit 97a734aa01
3 changed files with 19 additions and 0 deletions

View file

@ -31,6 +31,8 @@ if(NOT "${ARCH}" STREQUAL "posix")
)
include(${ZEPHYR_BASE}/cmake/compiler/clang/target_arm.cmake)
elseif("${ARCH}" STREQUAL "arm64")
include(${ZEPHYR_BASE}/cmake/compiler/clang/target_arm64.cmake)
elseif("${ARCH}" STREQUAL "riscv")
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_riscv.cmake)
endif()

View file

@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0
if(DEFINED GCC_M_CPU)
list(APPEND TOOLCHAIN_C_FLAGS -mcpu=${GCC_M_CPU})
list(APPEND TOOLCHAIN_LD_FLAGS -mcpu=${GCC_M_CPU})
endif()
if(DEFINED GCC_M_ARCH)
list(APPEND TOOLCHAIN_C_FLAGS -march=${GCC_M_ARCH})
list(APPEND TOOLCHAIN_LD_FLAGS -march=${GCC_M_ARCH})
endif()
if(DEFINED GCC_M_TUNE)
list(APPEND TOOLCHAIN_C_FLAGS -mtune=${GCC_M_TUNE})
list(APPEND TOOLCHAIN_LD_FLAGS -mtune=${GCC_M_TUNE})
endif()

View file

@ -25,6 +25,8 @@ if("${ARCH}" STREQUAL "arm")
# Default ARM target supported by all processors.
set(triple arm-none-eabi)
endif()
elseif("${ARCH}" STREQUAL "arm64")
set(triple aarch64-none-elf)
elseif("${ARCH}" STREQUAL "x86")
if(CONFIG_64BIT)
set(triple x86_64-pc-none-elf)