[patch, bz #58312] Fix libssp handling of vsnprintf for cross-compilers

Jakub Jelinek jakub@redhat.com
Wed Sep 4 07:01:00 GMT 2013


On Tue, Sep 03, 2013 at 06:59:30PM -0700, Brooks Moses wrote:
> The attached patch fixes bug 58312, by replacing the runtime check of
> vsnprintf with a compile-time check -- which means that it now
> performs the same checks for both native and cross compilers, ensuring
> consistency instead of the previous behavior of just discarding some
> libssp functions when cross-compiling.
> 
> I've tested this by reconfiguring (on an x86-linux cross
> configuration) and confirming that it behaves as expected -- the
> HAVE_USABLE_VSNPRINTF macro is defined in confdefs.h, and the
> config.log has verbosity of output similar to the previous version.
> (The formerly-explicit output is included as part of the AC_CHECK_FUNC
> macro.)
> 
> It is possible that this will enable the macro on some native
> configurations where vsnprintf was present but is broken.  The effect
> is simply that a few additional functions (which rely on vsnprintf)
> are compiled into libssp; this seems relatively innocuous.
> 
> Jakub, I'm cc'ing you in hopes that you're a reasonably appropriate
> person to review this.

That looks wrong, the test was intentionally looking for badly implemented
vsnprintf, see
http://www.gnu.org/software/gnulib/manual/html_node/snprintf.html
"This function does not return a byte count as specified in C99 on some
platforms: HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw."

The implementation relies on the returned byte count to be exactly correct,
so it can't be implemented on platforms where that is not the case.

Not sure which of the targets from the above list we still support,
certainly at least mingw, though in that case I don't know if it hasn't been
fixed there.  So, as Joseph said, you probably should keep the runtime test
as is, and just for cross compiling replace the unconditional =undef with
an optimistic assumption followed by a blacklist of platforms where it is
known not to work.

> 2013-09-03  Brooks Moses  <bmoses@google.com>
> 
>         * configure.ac: Replace runtime vsnprintf check with
>           compile-time check.
>         * configure: Regenerate.



	Jakub



More information about the Gcc-patches mailing list