| # Copyright 2020 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| import("//build_overrides/pigweed.gni") |
| import("//build_overrides/pigweed_environment.gni") |
| |
| import("$dir_pw_build/target_types.gni") |
| import("$dir_pw_toolchain/generate_toolchain.gni") |
| |
| # Disable obnoxious ABI warning. |
| # |
| # GCC 7.1 adds an over-zealous ABI warning with little useful information |
| # on how to resolve the issue. The warning you get is: |
| # |
| # note: parameter passing for argument of type '...' changed in GCC 7.1 |
| # |
| # There is no other information, and searching for the error is needed to |
| # understand what is happening. For upstream Pigweed, we compile from |
| # source so this is irrelevant; so disable it. |
| # |
| # See: https://gcc.gnu.org/gcc-7/changes.html (search for "psabi"). |
| # https://gcc.gnu.org/ml/gcc/2017-05/msg00073.html |
| config("disable_psabi_warning") { |
| cflags = [ "-Wno-psabi" ] |
| } |
| |
| # binutils 2.39 introduced new warnings that trigger on embedded ARM GCC builds: |
| # |
| # warning: *.elf has a LOAD segment with RWX permissions |
| # |
| # Disable these warnings --no-warn-rwx-segment. For details see: |
| # https://www.redhat.com/en/blog/linkers-warnings-about-executable-stacks-and-segments |
| config("disable_rwx_segment_warning") { |
| ldflags = [ "-Wl,--no-warn-rwx-segment" ] |
| } |
| |
| config("cortex_common") { |
| asmflags = [ |
| "-mabi=aapcs", |
| "-mthumb", |
| ] |
| cflags = asmflags + [ |
| "--sysroot=" + rebase_path(pw_env_setup_CIPD_ARM, root_build_dir), |
| "-specs=nano.specs", |
| "-specs=nosys.specs", |
| ] |
| ldflags = cflags + [ |
| "-lnosys", |
| "-lc", |
| ] |
| } |
| |
| config("enable_float_printf") { |
| cflags = [ "-u_printf_float" ] |
| ldflags = cflags |
| } |
| |
| config("cortex_m0plus") { |
| cflags = [ "-mcpu=cortex-m0plus" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_m3") { |
| cflags = [ "-mcpu=cortex-m3" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_m4") { |
| cflags = [ "-mcpu=cortex-m4" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_m7") { |
| cflags = [ "-mcpu=cortex-m7" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_m33") { |
| cflags = [ "-mcpu=cortex-m33" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_a32") { |
| cflags = [ "-mcpu=cortex-a32" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_software_fpu") { |
| cflags = [ "-mfloat-abi=soft" ] |
| asmflags = cflags |
| ldflags = cflags |
| } |
| |
| config("cortex_hardware_fpu") { |
| cflags = [ |
| "-mfloat-abi=hard", |
| "-mfpu=fpv4-sp-d16", |
| ] |
| asmflags = cflags |
| defines = [ "PW_ARMV7M_ENABLE_FPU=1" ] |
| ldflags = cflags |
| } |
| |
| config("cortex_hardware_fpu_v5") { |
| cflags = [ |
| "-mfloat-abi=hard", |
| "-mfpu=fpv5-d16", |
| ] |
| asmflags = cflags |
| defines = [ "PW_ARMV7M_ENABLE_FPU=1" ] |
| ldflags = cflags |
| } |
| |
| config("cortex_hardware_fpu_v5_sp") { |
| cflags = [ |
| "-mfloat-abi=hard", |
| "-mfpu=fpv5-sp-d16", |
| ] |
| asmflags = cflags |
| defines = [ "PW_ARMV7M_ENABLE_FPU=1" ] |
| ldflags = cflags |
| } |
| |
| config("wrap_newlib_stdio_functions") { |
| ldflags = [ |
| "-Wl,--wrap=__sread", |
| "-Wl,--wrap=__swrite", |
| "-Wl,--wrap=__sseek", |
| "-Wl,--wrap=__sclose", |
| ] |
| visibility = [ ":*" ] |
| } |
| |
| pw_source_set("newlib_os_interface_stubs") { |
| all_dependent_configs = [ ":wrap_newlib_stdio_functions" ] |
| sources = [ "newlib_os_interface_stubs.cc" ] |
| deps = [ dir_pw_assert ] |
| } |
| |
| # Basic libraries any arm-none-eabi-gcc target should use. This library should |
| # be included in pw_build_LINK_DEPS. |
| group("arm_none_eabi_gcc_support") { |
| deps = [ "$dir_pw_toolchain:wrap_abort" ] |
| |
| # TODO: b/301079199 - Stubs are not yet usable on clang. |
| # AttempedToInvokeUnsupportedNewlibOsInterfaceFunction (write_) is triggering, |
| # but not sure why yet. |
| # TODO: b/301262374 - Provide a better way to detect the compiler type. |
| if (get_path_info(pw_toolchain_SCOPE.cc, "file") != "clang") { |
| deps += [ ":newlib_os_interface_stubs" ] |
| } |
| } |