On Tue, Nov 20, 2018 at 08:47:14AM +0100, Landry Breuil wrote: > On Mon, Nov 19, 2018 at 11:44:28PM -0500, George Koehler wrote: > > On Mon, 19 Nov 2018 13:31:25 -0500 > > George Koehler <kern...@gmail.com> wrote: > > > > > My powerpc machine is using the gcc 6 diff from > > > https://marc.info/?l=openbsd-ports&m=154165621429861&w=2 > > > > > > This is using gcc-6.4.0p2 as ports-gcc, and has now failed to build > > > devel/cmake.... (It fails) because gcc 6 warns when linking any > > > C++ program: > > > > > > $ eg++ -o simple simple.cc > > > /usr/local/lib/gcc/powerpc-unknown-openbsd6.4/6.4.0/../../../libestdc++.so.18.0: > > > warning: sprintf() is often misused, please use snprintf() > > > > I now propose a patch for lang/gcc/6 that silences the above warning. > > With this patch, lang/gcc/6 builds devel/cmake successfully. The > > patch removes sprintf() from libestdc++.so but doesn't touch other > > sprintf() calls in /usr/local/include/c++/6.4.0/ext/throw_allocator.h; > > I did use base-gcc's /usr/include/g++/ext/throw_allocator.h as an > > example of snprintf(). > > Sadly, even if i personally would like those warning messages to go away > as they never served any purpose in the ports land (and caused griefs > from upstream in the past, and issues like this one..) i dont think this > diff can be accepted. Iirc __builtin_xxx might do more things, and some > developers have a strong opinion about keeping the warnings; so cmake > might have to be adapted to ignore them ?
So, the warning comes from libestdc++, and we dont see it on amd64 because it uses lld (which doesnt trigger the warning), and not on i386 because it uses clang so libc++. After discussing it with espie it might be better to use __builtin_snprintf instead of just snprintf - with that the warning msg should go away. That's what i'm testing in the current macppc bulk. In the end i was wrong, and your analysis was right :) Landry
$OpenBSD$ Silence this linker warning: /usr/local/lib/gcc/powerpc-unknown-openbsd6.4/6.4.0/../../../libestdc++.so.18.0: warning: sprintf() is often misused, please use snprintf() Index: libstdc++-v3/src/c++11/debug.cc --- libstdc++-v3/src/c++11/debug.cc.orig +++ libstdc++-v3/src/c++11/debug.cc @@ -660,7 +660,7 @@ namespace else if (__builtin_strcmp(name, "address") == 0) { char buf[64]; - int ret = __builtin_sprintf(buf, "%p", inst._M_address); + int ret = __builtin_snprintf(buf, sizeof buf, "%p", inst._M_address); print_word(ctx, buf, ret); } else @@ -712,7 +712,7 @@ namespace else if (__builtin_strcmp(name, "sequence") == 0) { assert(iterator._M_sequence); - int written = __builtin_sprintf(buf, "%p", iterator._M_sequence); + int written = __builtin_snprintf(buf, sizeof buf, "%p", iterator._M_sequence); print_word(ctx, buf, written); } else if (__builtin_strcmp(name, "seq_type") == 0) @@ -797,7 +797,7 @@ namespace } int written - = __builtin_sprintf(buf, "@ 0x%p {\n", inst._M_address); + = __builtin_snprintf(buf, sizeof buf, "@ 0x%p {\n", inst._M_address); print_word(ctx, buf, written); if (inst._M_type) @@ -853,7 +853,7 @@ namespace } int written - = __builtin_sprintf(buf, "@ 0x%p\n", ite._M_sequence); + = __builtin_snprintf(buf, sizeof buf, "@ 0x%p\n", ite._M_sequence); print_word(ctx, buf, written); } @@ -951,8 +951,8 @@ namespace if (param._M_kind == _Parameter::__integer) { int written - = __builtin_sprintf(buf, "%ld", - param._M_variant._M_integer._M_value); + = __builtin_snprintf(buf, sizeof buf, "%ld", + param._M_variant._M_integer._M_value); print_word(ctx, buf, written); } else if (param._M_kind == _Parameter::__string) @@ -1012,7 +1012,7 @@ namespace __gnu_debug if (_M_line > 0) { char buf[64]; - int written = __builtin_sprintf(buf, "%u:", _M_line); + int written = __builtin_snprintf(buf, sizeof buf, "%u:", _M_line); print_word(ctx, buf, written); go_to_next_line = true; }