This is the mail archive of the
mailing list for the GCC project.
RE: selective linking of floating point support for *printf / *scanf
- From: "Thomas Preud'homme" <thomas dot preudhomme at arm dot com>
- To: "'Joern Rennecke'" <joern dot rennecke at embecosm dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, "GCC" <gcc at gcc dot gnu dot org>, "Joerg Wunsch" <joerg_wunsch at uriah dot heep dot sax dot de>, <avr-libc-dev at nongnu dot org>, "Andrew Burgess" <andrew dot burgess at embecosm dot com>, <newlib at sourceware dot org>
- Date: Wed, 12 Nov 2014 18:08:25 -0000
- Subject: RE: selective linking of floating point support for *printf / *scanf
- Authentication-results: sourceware.org; auth=none
- References: <CAMqJFCpWKXVmmc-YLKf9XO6H8C_YnTEcgzkJAidE21MirJbi-w at mail dot gmail dot com> <001401cfc0f9$bdc5cbc0$39516340$ at arm dot com> <CAMqJFCrEOgavwvW25vO=S-+0TZ_xOnDa0Ex-Ff4XG329K5WE9g at mail dot gmail dot com> <001901cfc1c4$d0678630$71369290$ at arm dot com> <CAMqJFCoFC8sVRQB3+v4dzSVc5LLs9cycjm621FmM34gGHRWFng at mail dot gmail dot com> <000001cfc1e3$7f1a22f0$7d4e68d0$ at arm dot com> <CAMqJFCo1EA8TLVsv=r7gW-udiH6pqBKVuQUvHeGcFDqrnMo_EQ at mail dot gmail dot com> <000101cfc281$3a3008f0$ae901ad0$ at arm dot com> <CAMqJFCrrj1_VHmz7G-VgDpLNGjsTtdjPLqbCRY1oVxeO-BESHw at mail dot gmail dot com> <000201cfc34f$1ceadb20$56c09160$ at arm dot com> <000801cfee9e$47919380$d6b4ba80$ at arm dot com> <Pine dot LNX dot 4 dot 64 dot 1410231519170 dot 23533 at digraph dot polyomino dot org dot uk> <000c01cfef61$6316d2a0$294477e0$ at arm dot com> <CAMqJFCq=2TqLF0F25oJk2v6rTgpFpRNfoJe3nMbjpm2XP50e-A at mail dot gmail dot com>
> From: Joern Rennecke [mailto:firstname.lastname@example.org]
> Sent: Sunday, November 02, 2014 4:34 PM
> Sorry for the late reply, I was on vacation, and then I meant to flesh
> out a suitable
> solution for the macro/hook problem to test it, but the more I think
> about it, the more
> questions arise how this is best structured...
No problem, I'm pretty busy myself with other stuff as well.
> First, the interface of your hook: you say it returns a bool, but that
> bool is not used.
Indeed. I just though it could be used later but since it's an internal
interface it could be removed for now and added later.
> You leave the case to fall through to the default case, thus emitting
> the expression unchanged.
> For my purposes, I have to change the expression.
Oh yes my apologize. The hook should return the next expression.
> Note how my original patch had:
> + exp = copy_node (exp);
> + CALL_EXPR_FN (exp) = build_addr (decl, current_function_decl);
> I don't think changing the existing expression
> destructively is safe, so the return value should be the - possibly
> changed - expression.
> You can just explain in the hook description that this return value
> may be changed and/or
> additional target-specific output may be emitted.
> The auto-float-io option description dos not match what I intended the
> hook to do on the
> avr. The idea was to have standard behaviour as default, i.e. printf
> knows about float, and
> have the hook change the function name to the integer-specific
> function if the arguments
> don't mention float and the function is not a v* function.
Changing the default to auto-float-io should be ok. All we need is a way to
build newlib without this option since newlib contains some call to vprintf
and this would define the _printf_float symbol (and thus pulling code to
printf float) in any program using newlib.
Having the default to be off would ease the transition. It would be possible
to add the -fno-auto-float-io switch automatically in newlib when gcc is
detected to be recent enough but then compiling old newlib with a recent
gcc would always pull support for printing float values.
> So, if we want to have a versatile hook and describe the option
> specifically, it should be
> a target option. OTOH, that complicate the implementation of a
> generic hook even more...
Well the hook doesn't have to be different, just the default (auto Vs no auto).
Isn't it possible to define different default value for different backend?
> targhooks.c is not entirely target-independent code, so on one level
> we could say it's
> OK to customize it with macros, and we don't want to stuff the target
> vector with a gazillion
> settings that only very few targets use, but OTOH, if one target has
> multiple libraries,
> it might want multile variants of this hook. In fact, having
> sub-hooks for that hook wouldn't
> work if they were POD-kind hooks, and way overcomplicate the target if
> they weren't...
[SNIP explanation of how to do it with hook with template]
This all look complicated when in fact what we want is C target hook that can
be invoked from the middle end. Couldn't we use some kind of weak symbol
so that when no C library is linked in it compiles but nothing happens?
Thanks for all your comments Joern. Much appreciated.