• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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")
16import("//build_overrides/pigweed_environment.gni")
17
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_toolchain/generate_toolchain.gni")
20
21# Disable obnoxious ABI warning.
22#
23# GCC 7.1 adds an over-zealous ABI warning with little useful information
24# on how to resolve the issue. The warning you get is:
25#
26#   note: parameter passing for argument of type '...' changed in GCC 7.1
27#
28# There is no other information, and searching for the error is needed to
29# understand what is happening. For upstream Pigweed, we compile from
30# source so this is irrelevant; so disable it.
31#
32# See: https://gcc.gnu.org/gcc-7/changes.html (search for "psabi").
33#      https://gcc.gnu.org/ml/gcc/2017-05/msg00073.html
34config("disable_psabi_warning") {
35  cflags = [ "-Wno-psabi" ]
36}
37
38# binutils 2.39 introduced new warnings that trigger on embedded ARM GCC builds:
39#
40#   warning: *.elf has a LOAD segment with RWX permissions
41#
42# Disable these warnings --no-warn-rwx-segment. For details see:
43# https://www.redhat.com/en/blog/linkers-warnings-about-executable-stacks-and-segments
44config("disable_rwx_segment_warning") {
45  ldflags = [ "-Wl,--no-warn-rwx-segment" ]
46}
47
48config("cortex_common") {
49  asmflags = [
50    "-mabi=aapcs",
51    "-mthumb",
52  ]
53  cflags = asmflags + [
54             "--sysroot=" + rebase_path(pw_env_setup_CIPD_ARM, root_build_dir),
55             "-specs=nano.specs",
56             "-specs=nosys.specs",
57           ]
58  ldflags = cflags + [
59              "-lnosys",
60              "-lc",
61            ]
62}
63
64config("enable_float_printf") {
65  cflags = [ "-u_printf_float" ]
66  ldflags = cflags
67}
68
69config("cortex_m0plus") {
70  cflags = [ "-mcpu=cortex-m0plus" ]
71  asmflags = cflags
72  ldflags = cflags
73}
74
75config("cortex_m3") {
76  cflags = [ "-mcpu=cortex-m3" ]
77  asmflags = cflags
78  ldflags = cflags
79}
80
81config("cortex_m4") {
82  cflags = [ "-mcpu=cortex-m4" ]
83  asmflags = cflags
84  ldflags = cflags
85}
86
87config("cortex_m7") {
88  cflags = [ "-mcpu=cortex-m7" ]
89  asmflags = cflags
90  ldflags = cflags
91}
92
93config("cortex_m33") {
94  cflags = [ "-mcpu=cortex-m33" ]
95  asmflags = cflags
96  ldflags = cflags
97}
98
99config("cortex_a32") {
100  cflags = [ "-mcpu=cortex-a32" ]
101  asmflags = cflags
102  ldflags = cflags
103}
104
105config("cortex_software_fpu") {
106  cflags = [ "-mfloat-abi=soft" ]
107  asmflags = cflags
108  ldflags = cflags
109}
110
111config("cortex_hardware_fpu") {
112  cflags = [
113    "-mfloat-abi=hard",
114    "-mfpu=fpv4-sp-d16",
115  ]
116  asmflags = cflags
117  defines = [ "PW_ARMV7M_ENABLE_FPU=1" ]
118  ldflags = cflags
119}
120
121config("cortex_hardware_fpu_v5") {
122  cflags = [
123    "-mfloat-abi=hard",
124    "-mfpu=fpv5-d16",
125  ]
126  asmflags = cflags
127  defines = [ "PW_ARMV7M_ENABLE_FPU=1" ]
128  ldflags = cflags
129}
130
131config("cortex_hardware_fpu_v5_sp") {
132  cflags = [
133    "-mfloat-abi=hard",
134    "-mfpu=fpv5-sp-d16",
135  ]
136  asmflags = cflags
137  defines = [ "PW_ARMV7M_ENABLE_FPU=1" ]
138  ldflags = cflags
139}
140
141config("wrap_newlib_stdio_functions") {
142  ldflags = [
143    "-Wl,--wrap=__sread",
144    "-Wl,--wrap=__swrite",
145    "-Wl,--wrap=__sseek",
146    "-Wl,--wrap=__sclose",
147  ]
148  visibility = [ ":*" ]
149}
150
151pw_source_set("newlib_os_interface_stubs") {
152  all_dependent_configs = [ ":wrap_newlib_stdio_functions" ]
153  sources = [ "newlib_os_interface_stubs.cc" ]
154  deps = [ dir_pw_assert ]
155}
156
157# Basic libraries any arm-none-eabi-gcc target should use. This library should
158# be included in pw_build_LINK_DEPS.
159group("arm_none_eabi_gcc_support") {
160  deps = [ "$dir_pw_toolchain:wrap_abort" ]
161
162  # TODO: b/301079199 - Stubs are not yet usable on clang.
163  # AttempedToInvokeUnsupportedNewlibOsInterfaceFunction (write_) is triggering,
164  # but not sure why yet.
165  # TODO: b/301262374 - Provide a better way to detect the compiler type.
166  if (get_path_info(pw_toolchain_SCOPE.cc, "file") != "clang") {
167    deps += [ ":newlib_os_interface_stubs" ]
168  }
169}
170