+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.
#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
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
"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 " \
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.
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
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
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
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
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=
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
[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=
[.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],
-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
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
+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.
--- /dev/null
+/* { 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 } */