Closed Bug 1347672 Opened 8 years ago Closed 5 years ago

GCC 6: gfx/harfbuzz fails to build: memory/mozalloc/throw_gcc.h:137:74: error: 'snprintf' was not declared in this scope

Categories

(Core :: Memory Allocator, defect, P5)

Unspecified
FreeBSD
defect

Tracking

()

RESOLVED DUPLICATE of bug 1434447
Tracking Status
firefox55 --- affected

People

(Reporter: jbeich, Unassigned)

References

Details

Attachments

(1 file)

harfbuzz has "#define _POSIX_C_SOURCE 199309L" which hides snprintf() declaration resulting in an error on POSIXly correct systems. libc++ manages to avoid it by not bootlegging <cstdlib> (thus "mozilla/throw_gcc.h") via <stdlib.h> in "hb-private.hh". /usr/local/bin/g++6 -std=gnu++11 -o hb-blob.o -c -Iobjdir/dist/stl_wrappers -Iobjdir/dist/system_wrappers-include config/gcc_hidden.h -DNDEBUG=1 -DTRIMMED=1 '-DPACKAGE_VERSION="moz"' '-DPACKAGE_BUGREPORT="http://bugzilla.mozilla.org/"' -DHAVE_OT=1 -DHB_NO_MT -DHB_NO_UNICODE_FUNCS -UDEBUG -DSTATIC_EXPORTABLE_JS_API -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -Igfx/harfbuzz/src -Iobjdir/gfx/harfbuzz/src -Iobjdir/dist/include -Iobjdir/dist/include/nspr -Iobjdir/dist/include/nss -fPIC -DMOZILLA_CLIENT -include objdir/mozilla-config.h -MD -MP -MF .deps/hb-blob.o.pp -Wall -Wc++11-compat -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wc++14-compat -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wformat -fno-exceptions -fno-strict-aliasing -fno-rtti -fno-exceptions -fno-math-errno -pipe -O -fno-omit-frame-pointer -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include gfx/harfbuzz/src/hb-blob.cc In file included from objdir/dist/stl_wrappers/cstdlib:66:0, from /usr/local/lib/gcc6/include/c++/stdlib.h:36, from objdir/dist/system_wrappers/stdlib.h:3, from gfx/harfbuzz/src/hb-private.hh:43, from gfx/harfbuzz/src/hb-blob.cc:32: objdir/dist/include/mozilla/throw_gcc.h: In function 'void std::__throw_system_error(int)': objdir/dist/include/mozilla/throw_gcc.h:137:74: error: 'snprintf' was not declared in this scope "fatal: STL threw system_error: %s (%d)", strerror(err), err); ^
Also affects GCC 7.0.1 but not 5.4.0, 4.9.4, 4.8.5, 4.7.4, 4.6.4.
Blocks: 1316555
Summary: gfx/harfbuzz fails to build: memory/mozalloc/throw_gcc.h:137:74: error: 'snprintf' was not declared in this scope → GCC 6: gfx/harfbuzz fails to build: memory/mozalloc/throw_gcc.h:137:74: error: 'snprintf' was not declared in this scope
Oops, bug 1316555 is tracking runtime.
No longer blocks: 1316555
Comment on attachment 8847773 [details] Bug 1347672 - Unbreak build on FreeBSD with GCC 6 or later. https://reviewboard.mozilla.org/r/120692/#review127076 I'd rather move the snprintf call to mozalloc_abort.cpp.
Attachment #8847773 - Flags: review?(mh+mozilla)
Comment on attachment 8847773 [details] Bug 1347672 - Unbreak build on FreeBSD with GCC 6 or later. https://reviewboard.mozilla.org/r/120692/#review127076 snprintf requires mutable char[] but mozalloc_abort has const argument. Do you mean to change the prototype, pass error code as string only to turn it back into an integer or drop integer representation?
Comment on attachment 8847773 [details] Bug 1347672 - Unbreak build on FreeBSD with GCC 6 or later. https://reviewboard.mozilla.org/r/120692/#review129666 ::: memory/mozalloc/mozalloc_abort.cpp:25 (Diff revision 2) > > void > mozalloc_abort(const char* const msg) > { > + char error[128]; > + snprintf(error, sizeof(error)-1, "fatal: STL threw system_error: %s", msg); You're changing the output for other uses of mozalloc_abort. Add a new function that takes two strings. While here, also check the return value from snprintf and just output the strerror in that case.
Attachment #8847773 - Flags: review?(mh+mozilla)
Also please change the commit message to describe what the change is.

Is this still a problem for you?

Flags: needinfo?(jbeich)
Priority: -- → P5
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(jbeich)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: