Closed Bug 1367775 Opened 3 years ago Closed 3 years ago

build error: redefinition of 'long int std::abs(long int)

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: petr.sumbera, Assigned: petr.sumbera)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Build ID: 20170518000419

Steps to reproduce:

I'm getting following error during Firefox build on Solaris with gcc 5.4:

 0:30.05 /usr/bin/g++ -std=gnu++11 -o RefBase.o -c -I/var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/stl_wrappers -I/var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/system_wrappers -include /var/tmp/firefox/config/gcc_hidden.h -DNDEBUG=1 -DTRIMMED=1 -DANDROID_SMP=0 -DLOG_NDEBUG=1 -D_GLIBCXX_OS_DEFINES -DHAVE_SYS_UIO_H -DFAKE_LOG_DEVICE -DSTATIC_EXPORTABLE_JS_API -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -I/var/tmp/firefox/media/libstagefright -I/var/tmp/firefox/obj-x86_64-pc-solaris2.12/media/libstagefright -I/var/tmp/firefox/media/libstagefright/binding/include -I/var/tmp/firefox/media/libstagefright/frameworks/av/include -I/var/tmp/firefox/media/libstagefright/frameworks/av/include/media/stagefright/foundation -I/var/tmp/firefox/media/libstagefright/frameworks/av/media/libstagefright -I/var/tmp/firefox/media/libstagefright/stubs/empty -I/var/tmp/firefox/media/libstagefright/stubs/include -I/var/tmp/firefox/media/libstagefright/stubs/include/media/stagefright/foundation -I/var/tmp/firefox/media/libstagefright/system/core/include -I/var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/include  -I/var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/include/nspr -I/var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/include/nss       -fPIC  -DMOZILLA_CLIENT -include /var/tmp/firefox/obj-x86_64-pc-solaris2.12/mozilla-config.h -MD -MP -MF .deps/RefBase.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 -pthread -pipe  -g -O -fno-omit-frame-pointer  -Werror=format -Wno-multichar -Wno-sign-compare -Wno-unused -fdiagnostics-color  /var/tmp/firefox/media/libstagefright/system/core/libutils/RefBase.cpp
 0:30.23 In file included from /var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/system_wrappers/cstdlib:3:0,
 0:30.24                  from /var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/stl_wrappers/cstdlib:44,
 0:30.24                  from /var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/include/mozilla/mozalloc.h:21,
 0:30.24                  from /var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/stl_wrappers/new:52,
 0:30.25                  from /var/tmp/firefox/media/libstagefright/system/core/include/utils/TypeHelpers.h:20,
 0:30.25                  from /var/tmp/firefox/media/libstagefright/system/core/include/utils/RefBase.h:28,
 0:30.25                  from /var/tmp/firefox/media/libstagefright/frameworks/av/include/media/stagefright/MetaData.h:25,
 0:30.26                  from /var/tmp/firefox/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp:28:
 0:30.26 /usr/gcc/5/include/c++/5.4.0/cstdlib: In function 'long int std::abs(long int)':
 0:30.26 /usr/gcc/5/include/c++/5.4.0/cstdlib:166:3: error: redefinition of 'long int std::abs(long int)'
 0:30.27    abs(long __i) { return __builtin_labs(__i); }
 0:30.27    ^
 0:30.27 In file included from /usr/include/stdlib.h:12:0,
 0:30.27                  from /var/tmp/firefox/obj-x86_64-pc-solaris2.12/dist/system_wrappers/stdlib.h:3,
 0:30.28                  from /var/tmp/firefox/media/libstagefright/frameworks/av/media/libstagefright/MetaData.cpp:22:
 0:30.28 /usr/include/iso/stdlib_iso.h:204:16: note: 'long int std::abs(long int)' previously defined here
 0:30.28   inline long   abs(long _l) { return labs(_l); }
 0:30.29                 ^
...

This seems to be related to mozalloc.h:

#if defined(__cplusplus)
#  include <new>
// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the
// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code
// using things defined there. Specifically, with stdlib.h, the use of abs()
// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs()
#  include <cstdlib>
#  include <cstring>
#else
#  include <stdlib.h>
#  include <string.h>
#endif
So I was wrong to suspect mozalloc.h. The issue disappears when _GLIBCXX_OS_DEFINES is removed from above command line.

This is actually well known issue which just need to finally committed:
https://openindiana.org/pipermail/openindiana-discuss/2015-November/018290.html
Summary: mozalloc.h related build error: redefinition of 'long int std::abs(long int) → build error: redefinition of 'long int std::abs(long int)
Attached patch Bug1367775.patch (obsolete) — Splinter Review
Attachment #8871703 - Flags: review?(gsquelart)
Component: Untriaged → Build Config
Product: Firefox → Core
Comment on attachment 8871703 [details] [diff] [review]
Bug1367775.patch

Review of attachment 8871703 [details] [diff] [review]:
-----------------------------------------------------------------

r+ with nit:

::: media/libstagefright/moz.build
@@ +10,4 @@
>  DEFINES['ANDROID_SMP'] = 0
>  DEFINES['LOG_NDEBUG'] = 1
>  
> +if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['OS_TARGET'] != 'SunOS': 

Please remove the trailing space.
Attachment #8871703 - Flags: review?(gsquelart) → review+
Assignee: nobody → petr.sumbera
Attached patch Bug1367775.patchSplinter Review
Attachment #8871703 - Attachment is obsolete: true
Attachment #8872268 - Flags: review?(gsquelart)
Comment on attachment 8872268 [details] [diff] [review]
Bug1367775.patch

Review of attachment 8872268 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks Petr.
Attachment #8872268 - Flags: review?(gsquelart) → review+
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/395b41d878df
libstagefright build should avoid _GLIBCXX_OS_DEFINES on Solaris. r=gerald
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/395b41d878df
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.