summaryrefslogtreecommitdiff
path: root/cmake/aarch64-none-elf.cmake
blob: dada9fec1538a1c2d9fdf96105cff50f74c034ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright (c) 2026 Eclipse ThreadX contributors
# SPDX-License-Identifier: MIT
# Portions of this file were generated with AI assistance.
#
# Shared settings for the AArch64 bare metal ports, the counterpart of
# arm-none-eabi.cmake beside it. The two differ by more than the tool prefix:
# AArch64 has no -marm or -mthumb to choose between, no -mfloat-abi, and
# aarch64-none-elf-gcc rejects -mlong-calls outright, so that flag cannot simply
# be carried across.
#
# The tools are named without a path, so an aarch64-none-elf toolchain must be
# on PATH. Override CMAKE_C_COMPILER and friends on the command line to use one
# that is not.

# Toolchain settings
set(CMAKE_C_COMPILER    aarch64-none-elf-gcc)
set(CMAKE_CXX_COMPILER  aarch64-none-elf-g++)
set(AS                  aarch64-none-elf-as)
set(AR                  aarch64-none-elf-ar)
set(OBJCOPY             aarch64-none-elf-objcopy)
set(OBJDUMP             aarch64-none-elf-objdump)
set(SIZE                aarch64-none-elf-size)

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)

# Build the try-compile as a static library so no linker script or startup code
# is needed just to test the compiler.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(CMAKE_C_FLAGS   "${MCPU_FLAGS} ${VFP_FLAGS} ${SPEC_FLAGS} -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions" 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} ${LD_FLAGS} -Wl,--gc-sections" CACHE INTERNAL "exe link flags")

set(CMAKE_C_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")
set(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" 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")