Closed Bug 1063359 Opened 10 years ago Closed 9 years ago

Firefox fails to run with GTK3, in the presence of --as-needed, with "libxul.so: undefined symbol: gtk_main_do_event"

Categories

(Core :: Widget: Gtk, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: heftig, Assigned: glandium)

References

Details

Attachments

(1 file)

If LDFLAGS contains -Wl,--as-needed and Firefox 34.0a2 is configured with GTK3 widgets, xpcshell fails during the build, complaining about a symbol lookup error in libxul.so:

/tmp/mozilla-central/obj-x86_64-unknown-linux-gnu/dist/bin/xpcshell: symbol lookup error: /tmp/mozilla-central/obj-x86_64-unknown-linux-gnu/dist/bin/libxul.so: undefined symbol: gtk_main_do_event

Without --as-needed, libxul.so directly depends on libgtk-3.so.0, breaking the plugin-container (bug 1051209).
Blocks: gtk3
A common cause for this problem is misordering the libs on the ld command line. If lib A depends on lib B, lib A must be first on the command line, otherwise ld with --as-needed skips lib B as nothing depends on it.
Ah, my builds might trigger this bug because my LDFLAGS don't contain a literal "-Wl,--as-needed" (the build system checks for that), but the --as-needed is part of a longer -Wl, specifically "-Wl,-O1,--sort-common,--as-needed,-z,relro"
Just got a report on IRC of a gtk3-enabled build *building* successfully, but failing to *run*, with the same issue from comment 0 ("libxul.so: undefined symbol: gtk_main_do_event").  Marking as "confirmed" based on that report.

(I think comment 0 is really a failure to *run*, not a failure to *build*. Even though it's part of the build process, if we're starting xpcshell & libxul, then we've already built gecko. Hence, generalizing summary to be about running instead of building.)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: GTK3 fails to build in the presence of --as-needed → Firefox fails to run with GTK3, in the presence of --as-needed
Version: 34 Branch → Trunk
Summary: Firefox fails to run with GTK3, in the presence of --as-needed → Firefox fails to run with GTK3, in the presence of --as-needed, with "libxul.so: undefined symbol: gtk_main_do_event"
(In reply to Jan Steffens from comment #2)
> Ah, my builds might trigger this bug because my LDFLAGS don't contain a
> literal "-Wl,--as-needed" (the build system checks for that), but the
> --as-needed is part of a longer -Wl, specifically
> "-Wl,-O1,--sort-common,--as-needed,-z,relro"

Yes, the build system looks for an independent -Wl,--as-needed in LDFLAGS to trigger using -Wl,--no-as-needed "appropriately".
I'm running into this in Ubuntu 15.04 and it looks like gcc is adding -Wl,--as-needed by default. Can we just unconditionally add -Wl,--no-as-needed?
We'd need to detect what the linker uses by default. Because -Wl,--no-as-needed affects all the following linked libraries, including those the compiler adds on its own. So the -Wl,--no-as-needed -llib -Wl,--as-needed pattern is needed, but then that would make all following libraries linked "as-needed" on no-as-needed builds.

Or, we could just force -Wl,--as-needed on all our builds.
Blocks: 1186229
Assignee: nobody → mh+mozilla
Attachment #8637859 - Flags: review?(nfroyd)
Attachment #8637859 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/738d8ee106fe
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Depends on: 1187533
No longer depends on: 1187533
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: