# Copyright (c) 2026 Eclipse ThreadX contributors # SPDX-License-Identifier: MIT # Portions of this file were generated with AI assistance. # # Toolchain file for Arm Cortex-R52 (Armv8-R, AArch32) using Arm Toolchain for # Embedded, which is LLVM based and is the successor to Arm Compiler 6. # # There is no separate clang port directory: this builds the gnu port sources # with a different compiler, which is the same thing scripts/check_clang.sh does # for every other Arm port. THREADX_TOOLCHAIN stays "gnu" for that reason. # # cmake -S . -B build -G Ninja \ # -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_r52_clang.cmake \ # -DTX_R52_BUILD_FVP_EXAMPLE=ON set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_PROCESSOR cortex-r52) set(THREADX_ARCH "cortex_r52") set(THREADX_TOOLCHAIN "gnu") # Tool names as found on PATH, which is what CI uses: the workflow unpacks the # toolchain into the workspace and scripts/check_clang.sh passes its location # through as ATFE_TOOLCHAIN_PATH. set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) set(CMAKE_ASM_COMPILER clang) set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(OBJCOPY llvm-objcopy) set(OBJDUMP llvm-objdump) set(SIZE llvm-size) # Then pin a specific install if one is present, the way cortex_r52.cmake pins # the GNU toolchain and for the same reason: a local build should not depend on # PATH ordering. Absent that directory this falls back to the names above rather # than failing, so the file works on a machine that keeps clang elsewhere. # Override with -DATFE_TOOLCHAIN_PATH=. if(NOT DEFINED ATFE_TOOLCHAIN_PATH) set(ATFE_TOOLCHAIN_PATH "$ENV{HOME}/toolchains/ATfE-22.1.0-Linux-x86_64/bin") endif() if(EXISTS "${ATFE_TOOLCHAIN_PATH}/clang") set(CMAKE_C_COMPILER "${ATFE_TOOLCHAIN_PATH}/clang") set(CMAKE_CXX_COMPILER "${ATFE_TOOLCHAIN_PATH}/clang++") set(CMAKE_ASM_COMPILER "${ATFE_TOOLCHAIN_PATH}/clang") set(CMAKE_AR "${ATFE_TOOLCHAIN_PATH}/llvm-ar") set(CMAKE_RANLIB "${ATFE_TOOLCHAIN_PATH}/llvm-ranlib") set(OBJCOPY "${ATFE_TOOLCHAIN_PATH}/llvm-objcopy") set(OBJDUMP "${ATFE_TOOLCHAIN_PATH}/llvm-objdump") set(SIZE "${ATFE_TOOLCHAIN_PATH}/llvm-size") endif() set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # Link the try-compile as a static library, so probing the compiler does not # need a linker script or a target C library. set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) if(NOT DEFINED TX_R52_FLOAT_ABI) set(TX_R52_FLOAT_ABI "soft" CACHE STRING "R52 float ABI: soft | hard") endif() set(MCPU_FLAGS "--target=arm-none-eabi -marm -mcpu=cortex-r52") if(TX_R52_FLOAT_ABI STREQUAL "hard") set(VFP_FLAGS "-mfpu=fpv5-d16 -mfloat-abi=hard") else() set(VFP_FLAGS "-mfloat-abi=soft") endif() set(CMAKE_C_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fdata-sections -ffunction-sections -mlong-calls" CACHE INTERNAL "c compiler flags") set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls" CACHE INTERNAL "cxx compiler flags") set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags") set(CMAKE_EXE_LINKER_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fuse-ld=lld -Wl,--gc-sections" CACHE INTERNAL "exe link flags") set(CMAKE_C_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "c debug compiler flags") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "cxx debug compiler flags") set(CMAKE_ASM_FLAGS_DEBUG "-g" CACHE INTERNAL "asm debug compiler flags") set(CMAKE_C_FLAGS_RELEASE "-O3" CACHE INTERNAL "c release compiler flags") set(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE INTERNAL "cxx release compiler flags") set(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")