MSP430: Add -mtiny-printf option
2019-11-04 Jozef Lawrynowicz <jozef.l@mittosystems.com> gcc/ * 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. gcc/testsuite/ * gcc.target/msp430/tiny-printf.c: New test. From-SVN: r277774
This commit is contained in:
parent
e0f8e3da33
commit
02afb6a932
10 changed files with 94 additions and 4 deletions
|
@ -1,3 +1,18 @@
|
|||
2019-11-04 Jozef Lawrynowicz <jozef.l@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.
|
||||
|
||||
2019-11-04 Jozef Lawrynowicz <jozef.l@mittosystems.com>
|
||||
|
||||
* configure: Regenerate.
|
||||
|
|
|
@ -1688,6 +1688,13 @@
|
|||
#endif
|
||||
|
||||
|
||||
/* Define if GCC has been configured with --enable-newlib-nano-formatted-io.
|
||||
*/
|
||||
#ifndef USED_FOR_TARGET
|
||||
#undef HAVE_NEWLIB_NANO_FORMATTED_IO
|
||||
#endif
|
||||
|
||||
|
||||
/* Define to 1 if you have the `nl_langinfo' function. */
|
||||
#ifndef USED_FOR_TARGET
|
||||
#undef HAVE_NL_LANGINFO
|
||||
|
|
|
@ -287,6 +287,12 @@ msp430_option_override (void)
|
|||
possible to build newlib with -Os enabled. Until now... */
|
||||
if (TARGET_OPT_SPACE && optimize < 3)
|
||||
optimize_size = 1;
|
||||
|
||||
#ifndef HAVE_NEWLIB_NANO_FORMATTED_IO
|
||||
if (TARGET_TINY_PRINTF)
|
||||
error ("GCC must be configured with %<--enable-newlib-nano-formatted-io%> "
|
||||
"to use %<-mtiny-printf%>");
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef TARGET_SCALAR_MODE_SUPPORTED_P
|
||||
|
|
|
@ -75,7 +75,8 @@ extern bool msp430x;
|
|||
"msp430_propagate_region_opt(%* %{muse-lower-region-prefix})} " \
|
||||
"%{mdata-region=*:--data-region=%:" \
|
||||
"msp430_propagate_region_opt(%* %{muse-lower-region-prefix})} " \
|
||||
"%:msp430_get_linker_devices_include_path()"
|
||||
"%:msp430_get_linker_devices_include_path() " \
|
||||
"%{mtiny-printf:--wrap puts --wrap printf} "
|
||||
|
||||
#define DRIVER_SELF_SPECS \
|
||||
" %{!mlarge:%{mcode-region=*:%{mdata-region=*:%e-mcode-region and " \
|
||||
|
|
|
@ -2,6 +2,10 @@ msim
|
|||
Target
|
||||
Use simulator runtime.
|
||||
|
||||
mtiny-printf
|
||||
Target Report Mask(TINY_PRINTF)
|
||||
Use a lightweight configuration of printf and puts to reduce code size. For single-threaded applications, not requiring reentrant I/O only. Requires Newlib Nano IO.
|
||||
|
||||
masm-hex
|
||||
Target Mask(ASM_HEX)
|
||||
Force assembly output to always use hex constants.
|
||||
|
|
25
gcc/configure
vendored
25
gcc/configure
vendored
|
@ -990,6 +990,7 @@ with_plugin_ld
|
|||
enable_gnu_indirect_function
|
||||
enable_initfini_array
|
||||
enable_comdat
|
||||
enable_newlib_nano_formatted_io
|
||||
enable_standard_branch_protection
|
||||
enable_fix_cortex_a53_835769
|
||||
enable_fix_cortex_a53_843419
|
||||
|
@ -1718,6 +1719,8 @@ Optional Features:
|
|||
glibc systems
|
||||
--enable-initfini-array use .init_array/.fini_array sections
|
||||
--enable-comdat enable COMDAT group support
|
||||
--enable-newlib-nano-formatted-io
|
||||
Use nano version formatted IO
|
||||
|
||||
--enable-standard-branch-protection
|
||||
enable Branch Target Identification Mechanism and
|
||||
|
@ -18923,7 +18926,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 18926 "configure"
|
||||
#line 18929 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -19029,7 +19032,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 19032 "configure"
|
||||
#line 19035 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -24549,6 +24552,19 @@ $as_echo "#define HAVE_GAS_DISCRIMINATOR 1" >>confdefs.h
|
|||
fi
|
||||
|
||||
|
||||
# Catch the newlib flag of the same name so we can gate GCC features on it.
|
||||
# Check whether --enable-newlib-nano-formatted-io was given.
|
||||
if test "${enable_newlib_nano_formatted_io+set}" = set; then :
|
||||
enableval=$enable_newlib_nano_formatted_io; case "${enableval}" in
|
||||
yes|no)
|
||||
;;
|
||||
*)
|
||||
as_fn_error $? "unknown newlib-nano-formatted-io setting $enableval" "$LINENO" 5
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
# Thread-local storage - the check is heavily parameterized.
|
||||
conftest_s=
|
||||
tls_first_major=
|
||||
|
@ -27939,6 +27955,11 @@ $as_echo "#define HAVE_AS_MSPABI_ATTRIBUTE 1" >>confdefs.h
|
|||
|
||||
fi
|
||||
|
||||
if test x$enable_newlib_nano_formatted_io = xyes; then
|
||||
|
||||
$as_echo "#define HAVE_NEWLIB_NANO_FORMATTED_IO 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
;;
|
||||
riscv*-*-*)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .attribute support" >&5
|
||||
|
|
|
@ -3359,6 +3359,18 @@ gcc_GAS_CHECK_FEATURE([line table discriminator support],
|
|||
[AC_DEFINE(HAVE_GAS_DISCRIMINATOR, 1,
|
||||
[Define if your assembler supports the .loc discriminator sub-directive.])])
|
||||
|
||||
# Catch the newlib flag of the same name so we can gate GCC features on it.
|
||||
AC_ARG_ENABLE(newlib-nano-formatted-io,
|
||||
[AS_HELP_STRING([--enable-newlib-nano-formatted-io], [Use nano version
|
||||
formatted IO])],
|
||||
[case "${enableval}" in
|
||||
yes|no)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([unknown newlib-nano-formatted-io setting $enableval])
|
||||
;;
|
||||
esac], [])
|
||||
|
||||
# Thread-local storage - the check is heavily parameterized.
|
||||
conftest_s=
|
||||
tls_first_major=
|
||||
|
@ -4999,6 +5011,10 @@ pointers into PC-relative form.])
|
|||
[.mspabi_attribute 4,1],,
|
||||
[AC_DEFINE(HAVE_AS_MSPABI_ATTRIBUTE, 1,
|
||||
[Define if your assembler supports .mspabi_attribute.])])
|
||||
if test x$enable_newlib_nano_formatted_io = xyes; then
|
||||
AC_DEFINE(HAVE_NEWLIB_NANO_FORMATTED_IO, 1, [Define if GCC has been
|
||||
configured with --enable-newlib-nano-formatted-io.])
|
||||
fi
|
||||
;;
|
||||
riscv*-*-*)
|
||||
gcc_GAS_CHECK_FEATURE([.attribute support],
|
||||
|
|
|
@ -1010,7 +1010,7 @@ Objective-C and Objective-C++ Dialects}.
|
|||
-mwarn-mcu @gol
|
||||
-mcode-region= -mdata-region= @gol
|
||||
-msilicon-errata= -msilicon-errata-warn= @gol
|
||||
-mhwmult= -minrt}
|
||||
-mhwmult= -minrt -mtiny-printf}
|
||||
|
||||
@emph{NDS32 Options}
|
||||
@gccoptlist{-mbig-endian -mlittle-endian @gol
|
||||
|
@ -23323,6 +23323,19 @@ initializers or constructors. This is intended for memory-constrained
|
|||
devices. The compiler includes special symbols in some objects
|
||||
that tell the linker and runtime which code fragments are required.
|
||||
|
||||
@item -mtiny-printf
|
||||
@opindex mtiny-printf
|
||||
Enable reduced code size @code{printf} and @code{puts} library functions.
|
||||
The @samp{tiny} implementations of these functions are not reentrant, so
|
||||
must be used with caution in multi-threaded applications.
|
||||
|
||||
Support for streams has been removed and the string to be printed will
|
||||
always be sent to stdout via the @code{write} syscall. The string is not
|
||||
buffered before it is sent to write.
|
||||
|
||||
This option requires Newlib Nano IO, so GCC must be configured with
|
||||
@samp{--enable-newlib-nano-formatted-io}.
|
||||
|
||||
@item -mcode-region=
|
||||
@itemx -mdata-region=
|
||||
@opindex mcode-region
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2019-11-04 Jozef Lawrynowicz <jozef.l@mittosystems.com>
|
||||
|
||||
* gcc.target/msp430/tiny-printf.c: New test.
|
||||
|
||||
2019-11-04 Jozef Lawrynowicz <jozef.l@mittosystems.com>
|
||||
|
||||
* gcc.target/msp430/devices/csv-using-env-var.c: New test.
|
||||
|
|
3
gcc/testsuite/gcc.target/msp430/tiny-printf.c
Normal file
3
gcc/testsuite/gcc.target/msp430/tiny-printf.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-mtiny-printf" } */
|
||||
/* { dg-error "GCC must be configured with --enable-newlib-nano-formatted-io to use -mtiny-printf" "" { target { ! newlib_nano_io } } 0 } */
|
Loading…
Add table
Reference in a new issue