diff options
| author | Frédéric Desbiens <[email protected]> | 2026-10-02 10:42:44 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-10-02 10:42:44 -0400 |
| commit | 93387b0a60382a29579bbad5045c68328e3751df (patch) | |
| tree | 42be790d602cb76f55090e5a7c418df7ea2b3428 /cmake/cortex_r52_clang.cmake | |
| parent | 44d7c95c582d415c4ad84527180b29c93c3bf664 (diff) | |
| parent | 28281cd5647d4671236ca08d19bd18ed15b2265a (diff) | |
Merge pull request #783 from eclipse-threadx/devv6.5.2.202603_rel
Merged changes ahead of the v6.5.2.202603 release
Diffstat (limited to 'cmake/cortex_r52_clang.cmake')
| -rw-r--r-- | cmake/cortex_r52_clang.cmake | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/cmake/cortex_r52_clang.cmake b/cmake/cortex_r52_clang.cmake new file mode 100644 index 00000000..f5669efa --- /dev/null +++ b/cmake/cortex_r52_clang.cmake @@ -0,0 +1,84 @@ +# 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=<dir containing clang>. +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") |
