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

RESOLVED FIXED in Firefox 42

Status

()

Core
Widget: Gtk
RESOLVED FIXED
3 years ago
26 days ago

People

(Reporter: heftig, Assigned: glandium)

Tracking

Trunk
mozilla42
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox42 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
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).
(Reporter)

Updated

3 years ago
Blocks: 627699
(Reporter)

Comment 1

3 years ago
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.
(Reporter)

Comment 2

3 years ago
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"
(Assignee)

Comment 4

3 years ago
(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?
(Assignee)

Comment 6

3 years ago
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.
(Assignee)

Updated

2 years ago
Blocks: 1186229
(Assignee)

Comment 7

2 years ago
Created attachment 8637859 [details] [diff] [review]
Unconditionally use -Wl,--no-as-needed when building with GNU ld/gold
Assignee: nobody → mh+mozilla
Attachment #8637859 - Flags: review?(nfroyd)
Attachment #8637859 - Flags: review?(nfroyd) → review+
(Assignee)

Updated

2 years ago
Duplicate of this bug: 1080654

Comment 9

2 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/738d8ee106fe

Comment 10

2 years ago
https://hg.mozilla.org/integration/fx-team/rev/a052bbea7c2e
https://hg.mozilla.org/mozilla-central/rev/738d8ee106fe
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox42: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
https://hg.mozilla.org/mozilla-central/rev/a052bbea7c2e
(Assignee)

Updated

2 years ago
Depends on: 1187533
(Assignee)

Updated

2 years ago
No longer depends on: 1187533
You need to log in before you can comment on or make changes to this bug.