Skip to content

Commit

Permalink
pw_toolchain: Add libc stub for gettimeofday, update visibility rules
Browse files Browse the repository at this point in the history
* Add `gettimeofday` to the disabled libc functions.
* Change `newlib_os_interface_stubs` to have public visibility, so it is
  not automatically bundled with `wrap_abort` through the
  `arm_none_eabi_gcc_support` rule.

Change-Id: I493b515f73e3a886e45ff48cc78e689160b9c924
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/173850
Presubmit-Verified: CQ Bot Account <[email protected]>
Commit-Queue: Shiva Rajagopal <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
  • Loading branch information
shivarajagopalgoogle authored and CQ Bot Account committed Oct 2, 2023
1 parent 36cb582 commit 107b4ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pw_toolchain/arm_gcc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pw_cc_library(
"-Wl,--wrap=__sseek",
"-Wl,--wrap=__sclose",
],
visibility = ["//visibility:private"],
visibility = ["//visibility:public"],
deps = ["//pw_assert"],
)

Expand Down
1 change: 0 additions & 1 deletion pw_toolchain/arm_gcc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ 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
Expand Down
1 change: 1 addition & 0 deletions pw_toolchain/arm_gcc/newlib_os_interface_stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ PW_DISABLE_NEWLIB_FUNCTION(getpid, void)
// documentation since isatty is called indirectly by snprintf.
extern "C" int _isatty(int) { return 1; }

PW_DISABLE_NEWLIB_FUNCTION(gettimeofday, struct timeval*, struct timezone*)
PW_DISABLE_NEWLIB_FUNCTION(kill, int, int)
PW_DISABLE_NEWLIB_FUNCTION(link, char*, char*)
PW_DISABLE_NEWLIB_FUNCTION(lseek, int, int, int)
Expand Down
9 changes: 6 additions & 3 deletions pw_toolchain/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@ results in linker warnings like the following:
Most of the OS interface functions should never be called in embedded builds.
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.
these functions and forces a linker error if they are used. It also
automatically includes a wrapper for ``abort`` for use of ``stdout`` and
``stderr`` which abort if they are called.

If you need to use your own wrapper for ``abort``, include the library directly
using ``pw_toolchain/arm_gcc:newlib_os_interface_stubs``.

pw_toolchain/no_destructor.h
============================
Expand Down

0 comments on commit 107b4ff

Please sign in to comment.