Armando Montanez | c931834 | 2023-10-31 19:55:27 +0000 | [diff] [blame] | 1 | # Copyright 2023 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 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | import("//build_overrides/pigweed_environment.gni") |
| 17 | |
| 18 | import("$dir_pw_build/target_types.gni") |
| 19 | |
| 20 | # Disable obnoxious ABI warning. |
| 21 | # |
| 22 | # GCC 7.1 adds an over-zealous ABI warning with little useful information |
| 23 | # on how to resolve the issue. The warning you get is: |
| 24 | # |
| 25 | # note: parameter passing for argument of type '...' changed in GCC 7.1 |
| 26 | # |
| 27 | # There is no other information, and searching for the error is needed to |
| 28 | # understand what is happening. For upstream Pigweed, we compile from |
| 29 | # source so this is irrelevant; so disable it. |
| 30 | # |
| 31 | # See: https://gcc.gnu.org/gcc-7/changes.html (search for "psabi"). |
| 32 | # https://gcc.gnu.org/ml/gcc/2017-05/msg00073.html |
| 33 | config("disable_psabi_warning") { |
| 34 | cflags = [ "-Wno-psabi" ] |
| 35 | } |
| 36 | |
| 37 | config("thumb") { |
| 38 | asmflags = [ |
| 39 | "-mabi=aapcs", |
| 40 | "-mthumb", |
| 41 | ] |
| 42 | cflags = asmflags |
| 43 | ldflags = cflags |
| 44 | } |
| 45 | |
| 46 | config("newlib_nano") { |
| 47 | cflags = [ |
| 48 | "--sysroot=" + rebase_path(pw_env_setup_CIPD_ARM, root_build_dir), |
| 49 | "-specs=nano.specs", |
| 50 | ] |
| 51 | ldflags = cflags + [ "-lc" ] |
| 52 | } |
| 53 | |
| 54 | config("nosys") { |
| 55 | cflags = [ "-specs=nosys.specs" ] |
| 56 | ldflags = cflags + [ "-lnosys" ] |
| 57 | } |
| 58 | |
| 59 | config("enable_float_printf") { |
| 60 | cflags = [ "-u_printf_float" ] |
| 61 | ldflags = cflags |
| 62 | } |
| 63 | |
| 64 | config("cortex_m0") { |
| 65 | cflags = [ "-mcpu=cortex-m0" ] |
| 66 | asmflags = cflags |
| 67 | ldflags = cflags |
| 68 | } |
| 69 | |
| 70 | config("cortex_m0_small_multiply") { |
| 71 | cflags = [ "-mcpu=cortex-m0.small-multiply" ] |
| 72 | asmflags = cflags |
| 73 | ldflags = cflags |
| 74 | } |
| 75 | |
| 76 | config("cortex_m0plus") { |
| 77 | cflags = [ "-mcpu=cortex-m0plus" ] |
| 78 | asmflags = cflags |
| 79 | ldflags = cflags |
| 80 | } |
| 81 | |
| 82 | config("cortex_m0plus_small_multiply") { |
| 83 | cflags = [ "-mcpu=cortex-m0plus.small-multiply" ] |
| 84 | asmflags = cflags |
| 85 | ldflags = cflags |
| 86 | } |
| 87 | |
| 88 | config("cortex_m1") { |
| 89 | cflags = [ "-mcpu=cortex-m1" ] |
| 90 | asmflags = cflags |
| 91 | ldflags = cflags |
| 92 | } |
| 93 | |
| 94 | config("cortex_m1_small_multiply") { |
| 95 | cflags = [ "-mcpu=cortex-m1.small-multiply" ] |
| 96 | asmflags = cflags |
| 97 | ldflags = cflags |
| 98 | } |
| 99 | |
| 100 | config("cortex_m3") { |
| 101 | cflags = [ "-mcpu=cortex-m3" ] |
| 102 | asmflags = cflags |
| 103 | ldflags = cflags |
| 104 | } |
| 105 | |
| 106 | config("cortex_m4") { |
| 107 | cflags = [ "-mcpu=cortex-m4" ] |
| 108 | asmflags = cflags |
| 109 | ldflags = cflags |
| 110 | } |
| 111 | |
| 112 | config("cortex_m7") { |
| 113 | cflags = [ "-mcpu=cortex-m7" ] |
| 114 | asmflags = cflags |
| 115 | ldflags = cflags |
| 116 | } |
| 117 | |
| 118 | config("cortex_m23") { |
| 119 | cflags = [ "-mcpu=cortex-m23" ] |
| 120 | asmflags = cflags |
| 121 | ldflags = cflags |
| 122 | } |
| 123 | |
| 124 | config("cortex_m33") { |
| 125 | cflags = [ "-mcpu=cortex-m33" ] |
| 126 | asmflags = cflags |
| 127 | ldflags = cflags |
| 128 | } |
| 129 | |
| 130 | config("cortex_m35p") { |
| 131 | cflags = [ "-mcpu=cortex-m35p" ] |
| 132 | asmflags = cflags |
| 133 | ldflags = cflags |
| 134 | } |
| 135 | |
| 136 | config("cortex_m55") { |
| 137 | cflags = [ "-mcpu=cortex-m33" ] |
| 138 | asmflags = cflags |
| 139 | ldflags = cflags |
| 140 | } |
| 141 | |
| 142 | config("fpu_soft") { |
| 143 | cflags = [ "-mfloat-abi=soft" ] |
| 144 | asmflags = cflags |
| 145 | ldflags = cflags |
| 146 | } |
| 147 | |
| 148 | config("fpu_fpv4_sp") { |
| 149 | cflags = [ |
| 150 | "-mfloat-abi=hard", |
| 151 | "-mfpu=fpv4-sp-d16", |
| 152 | ] |
| 153 | asmflags = cflags |
| 154 | defines = [ "PW_ARMV7M_ENABLE_FPU=1" ] |
| 155 | ldflags = cflags |
| 156 | } |
| 157 | |
| 158 | config("fpu_fpv5") { |
| 159 | cflags = [ |
| 160 | "-mfloat-abi=hard", |
| 161 | "-mfpu=fpv5-d16", |
| 162 | ] |
| 163 | asmflags = cflags |
| 164 | defines = [ "PW_ARMV7M_ENABLE_FPU=1" ] |
| 165 | ldflags = cflags |
| 166 | } |
| 167 | |
| 168 | config("fpu_fpv5_sp") { |
| 169 | cflags = [ |
| 170 | "-mfloat-abi=hard", |
| 171 | "-mfpu=fpv5-sp-d16", |
| 172 | ] |
| 173 | asmflags = cflags |
| 174 | defines = [ "PW_ARMV7M_ENABLE_FPU=1" ] |
| 175 | ldflags = cflags |
| 176 | } |
| 177 | |
| 178 | config("wrap_newlib_stdio_functions") { |
| 179 | ldflags = [ |
| 180 | "-Wl,--wrap=__sread", |
| 181 | "-Wl,--wrap=__swrite", |
| 182 | "-Wl,--wrap=__sseek", |
| 183 | "-Wl,--wrap=__sclose", |
| 184 | ] |
| 185 | visibility = [ ":*" ] |
| 186 | } |
| 187 | |
| 188 | pw_source_set("newlib_os_interface_stubs") { |
| 189 | all_dependent_configs = [ ":wrap_newlib_stdio_functions" ] |
| 190 | sources = [ "$dir_pw_toolchain/arm_gcc/newlib_os_interface_stubs.cc" ] |
| 191 | deps = [ dir_pw_assert ] |
| 192 | visibility = [ ":*" ] |
| 193 | } |
| 194 | |
| 195 | # Basic libraries any arm-none-eabi-gcc target should use. This library should |
| 196 | # be included in pw_build_LINK_DEPS. |
| 197 | group("arm_none_eabi_gcc_support") { |
| 198 | deps = [ |
| 199 | ":newlib_os_interface_stubs", |
| 200 | "$dir_pw_toolchain:wrap_abort", |
| 201 | ] |
| 202 | } |