Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Oct 2016 03:31:36 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Dewayne Geraghty <dewaynegeraghty@gmail.com>
Cc:        ports-list freebsd <freebsd-ports@freebsd.org>
Subject:   Re: Problem with gcc5 std library when building ports
Message-ID:  <D3A95230-783D-4C31-8711-B3BF3D9A0A95@FreeBSD.org>
In-Reply-To: <CAGnMC6pcVCgv4_g-3At5drkTAaVicCS1U4yXXdV2-QOF92=fYg@mail.gmail.com>
References:  <CAGnMC6pcVCgv4_g-3At5drkTAaVicCS1U4yXXdV2-QOF92=fYg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_974229DC-1DCE-4529-8910-13BC82B8FD71
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 27 Oct 2016, at 01:01, Dewayne Geraghty <dewaynegeraghty@gmail.com> =
wrote:
>=20
> 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.
>=20
> If I change the compiler from gcc5 to clang everything compiles and =
runs
> correctly. I have in /etc/make.conf
> USE_GCC=3D  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


--Apple-Mail=_974229DC-1DCE-4529-8910-13BC82B8FD71
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.30

iEYEARECAAYFAlgVW5IACgkQsF6jCi4glqNKtgCgvRoQFssLunGb7u3ExE5zeHli
0FkAoNn1jrw5fXsqaLZOzIlLt0NA+mWk
=Bv4n
-----END PGP SIGNATURE-----

--Apple-Mail=_974229DC-1DCE-4529-8910-13BC82B8FD71--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D3A95230-783D-4C31-8711-B3BF3D9A0A95>