In the Specs Language documentation in gcc.c it says:
%* substitute the variable part of a matched option. (See below.)
Note that each comma in the substituted string is replaced by
a single space.
However that is not quite what it does. It actually appends a space
at the end.
For a port that we hope to contribute in the future, besides a Linux version,
we need to support multiple target board variants (a set that is still
growing)
for a bare-metal newlib-based toolchain. We want to do this by linking in
an extra board-specific file in STARTFILE_SPECS.
The board is specified as part of an -m option that also triggers common SPEC
adaptations for the newlib-based toolchain.
According to the documentation, we should be able to specify the file with
name-prefix%*.o . However, because of the undocumented insertion of ' ',
this goes badly awry.
The emission of the extra ' ' goes back all the way to the dawn of RCS control
of GCC sources, so getting rid of it altogether is not likely to be easy.
However, most uses either have a whitespace character next - so the extra ' '
is redundant - or they have a '}' character next - in which case it seems
sensible to keep the ' ' for now.
There are two other cases in config/{,*/}*:
- LINK_SYSROOT_SPEC in config/darwin.h . At the only place where
LINK_SYSROOT_SPEC is used, a space follows.
- LINK_SPEC in config/m68k/uclinux.h . The use is at one of the two
alternative ends of LINK_SPEC; besides, the other end doesnt' have a
trailing space, either.
Thus, it seems safe to stop the emitting of the extra space if the next
character is not '}' .
Would a patch like the one below be considered when 4.7 phase 1 opens?
2011-02-16 Joern Rennecke <joern.renne...@embecosm.com>
* gcc.c (do_spec_1) <%*>: Don't append a space unless the next
character is '}'.
Index: gcc.c
===================================================================
--- gcc.c (revision 1452)
+++ gcc.c (working copy)
@@ -5868,7 +5868,12 @@ do_spec_1 (const char *spec, int inswitc
if (soft_matched_part)
{
do_spec_1 (soft_matched_part, 1, NULL);
- do_spec_1 (" ", 0, NULL);
+ /* ??? Emitting a space after soft_matched_part gets in
+ is undocumented and gets in the way of doing useful
+ file name pasting; but for backward compatibility, we
+ keep this behaviour when the next character is '}'. */
+ if (p[1] == '}')
+ do_spec_1 (" ", 0, NULL);
}
else
/* Catch the case where a spec string contains something like