On 10/24/19 2:56 PM, Jozef Lawrynowicz wrote:
> I added support for reduced code size printf and puts functions to Newlib for
> MSP430 a while ago [1]. By removing support for reentrancy, streams and
> buffering we can greatly reduce code size, which is always often a limitation
> when using printf on microcontrollers.
> 
> This patch adds an interface to enable these reduced code size implementations
> from GCC by using the -mtiny-printf option. The tiny printf and puts
> implementations require GCC to be configured with
> --enable-newlib-nano-formatted-io, so there are some modifications to 
> configure
> scripts to support the checking of that.
> 
> -mtiny-printf is merely an alias for passing "--wrap printf --wrap puts" to 
> the
> linker.
> This will replace references to "printf" and "puts" in user
> code with "__wrap_printf" and "__wrap_puts" respectively.
> If there is no implementation of these __wrap* functions in user code,
> these "tiny" printf and puts implementations will be linked into the
> final executable.
> 
> The wrapping mechanism is supposed to be invisible to the user since even if
> they are unaware of the "tiny" implementation, and implement their own 
> __wrap_printf and __wrap_puts, their own implementation will be automatically
> chosen over the "tiny" printf and puts from the library.
> 
> Successfully regtested on trunk by comparing results with -mtiny-printf with a
> set of testresults without the option.
> The new test "gcc.target/msp430/tiny-printf.c" verifies the option behaves as
> expected when GCC is configured with and without
> --enable-newlib-nano-formatted-io.
> 
> Ok to apply?
> 
> [1]
> https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=1e6c561d48f
> 
> 
> 0001-MSP430-Add-mtiny-printf-option.patch
> 
> From 4d4e2b6bb92317b2b4db1d99c3f43a167a1e3288 Mon Sep 17 00:00:00 2001
> From: Jozef Lawrynowicz <joze...@mittosystems.com>
> Date: Thu, 24 Oct 2019 13:30:21 +0100
> Subject: [PATCH] MSP430: Add -mtiny-printf option
> 
> gcc/ChangeLog:
> 
> 2019-10-24  Jozef Lawrynowicz  <joze...@mittosystems.com>
> 
>       * config.in: Regenerate.
>       * config/msp430/msp430.c (msp430_option_override): Emit an error if
>       -mtiny-printf is used without GCC being configured with
>       --enable-newlib-nano-formatted-io.
>       * config/msp430/msp430.h (LINK_SPEC): Pass 
>       "--wrap puts --wrap printf" when -mtiny-printf is used.
>       * config/msp430/msp430.opt: Document -mtiny-printf.
>       * configure: Regenerate.
>       * configure.ac: Enable --enable-newlib-nano-formatted-io flag.
>       Define HAVE_NEWLIB_NANO_FORMATTED_IO if
>       --enable-newlib-nano-formatted-io is passed.
>       * doc/invoke.texi: Document -mtiny-printf.
OK
jeff

Reply via email to