pw_toolchain: arm_none_eabi_gcc_support library
The arm_none_eabi_gcc_support group collects libraries that should be
used when building with arm-none-eabi-gcc. Targets using that compiler
should add this target to pw_build_LINK_DEPS.
Change-Id: I73c450038cf55d7a53c480489d7cc82cbd25ff04
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112268
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
diff --git a/pw_toolchain/arm_gcc/BUILD.bazel b/pw_toolchain/arm_gcc/BUILD.bazel
index 79cfb7f..5e34751 100644
--- a/pw_toolchain/arm_gcc/BUILD.bazel
+++ b/pw_toolchain/arm_gcc/BUILD.bazel
@@ -17,8 +17,6 @@
"pw_cc_library",
)
-package(default_visibility = ["//visibility:public"])
-
licenses(["notice"])
pw_cc_library(
@@ -30,5 +28,15 @@
"-Wl,--wrap=__sseek",
"-Wl,--wrap=__sclose",
],
+ visibility = ["//visibility:private"],
deps = ["//pw_assert"],
)
+
+pw_cc_library(
+ name = "arm_none_eabi_gcc_support",
+ visibility = ["//visibility:public"],
+ deps = [
+ ":newlib_os_interface_stubs",
+ "//pw_toolchain:wrap_abort",
+ ],
+)
diff --git a/pw_toolchain/arm_gcc/BUILD.gn b/pw_toolchain/arm_gcc/BUILD.gn
index fad0fcc..436c4de 100644
--- a/pw_toolchain/arm_gcc/BUILD.gn
+++ b/pw_toolchain/arm_gcc/BUILD.gn
@@ -134,8 +134,15 @@
pw_source_set("newlib_os_interface_stubs") {
all_dependent_configs = [ ":wrap_newlib_stdio_functions" ]
sources = [ "newlib_os_interface_stubs.cc" ]
+ deps = [ dir_pw_assert ]
+ visibility = [ ":*" ]
+}
+
+# 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 = [
+ ":newlib_os_interface_stubs",
"$dir_pw_toolchain:wrap_abort",
- dir_pw_assert,
]
}
diff --git a/pw_toolchain/arm_gcc/CMakeLists.txt b/pw_toolchain/arm_gcc/CMakeLists.txt
index c353a70..425831a 100644
--- a/pw_toolchain/arm_gcc/CMakeLists.txt
+++ b/pw_toolchain/arm_gcc/CMakeLists.txt
@@ -25,3 +25,9 @@
"-Wl,--wrap=__sseek"
"-Wl,--wrap=__sclose"
)
+
+pw_add_library(pw_toolchain.arm_gcc.arm_none_eabi_gcc_support INTERFACE
+ PUBLIC_DEPS
+ pw_toolchain.arm_gcc.newlib_os_interface_stubs
+ pw_toolchain.wrap_abort
+)
diff --git a/pw_toolchain/docs.rst b/pw_toolchain/docs.rst
index 77fd6c4..bb36b7e 100644
--- a/pw_toolchain/docs.rst
+++ b/pw_toolchain/docs.rst
@@ -156,8 +156,15 @@
``-Wl,--wrap=abort`` linker option to redirect to ``abort`` calls to
``PW_CRASH`` instead.
+arm-none-eabi-gcc support
+=========================
+Targets building with the GNU Arm Embedded Toolchain (``arm-none-eabi-gcc``)
+should depend on the ``pw_toolchain/arm_gcc:arm_none_eabi_gcc_support`` library
+into their builds. In GN, that target should be included in
+``pw_build_LINK_DEPS``.
+
Newlib OS interface
-===================
+-------------------
`Newlib <https://sourceware.org/newlib/>`_, the C Standard Library
implementation provided with ``arm-none-eabi-gcc``, defines a set of `OS
interface functions <https://sourceware.org/newlib/libc.html#Stubs>`_ that
@@ -165,7 +172,8 @@
implemented, but using the default results in a compiler warning.
Most of the OS interface functions should never be called in embedded builds.
-The ``pw_toolchain/arg_gcc:newlib_os_interface_stubs`` library implements these
-functions and forces a linker error if they are used. It also wraps some
+The ``pw_toolchain/arg_gcc:newlib_os_interface_stubs`` library, which is
+provided through ``pw_toolchain/arm_gcc:arm_none_eabi_gcc_support``, implements
+these functions and forces a linker error if they are used. It also wraps some
functions related to use of ``stdout`` and ``stderr`` that abort if they are
called.
diff --git a/targets/stm32f429i_disc1/target_toolchains.gni b/targets/stm32f429i_disc1/target_toolchains.gni
index 5022588..dcce335 100644
--- a/targets/stm32f429i_disc1/target_toolchains.gni
+++ b/targets/stm32f429i_disc1/target_toolchains.gni
@@ -86,8 +86,7 @@
"$dir_pw_assert:impl",
"$dir_pw_cpu_exception:entry_impl",
"$dir_pw_log:impl",
- "$dir_pw_toolchain:wrap_abort",
- "$dir_pw_toolchain/arm_gcc:newlib_os_interface_stubs",
+ "$dir_pw_toolchain/arm_gcc:arm_none_eabi_gcc_support",
]
current_cpu = "arm"