• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("clang_config.gni")
18
19cortex_m_common_flags = [
20  "-mabi=aapcs",
21  "-mthumb",
22]
23
24cortex_m_software_fpu_flags = [ "-mfloat-abi=soft" ]
25
26cortex_m_hardware_fpu_flags_common = [
27  "-mfloat-abi=hard",
28
29  # Used by some pigweed tests/targets to correctly handle hardware FPU
30  # behavior.
31  "-DPW_ARMV7M_ENABLE_FPU=1",
32]
33
34cortex_m_hardware_fpu_flags =
35    cortex_m_hardware_fpu_flags_common + [ "-mfpu=fpv4-sp-d16" ]
36
37cortex_m_hardware_fpu_v5_flags =
38    cortex_m_hardware_fpu_flags_common + [ "-mfpu=fpv5-d16" ]
39
40cortex_m_hardware_fpu_v5_sp_flags =
41    cortex_m_hardware_fpu_flags_common + [ "-mfpu=fpv5-sp-d16" ]
42
43# Default config added to all the ARM cortex M targets to link `nosys` library.
44config("nosys") {
45  libs = [ "nosys" ]
46}
47
48config("enable_float_printf") {
49  ldflags = [ "-Wl,-u_printf_float" ]
50}
51
52pw_clang_arm_config("cortex_m0plus") {
53  cflags = [ "-mcpu=cortex-m0plus" ]
54  cflags += cortex_m_common_flags
55  cflags += cortex_m_software_fpu_flags
56  asmflags = cflags
57  ldflags = cflags
58}
59
60pw_clang_arm_config("cortex_m3") {
61  cflags = [ "-mcpu=cortex-m3" ]
62  cflags += cortex_m_common_flags
63  cflags += cortex_m_software_fpu_flags
64  asmflags = cflags
65  ldflags = cflags
66}
67
68pw_clang_arm_config("cortex_m4") {
69  cflags = [ "-mcpu=cortex-m4" ]
70  cflags += cortex_m_common_flags
71  cflags += cortex_m_software_fpu_flags
72  asmflags = cflags
73  ldflags = cflags
74}
75
76pw_clang_arm_config("cortex_m4f") {
77  cflags = [ "-mcpu=cortex-m4" ]
78  cflags += cortex_m_common_flags
79  cflags += cortex_m_hardware_fpu_flags
80  asmflags = cflags
81  ldflags = cflags
82}
83
84pw_clang_arm_config("cortex_m7") {
85  cflags = [ "-mcpu=cortex-m7" ]
86  cflags += cortex_m_common_flags
87  cflags += cortex_m_software_fpu_flags
88  asmflags = cflags
89  ldflags = cflags
90}
91
92pw_clang_arm_config("cortex_m7f") {
93  cflags = [ "-mcpu=cortex-m7" ]
94  cflags += cortex_m_common_flags
95  cflags += cortex_m_hardware_fpu_v5_flags
96  asmflags = cflags
97  ldflags = cflags
98}
99
100pw_clang_arm_config("cortex_m33") {
101  cflags = [ "-mcpu=cortex-m33" ]
102  cflags += cortex_m_common_flags
103  cflags += cortex_m_software_fpu_flags
104  asmflags = cflags
105  ldflags = cflags
106}
107
108pw_clang_arm_config("cortex_m33f") {
109  cflags = [ "-mcpu=cortex-m33" ]
110  cflags += cortex_m_common_flags
111  cflags += cortex_m_hardware_fpu_v5_sp_flags
112  asmflags = cflags
113  ldflags = cflags
114}
115