Closed Bug 1694575 Opened 8 months ago Closed 8 months ago

Can't compile Firefox 86.0 with Clang/LLVM/libc++ 12.0.0 rc1

Categories

(Firefox Build System :: General, defect)

Firefox 86
defect

Tracking

(firefox88 fixed)

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: w12101111, Assigned: glandium)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0

Steps to reproduce:

Compile firefox 86.0 ( or 85.0.2 ) using Clang/LLVM/libc++ 12

Actual results:

Clang command line:

8 7:50.62 /usr/lib/ccache/bin/clang++ -std=gnu++17 -o Unified_cpp_webaudio_blink0.o -c  -I/tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/dist/stl_wrappers -I/tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/dist/system_wrappers -include /tmp/portage/www-client/firefox-86.0/work/firefox-86.0/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -DNDEBUG=1 -DTRIMMED=1 -DUSE_SSE2 -DOS_POSIX=1 -DOS_LINUX=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/tmp/portage/www-client/firefox-86.0/work/firefox-86.0/dom/media/webaudio/blink -I/tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/dom/media/webaudio/blink -I/tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/ipc/ipdl/_ipdlheaders -I/tmp/portage/www-client/firefox-86.0/work/firefox-86.0/ipc/chromium/src -I/tmp/portage/www-client/firefox-86.0/work/firefox-86.0/ipc/glue -I/tmp/portage/www-client/firefox-86.0/work/firefox-86.0/dom/media/webaudio -I/tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/dist/include -I/usr/include/nspr -I/usr/include/nss -I/usr/include/nspr -I/tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/dist/include/nss -I/usr/include/pixman-1 -fPIC -DMOZILLA_CLIENT -include /tmp/portage/www-client/firefox-86.0/work/firefox_build/instrumented/mozilla-config.h -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wwrite-strings -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wimplicit-fallthrough -Wunused-function -Wunused-variable -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wno-error=tautological-type-limit-compare -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=free-nonheap-object -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-psabi -Wno-unknown-warning-option -fno-sized-deallocation -fno-aligned-new -march=skylake -mtune=skylake -pipe -falign-functions=32 -fomit-frame-pointer -ffunction-sections -fdata-sections -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -O3 -fomit-frame-pointer -funwind-tables -Wno-shadow -fexperimental-new-pass-manager -DNS_FREE_PERMANENT_DATA=1 -fprofile-generate -DMOZ_PROFILE_INSTRUMENTATION -MD -MP -MF .deps/Unified_cpp_webaudio_blink0.o.pp  -fcolor-diagnostics  Unified_cpp_webaudio_blink0.cpp

8 8:01.17 In file included from Unified_cpp_webaudio_blink0.cpp:2:
8 8:01.18 In file included from /tmp/portage/www-client/firefox-86.0/work/firefox-86.0/dom/media/webaudio/blink/Biquad.cpp:29:
8 8:01.18 In file included from ../../../../../../firefox-86.0/dom/media/webaudio/blink/Biquad.h:32:
8 8:01.18 In file included from ../../../../dist/system_wrappers/complex:3:
8 8:01.19 In file included from /usr/include/c++/v1/complex:236:
8 8:01.19 In file included from /usr/include/c++/v1/stdexcept:46:
8 8:01.19 In file included from ../../../../dist/system_wrappers/exception:3:
8 8:01.19 In file included from /usr/include/c++/v1/exception:81:
8 8:01.19 In file included from /usr/include/c++/v1/__memory/base.h:14:
8 8:01.19 In file included from /usr/include/c++/v1/__debug:14:
8 8:01.19 In file included from ../../../../dist/stl_wrappers/iosfwd:58:
8 8:01.20 In file included from ../../../../dist/include/mozilla/mozalloc.h:16:
8 8:01.20 In file included from ../../../../dist/stl_wrappers/new:52:
8 8:01.20 In file included from ../../../../dist/system_wrappers/new:3:
8 8:01.20 /usr/include/c++/v1/new:127:14: error: expected class name
8 8:01.20     : public exception
8 8:01.20              ^
8 8:01.20 1 error generated.
8 8:01.20 gmake[4]: *** [/tmp/portage/www-client/firefox-86.0/work/firefox-86.0/config/rules.mk:674: Unified_cpp_webaudio_blink0.o] Error 1

The exception class is defined in /usr/include/c++/v1/exception, and it's used in /usr/include/c++/v1/new:

class _LIBCPP_EXCEPTION_ABI bad_alloc
    : public exception
{
public:
    bad_alloc() _NOEXCEPT;
    virtual ~bad_alloc() _NOEXCEPT;
    virtual const char* what() const _NOEXCEPT;
};

I remove the "# include "mozilla/mozalloc.h" in dist/stl_wrappers/iosfwd as a workaround.

Expected results:

It should compile without error.

The Bugbug bot thinks this bug should belong to the 'Firefox Build System::General' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → General
Product: Firefox → Firefox Build System

This probably has nothing to do with clang, except if your C++ headers in /usr/include/c++ come from libc++. In most cases, they would come from GCC's libstdc++. Can you confirm which one they come from, and what version the are?

Flags: needinfo?(w12101111)

Oh, I missed the -stdlib=libc++ in the command line.

Flags: needinfo?(w12101111)

Can you try the following patch?

diff --git a/config/gcc-stl-wrapper.template.h b/config/gcc-stl-wrapper.template.h
index 9fe70fbaab8dc..cf3f0ec94114c 100644
--- a/config/gcc-stl-wrapper.template.h
+++ b/config/gcc-stl-wrapper.template.h
@@ -40,6 +40,10 @@
 #  define moz_dont_include_mozalloc_for_limits
 #endif
 
+#ifndef moz_dont_include_mozalloc_for_iosfwd
+#  define moz_dont_include_mozalloc_for_iosfwd
+#endif
+
 // Include mozalloc after the STL header and all other headers it includes
 // have been preprocessed.
 #if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
Flags: needinfo?(w12101111)

This patch fix it!

Flags: needinfo?(w12101111)
Assignee: nobody → mh+mozilla
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f875a4ffd653
Don't include mozalloc.h from the iosfwd wrapper. r=andi
Status: UNCONFIRMED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch

Would be nice if we could uplift into Firefox 78 ESR, we hit this in Gentoo.

can confirm that the build completes successfully with libc++12 when the patch is applied to 78esr.

You need to log in before you can comment on or make changes to this bug.