Closed Bug 1712675 Opened 4 years ago Closed 4 years ago

Adding new CPP files into widget/gtk causes various build failure

Categories

(Core :: Widget: Gtk, defect)

Desktop
Linux
defect

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

https://treeherder.mozilla.org/jobs?repo=try&selectedTaskRun=ZU9H5Ko4TGGFReeY8pttLg.0&revision=33bb02ffbed37c5dcee4c01d3b3b4815d2d4c6f4

First, I'd like to add GtkIMContextProxy.cpp which does not depend on any other files under the directory. However, I need to add the following change:
https://hg.mozilla.org/try/diff/c20d1577f3ecd5de5d2ecd6f938811511df432b9/widget/gtk/WaylandShmBuffer.cpp

Then, I'd like to add PangoAttrProxy.cpp which also does not depend on any other files under the directory. Then, I got the following errors again:

[task 2021-05-25T06:29:53.312Z] 06:29:53     INFO -  make[4]: Entering directory '/builds/worker/workspace/obj-build/widget/gtk'
[task 2021-05-25T06:29:53.317Z] 06:29:53     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot -std=gnu++17 -o Unified_cpp_widget_gtk1.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -ftrivial-auto-var-init=pattern -DDEBUG=1 -DOS_POSIX=1 -DOS_LINUX=1 -DCAIRO_GFX '-DMOZ_APP_NAME="firefox"' -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/widget/gtk -I/builds/worker/workspace/obj-build/widget/gtk -I/builds/worker/workspace/obj-build/ipc/ipdl/_ipdlheaders -I/builds/worker/checkouts/gecko/ipc/chromium/src -I/builds/worker/checkouts/gecko/ipc/glue -I/builds/worker/checkouts/gecko/layout/base -I/builds/worker/checkouts/gecko/layout/forms -I/builds/worker/checkouts/gecko/layout/generic -I/builds/worker/checkouts/gecko/layout/xul -I/builds/worker/checkouts/gecko/other-licenses/atk-1.0 -I/builds/worker/checkouts/gecko/third_party/cups/include -I/builds/worker/checkouts/gecko/widget -I/builds/worker/checkouts/gecko/widget/headless -I/builds/worker/checkouts/gecko/widget/x11 -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/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 -Werror=non-literal-null-conversion -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 -D_GLIBCXX_USE_CXX11_ABI=0 -fno-sized-deallocation -fno-aligned-new -fcrash-diagnostics-dir=/builds/worker/artifacts -fno-exceptions -fno-strict-aliasing -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -Os -fno-omit-frame-pointer -funwind-tables -Werror -I/builds/worker/checkouts/gecko/widget/gtk/compat-gtk3 -pthread -I/builds/worker/fetches/sysroot/usr/include/gtk-3.0/unix-print -I/builds/worker/fetches/sysroot/usr/include/gtk-3.0 -I/builds/worker/fetches/sysroot/usr/include/at-spi2-atk/2.0 -I/builds/worker/fetches/sysroot/usr/include/at-spi-2.0 -I/builds/worker/fetches/sysroot/usr/include/dbus-1.0 -I/builds/worker/fetches/sysroot/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/builds/worker/fetches/sysroot/usr/include/gtk-3.0 -I/builds/worker/fetches/sysroot/usr/include/cairo -I/builds/worker/fetches/sysroot/usr/include/pango-1.0 -I/builds/worker/fetches/sysroot/usr/include/harfbuzz -I/builds/worker/fetches/sysroot/usr/include/pango-1.0 -I/builds/worker/fetches/sysroot/usr/include/atk-1.0 -I/builds/worker/fetches/sysroot/usr/include/cairo -I/builds/worker/fetches/sysroot/usr/include/pixman-1 -I/builds/worker/fetches/sysroot/usr/include/freetype2 -I/builds/worker/fetches/sysroot/usr/include/libpng12 -I/builds/worker/fetches/sysroot/usr/include/gdk-pixbuf-2.0 -I/builds/worker/fetches/sysroot/usr/include/libpng12 -I/builds/worker/fetches/sysroot/usr/include/gio-unix-2.0/ -I/builds/worker/fetches/sysroot/usr/include/glib-2.0 -I/builds/worker/fetches/sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/builds/worker/fetches/sysroot/usr/include/gtk-3.0 -I/builds/worker/fetches/sysroot/usr/include/at-spi2-atk/2.0 -I/builds/worker/fetches/sysroot/usr/include/at-spi-2.0 -I/builds/worker/fetches/sysroot/usr/include/dbus-1.0 -I/builds/worker/fetches/sysroot/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/builds/worker/fetches/sysroot/usr/include/gtk-3.0 -I/builds/worker/fetches/sysroot/usr/include/gio-unix-2.0/ -I/builds/worker/fetches/sysroot/usr/include/cairo -I/builds/worker/fetches/sysroot/usr/include/pango-1.0 -I/builds/worker/fetches/sysroot/usr/include/harfbuzz -I/builds/worker/fetches/sysroot/usr/include/pango-1.0 -I/builds/worker/fetches/sysroot/usr/include/atk-1.0 -I/builds/worker/fetches/sysroot/usr/include/cairo -I/builds/worker/fetches/sysroot/usr/include/pixman-1 -I/builds/worker/fetches/sysroot/usr/include/freetype2 -I/builds/worker/fetches/sysroot/usr/include/libpng12 -I/builds/worker/fetches/sysroot/usr/include/gdk-pixbuf-2.0 -I/builds/worker/fetches/sysroot/usr/include/libpng12 -I/builds/worker/fetches/sysroot/usr/include/glib-2.0 -I/builds/worker/fetches/sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/builds/worker/fetches/sysroot/usr/include/libdrm -I/builds/worker/fetches/sysroot/usr/include/dbus-1.0 -I/builds/worker/fetches/sysroot/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/builds/worker/fetches/sysroot/usr/include/glib-2.0 -I/builds/worker/fetches/sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wno-error=shadow -Werror=switch -fexperimental-new-pass-manager  -MD -MP -MF .deps/Unified_cpp_widget_gtk1.o.pp   Unified_cpp_widget_gtk1.cpp
[task 2021-05-25T06:29:53.319Z] 06:29:53     INFO -  In file included from Unified_cpp_widget_gtk1.cpp:47:
[task 2021-05-25T06:29:53.320Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:63:10: error: expression result unused [-Werror,-Wunused-value]
[task 2021-05-25T06:29:53.321Z] 06:29:53     INFO -      LOG(("Drawing to nsWindow %p will use wl_surface\n", mWidget));
[task 2021-05-25T06:29:53.322Z] 06:29:53     INFO -           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.323Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:63:56: error: possible misuse of comma operator here [-Werror,-Wcomma]
[task 2021-05-25T06:29:53.324Z] 06:29:53     INFO -      LOG(("Drawing to nsWindow %p will use wl_surface\n", mWidget));
[task 2021-05-25T06:29:53.325Z] 06:29:53     INFO -                                                         ^
[task 2021-05-25T06:29:53.326Z] 06:29:53     INFO -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:63:10: note: cast expression to void to silence warning
[task 2021-05-25T06:29:53.327Z] 06:29:53     INFO -      LOG(("Drawing to nsWindow %p will use wl_surface\n", mWidget));
[task 2021-05-25T06:29:53.328Z] 06:29:53     INFO -           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.328Z] 06:29:53     INFO -           static_cast<void>(                            )
[task 2021-05-25T06:29:53.329Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:63:5: error: use of undeclared identifier 'LOG'
[task 2021-05-25T06:29:53.329Z] 06:29:53     INFO -      LOG(("Drawing to nsWindow %p will use wl_surface\n", mWidget));
[task 2021-05-25T06:29:53.330Z] 06:29:53     INFO -      ^
[task 2021-05-25T06:29:53.330Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:74:12: error: expression result unused [-Werror,-Wunused-value]
[task 2021-05-25T06:29:53.330Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use XRender\n", mXWindow));
[task 2021-05-25T06:29:53.331Z] 06:29:53     INFO -             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.331Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:74:56: error: possible misuse of comma operator here [-Werror,-Wcomma]
[task 2021-05-25T06:29:53.331Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use XRender\n", mXWindow));
[task 2021-05-25T06:29:53.332Z] 06:29:53     INFO -                                                         ^
[task 2021-05-25T06:29:53.333Z] 06:29:53     INFO -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:74:12: note: cast expression to void to silence warning
[task 2021-05-25T06:29:53.333Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use XRender\n", mXWindow));
[task 2021-05-25T06:29:53.334Z] 06:29:53     INFO -             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.335Z] 06:29:53     INFO -             static_cast<void>(                          )
[task 2021-05-25T06:29:53.335Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:74:7: error: use of undeclared identifier 'LOG'
[task 2021-05-25T06:29:53.336Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use XRender\n", mXWindow));
[task 2021-05-25T06:29:53.337Z] 06:29:53     INFO -        ^
[task 2021-05-25T06:29:53.338Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:81:12: error: expression result unused [-Werror,-Wunused-value]
[task 2021-05-25T06:29:53.338Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use MIT-SHM\n", mXWindow));
[task 2021-05-25T06:29:53.339Z] 06:29:53     INFO -             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.340Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:81:56: error: possible misuse of comma operator here [-Werror,-Wcomma]
[task 2021-05-25T06:29:53.341Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use MIT-SHM\n", mXWindow));
[task 2021-05-25T06:29:53.342Z] 06:29:53     INFO -                                                         ^
[task 2021-05-25T06:29:53.342Z] 06:29:53     INFO -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:81:12: note: cast expression to void to silence warning
[task 2021-05-25T06:29:53.343Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use MIT-SHM\n", mXWindow));
[task 2021-05-25T06:29:53.344Z] 06:29:53     INFO -             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.345Z] 06:29:53     INFO -             static_cast<void>(                          )
[task 2021-05-25T06:29:53.345Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:81:7: error: use of undeclared identifier 'LOG'
[task 2021-05-25T06:29:53.346Z] 06:29:53     INFO -        LOG(("Drawing to Window 0x%lx will use MIT-SHM\n", mXWindow));
[task 2021-05-25T06:29:53.347Z] 06:29:53     INFO -        ^
[task 2021-05-25T06:29:53.348Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:87:10: error: expression result unused [-Werror,-Wunused-value]
[task 2021-05-25T06:29:53.350Z] 06:29:53     INFO -      LOG(("Drawing to Window 0x%lx will use XPutImage\n", mXWindow));
[task 2021-05-25T06:29:53.350Z] 06:29:53     INFO -           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.351Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:87:56: error: possible misuse of comma operator here [-Werror,-Wcomma]
[task 2021-05-25T06:29:53.352Z] 06:29:53     INFO -      LOG(("Drawing to Window 0x%lx will use XPutImage\n", mXWindow));
[task 2021-05-25T06:29:53.353Z] 06:29:53     INFO -                                                         ^
[task 2021-05-25T06:29:53.353Z] 06:29:53     INFO -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:87:10: note: cast expression to void to silence warning
[task 2021-05-25T06:29:53.354Z] 06:29:53     INFO -      LOG(("Drawing to Window 0x%lx will use XPutImage\n", mXWindow));
[task 2021-05-25T06:29:53.355Z] 06:29:53     INFO -           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2021-05-25T06:29:53.355Z] 06:29:53     INFO -           static_cast<void>(                            )
[task 2021-05-25T06:29:53.356Z] 06:29:53    ERROR -  /builds/worker/checkouts/gecko/widget/gtk/WindowSurfaceProvider.cpp:87:5: error: use of undeclared identifier 'LOG'
[task 2021-05-25T06:29:53.356Z] 06:29:53     INFO -      LOG(("Drawing to Window 0x%lx will use XPutImage\n", mXWindow));
[task 2021-05-25T06:29:53.356Z] 06:29:53     INFO -      ^
[task 2021-05-25T06:29:53.357Z] 06:29:53     INFO -  12 errors generated.
[task 2021-05-25T06:29:53.357Z] 06:29:53    ERROR -  make[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:676: Unified_cpp_widget_gtk1.o] Error 1
[task 2021-05-25T06:29:53.357Z] 06:29:53     INFO -  make[4]: Leaving directory '/builds/worker/workspace/obj-build/widget/gtk'
[task 2021-05-25T06:29:53.357Z] 06:29:53     INFO -  make[4]: *** Waiting for unfinished jobs....

It seems that WindowSurfaceProvider.cpp depends on LOG macro which is defined by another cpp file which was defined under current condition.

WakeLockListener.cpp and WaylandShmBuffer.cpp are removed, and nsClipboardWayland.cpp and nsClipboardX11.cpp are added.

I guess that this #undef LOG causes the dependency.
https://searchfox.org/mozilla-central/rev/08f063f4c89d270fd809fc0325b5a9000ae87d63/widget/gtk/WaylandShmBuffer.cpp#18

rmader: Could you take a look? It's created by you in bug 1711094.

Flags: needinfo?(robert.mader)

Hm, so I actually just cargo-culted this from https://searchfox.org/mozilla-central/source/widget/gtk/WindowSurfaceWayland.cpp#24-33 - bug 1711094 only split some code out of that. That in turn appear to come from e.g. https://searchfox.org/mozilla-central/source/widget/gtk/MozContainer.cpp#20-29, where LOG is actually redefined.

So it looks to me like we can simply drop that #undef LOG in WaylandShmBuffer.cpp as we only define LOGWAYLAND - would that solve your issue?

Flags: needinfo?(robert.mader)

Yeah, If I just commented out the #undef LOG and made nsClipboardWayland.cpp include nsWindow.h, most errors have gone. Ideally, there should be inline methods instead of this kind of shortcut macros in a header file. Then, CPP file order becomes no problem anymore.

Although I still see:

 0:08.51 In file included from /home/toybox/mozilla/src/widget/gtk/nsNativeThemeGTK.cpp:37:
 0:08.51 /home/toybox/mozilla/fx-gtk3-dbg/dist/include/mozilla/gfx/BorrowedContext.h:124:3: error: reference to 'Screen' is ambiguous
 0:08.51   Screen* mScreen;
 0:08.51   ^
 0:08.51 /usr/include/X11/Xlib.h:275:3: note: candidate found by name lookup is 'Screen'
 0:08.51 } Screen;
 0:08.51   ^
 0:08.51 /home/toybox/mozilla/fx-gtk3-dbg/dist/include/mozilla/widget/Screen.h:23:7: note: candidate found by name lookup is 'mozilla::widget::Screen'
 0:08.51 class Screen final : public nsIScreen {
 0:08.51       ^
Assignee: nobody → masayuki
Status: NEW → ASSIGNED

LOG is defined by nsWindow.h for a shortcut of MOZ_LOG for generic use
under widget/gtk. However, some cpp files do #undef LOG and redefine it.
This causes the CPP file order important in unified cpp files since a CPP
file's LOG may be redefined unexpectedly with changing the unified order
and/or group. Therefore, each cpp file should define its own macro name
instead of redefining LOG.

Depends on D115977

Some headers which are included by nsNativeThemeGTK.cpp are confused by
Screen in Xlib.h and mozilla::widget::Screen in widget/Screen.h.
Unless CPP files stop using using namespace mozilla::widget, we cannot
build with unified cpp files.

Depends on D115978

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/799a3bb97821 part 1: Add missing header includes under widget/gtk r=rmader https://hg.mozilla.org/integration/autoland/rev/ca128b6fdeb4 part 2: Make any cpp file under `widget/gtk` stop redefining `LOG` macro r=rmader,stransky https://hg.mozilla.org/integration/autoland/rev/c935dbe9e149 part 3: Stop unifying nsNativeThemeGTK.cpp r=rmader
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: