Problem with gcc5 std library when building ports

Dimitry Andric dim at FreeBSD.org
Sun Oct 30 02:31:51 UTC 2016


On 27 Oct 2016, at 01:01, Dewayne Geraghty <dewaynegeraghty at gmail.com> wrote:
> 
> Can anyone help regarding the apparant absence of snprintf from std?  Am I
> missing something, perhaps LDCONFIG or?  I've looked in /usr/ports/Mk/
> bsd.gcc.mk and /usr/ports/Mk/bsd.port.mk but this is an area that I'm
> unfamiliar, so nothing really stood out.
> 
> If I change the compiler from gcc5 to clang everything compiles and runs
> correctly. I have in /etc/make.conf
> USE_GCC=  5
> and to use clang, I just comment out the above. So everything is constant,
> on FreeBSD 10.3Stable (updated and rebuilt overnight)

The difference is that clang by default uses libc++, while gcc uses
libstcd++.  Unfortunately, our gcc ports have a long-standing problem
with recognition of C99 functionality for their copies of libstdc++.

If you look in gcc5's <cstdio> header, usually located in
/usr/local/lib/gcc5/include/c++/cstdio, you will see this:

#if _GLIBCXX_USE_C99

#undef snprintf
[...]

namespace __gnu_cxx
{
#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
  extern "C" int
  (snprintf)(char * __restrict, std::size_t, const char * __restrict, ...)
  throw ();
[...]
#endif

#if !_GLIBCXX_USE_C99_DYNAMIC
  using ::snprintf;
[...]
#endif
} // namespace __gnu_cxx

namespace std
{
  using ::__gnu_cxx::snprintf;
[...]
} // namespace std

#endif // _GLIBCXX_USE_C99

So in a slightly convoluted way, it only defines std::snprintf() when
_GLIBCXX_USE_C99 is defined.

However, during the port build, the gcc configuration mechanism seems to
conclude that C99 support is *not* available, and stores this in
/usr/local/lib/gcc5/include/c++/${ARCH}-portbld-freebsd${VERSION}/bits/c++config.h:

/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
   <stdio.h>, and <stdlib.h> can be used or exposed. */
/* #undef _GLIBCXX_USE_C99 */

This has been the case for ages now, and there must be lots of bug
reports for it, but it has not been fixed.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20161030/601956f3/attachment.sig>


More information about the freebsd-ports mailing list