1# SPDX-License-Identifier: Apache-2.0
2
3set(ARM_C_FLAGS)
4
5list(APPEND ARM_C_FLAGS   -mcpu=${GCC_M_CPU})
6
7if(CONFIG_COMPILER_ISA_THUMB2)
8  list(APPEND ARM_C_FLAGS   -mthumb)
9endif()
10
11list(APPEND ARM_C_FLAGS -mabi=aapcs)
12
13if(CONFIG_BIG_ENDIAN)
14  list(APPEND TOOLCHAIN_C_FLAGS -mbig-endian)
15  list(APPEND TOOLCHAIN_LD_FLAGS -mbig-endian)
16endif()
17
18if(CONFIG_FPU)
19  list(APPEND ARM_C_FLAGS   -mfpu=${GCC_M_FPU})
20
21  if(CONFIG_DCLS AND NOT CONFIG_FP_HARDABI)
22    # If the processor is equipped with VFP and configured in DCLS topology,
23    # the FP "hard" ABI must be used in order to facilitate the FP register
24    # initialisation and synchronisation.
25    set(FORCE_FP_HARDABI TRUE)
26  endif()
27
28  if    (CONFIG_FP_HARDABI OR FORCE_FP_HARDABI)
29    list(APPEND ARM_C_FLAGS   -mfloat-abi=hard)
30  elseif(CONFIG_FP_SOFTABI)
31    list(APPEND ARM_C_FLAGS   -mfloat-abi=softfp)
32  endif()
33endif()
34
35if(CONFIG_FP16)
36  if    (CONFIG_FP16_IEEE)
37    list(APPEND ARM_C_FLAGS   -mfp16-format=ieee)
38  elseif(CONFIG_FP16_ALT)
39    list(APPEND ARM_C_FLAGS   -mfp16-format=alternative)
40  endif()
41endif()
42
43if(CONFIG_THREAD_LOCAL_STORAGE)
44    list(APPEND ARM_C_FLAGS -mtp=soft)
45endif()
46
47list(APPEND TOOLCHAIN_C_FLAGS ${ARM_C_FLAGS})
48list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT ${ARM_C_FLAGS})
49
50# Flags not supported by llext linker
51# (regexps are supported and match whole word)
52set(LLEXT_REMOVE_FLAGS
53  -fno-pic
54  -fno-pie
55  -ffunction-sections
56  -fdata-sections
57  -g.*
58  -Os
59)
60
61# Flags to be added to llext code compilation
62set(LLEXT_APPEND_FLAGS
63  -mlong-calls
64  -mthumb
65)
66
67list(APPEND LLEXT_EDK_REMOVE_FLAGS
68    --sysroot=.*
69    -fmacro-prefix-map=.*
70    )
71
72list(APPEND LLEXT_EDK_APPEND_FLAGS
73    -nodefaultlibs
74    )
75