Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 301649 - Firefox and thunderbird wont load on prefix due to dynamic linking problems
Summary: Firefox and thunderbird wont load on prefix due to dynamic linking problems
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-20 17:58 UTC by Richard Connon
Modified: 2010-02-18 15:53 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Connon 2010-01-20 17:58:06 UTC
At the moment it seems nspr and nss installs are customised to install to /usr/lib/nspr and /usr/lib/nss respectively. These paths are then added to /etc/ld.so.conf
As far as I can tell this addition to /etc/ld.so.conf means there's no reason not to just install to /usr/lib in the standard way.

The current method leads to complications with the prefix install since on a prefix we can't modify /etc/ld.so.conf

We can't fix this with rpaths like some other packages do since mozilla have a custom way of loading dynamic libraries.

Reproducible: Always

Steps to Reproduce:
Comment 1 Jory A. Pratt gentoo-dev 2010-01-20 18:10:32 UTC
# put all *.a files in /usr/lib/nss (because some have conflicting names
# with existing libraries)

The same is true for nspr hense the are installed as such.
Comment 2 Fabian Groffen gentoo-dev 2010-01-20 18:15:07 UTC
(In reply to comment #0)
> We can't fix this with rpaths like some other packages do since mozilla have a
> custom way of loading dynamic libraries.

Have you tried adding the paths to nspr and nss to RUNPATH of the mozilla
binary?  I think that just fixes it.  The problem here is that it's really
nasty since we don't know what mozilla links against, since it basically loads
libs that xulrunner says are required.  Maybe a not too ugly hack would be to
take the RUNPATH of xulrunner and add that to the RUNPATH of mozilla-firefox
and mozilla-thunderbird.  That way, we ensure that we have the right search
paths in the front-end binaries based on the core-binary (xulrunner) that has
the proper RUNPATH setup.
Comment 3 Fabian Groffen gentoo-dev 2010-01-21 10:32:47 UTC
I'm affraid this pretty much sucks:

% env LD_LIBRARY_PATH="$EPREFIX/usr/lib/nspr:$EPREFIX/usr/lib/nss:$EPREFIX/usr/lib:$EPREFIX/lib" firefox

(firefox:20546): GLib-WARNING **: g_set_prgname() called multiple times
Segmentation fault
Comment 4 Heiko 2010-01-21 14:27:21 UTC
Well the problem is nss missing an RPATH to nspr (e.g. firefox loads libxul.so, which loads libnss*.so, which wants to load libnspr4.so but fails due to the missing RPATH, hence the crash of firefox).

This can be fixed inside the nss ebuild in a way similar to this one:

    # Force proper RPATH for nspr loading!
    use prefix && append-ldflags -Wl,-R,"${EPREFIX}"/usr/$(get_libdir)/nspr

This works on Linux (tested with firefox and thunderbird), but probably needs some tweaking for portability and non-fuglyness. I'll hand that over to you, grobian.
Comment 5 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-01-22 20:28:55 UTC
(In reply to comment #4)
> Well the problem is nss missing an RPATH to nspr (e.g. firefox loads libxul.so,
> which loads libnss*.so, which wants to load libnspr4.so but fails due to the
> missing RPATH, hence the crash of firefox).
> 
> This can be fixed inside the nss ebuild in a way similar to this one:
> 
>     # Force proper RPATH for nspr loading!
>     use prefix && append-ldflags -Wl,-R,"${EPREFIX}"/usr/$(get_libdir)/nspr
> 
> This works on Linux (tested with firefox and thunderbird), but probably needs
> some tweaking for portability and non-fuglyness. I'll hand that over to you,
> grobian.

confirmed, thanks for your investigation! 

Comment 6 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-01-26 16:25:15 UTC
The fix is in gentoo-x86. For completeness:

%% cvs di
Index: nss-3.12.5.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-libs/nss/nss-3.12.5.ebuild,v
retrieving revision 1.6
diff -u -r1.6 nss-3.12.5.ebuild
--- nss-3.12.5.ebuild   23 Jan 2010 15:42:58 -0000      1.6
+++ nss-3.12.5.ebuild   26 Jan 2010 16:17:49 -0000
@@ -43,6 +43,11 @@
 src_compile() {
        strip-flags

+       # Prefix compat. In Gentoo Linux, defaults to ${ROOT} (can be changed with
+       # EAPI-3). bug 301649
+       [[ -z ${EROOT} ]] && local EROOT=${ROOT}
+       append-ldflags -Wl,-R,"${EROOT}"/usr/$(get_libdir)/nspr
+
        echo > "${T}"/test.c
        $(tc-getCC) -c "${T}"/test.c -o "${T}"/test.o
        case $(file "${T}"/test.o) in


+  26 Jan 2010; Jeremy Olexa <darkside@gentoo.org> nss-3.12.5.ebuild:
+  Fix dynamic linking issues which surfaced in Gentoo Prefix env. Tested on
+  Gentoo Linux system and Gentoo Prefix in bug 301649. Proxy commit approved
+  by the mozilla team

Thanks, all.
Comment 7 Fabian Groffen gentoo-dev 2010-01-26 16:29:19 UTC
Ehrm, sorry guys, but that's just plain wrong.  You shouldn't encode ROOT into any object.  It should just be EPREFIX.
Comment 8 Fabian Groffen gentoo-dev 2010-01-26 16:57:01 UTC
ok, the problem is actually nspr's pkg-config file not including -R/usr/lib/nspr in it's output, like it should (Prefix people: look at e.g. pkg-config --libs libxslt).

So that makes something like:

--- files/nspr-4.8-pkgconfig-gentoo.patch       (revision 56637)
+++ files/nspr-4.8-pkgconfig-gentoo.patch       (working copy)
@@ -53,7 +53,7 @@
 +Name: NSPR
 +Description: The Netscape Portable Runtime
 +Version: @MOD_MAJOR_VERSION@.@MOD_MINOR_VERSION@.@MOD_PATCH_VERSION@
-+Libs: -L${libdir} -lplds@MOD_MAJOR_VERSION@ -lplc@MOD_MAJOR_VERSION@ -lnspr@MOD_MAJOR_VERSION@ -lpthread 
++Libs: -R${libdir} -L${libdir} -lplds@MOD_MAJOR_VERSION@ -lplc@MOD_MAJOR_VERSION@ -lnspr@MOD_MAJOR_VERSION@ -lpthread 
 +Cflags: -I${includedir}
 +
 diff -urN nspr-4.8-orig/mozilla/nsprpub/config/rules.mk nspr-4.8/mozilla/nsprpub/config/rules.mk

Problem with this is that it will break Darwin once we ever port it there.  In the nss ebuild nspr's output should then be propagated properly into the build env, using pkg-config --libs nspr.
Comment 9 Fabian Groffen gentoo-dev 2010-01-26 17:01:32 UTC
The 3.12-nss.pc.in file already does -Wl,-R${libdir}.  A bit too late IMO, should come before or right after the -L.  Anyway, it breaks most notably Darwin, but that is a minor detail right now.
Comment 10 Jory A. Pratt gentoo-dev 2010-01-27 02:14:49 UTC
pkg-config --libs nss
-Wl,-R/usr/lib64/nss -R/usr/lib64/nspr -L/usr/lib64/nss -L/usr/lib64/nspr -lssl3 -lsmime3 -lnssutil3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread

I do not see why you feel it is too late. Either way I have reverted the change to nss and updated nspr to handle proper linking for libs. Once darwin is up and running we can address any issues there.
Comment 11 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-02-01 16:51:53 UTC
I need to re-open this, I just updated the "firefox stack" and can only start firefox like this: "LD_LIBRARY_PATH="$EPREFIX/usr/lib/nspr" firefox" which is identical to the original report.

[ebuild   R   ] dev-libs/nspr-4.8.2-r1  USE="-debug -ipv6" 0 kB
[ebuild   R   ] dev-libs/nss-3.12.5  USE="-utils" 0 kB
[ebuild   R   ] net-libs/xulrunner-1.9.2-r1  USE="alsa -custom-optimization -dbus -debug -gnome -java -libnotify -startup-notification -wifi" 0 kB
[ebuild   R   ] www-client/mozilla-firefox-3.6-r1  USE="alsa bindist -custom-optimization -dbus -gnome -java -libnotify -startup-notification -wifi" LINGUAS="en -af -ar -as -be -bg -bn -bn_BD -bn_IN -ca -cs -cy -da -de -el -en_GB -en_US -eo -es -es_AR -es_CL -es_ES -es_MX -et -eu -fa -fi -fr -fy -fy_NL -ga -ga_IE -gl -gu -gu_IN -he -hi -hi_IN -hr -hu -id -is -it -ja -ka -kk -kn -ko -ku -lt -lv -mk -ml -mr -nb -nb_NO -nl -nn -nn_NO -oc -or -pa -pa_IN -pl -pt -pt_BR -pt_PT -rm -ro -ru -si -sk -sl -sq -sr -sv -sv_SE -ta -ta_LK -te -th -tr -uk -vi -zh_CN -zh_TW" 0 kB
Comment 12 Fabian Groffen gentoo-dev 2010-02-04 14:22:18 UTC
I suspected so, since nss does not seem to use pkg-config --libs nspr to build/link.
Comment 13 Jory A. Pratt gentoo-dev 2010-02-11 03:33:26 UTC
(In reply to comment #12)
> I suspected so, since nss does not seem to use pkg-config --libs nspr to
> build/link.
> 

Issue should be officially resolved, the libs have been moved to standard location.
Comment 14 Fabian Groffen gentoo-dev 2010-02-11 10:16:07 UTC
that sounds pretty cool!
Comment 15 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-02-18 15:53:15 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > I suspected so, since nss does not seem to use pkg-config --libs nspr to
> > build/link.
> > 
> 
> Issue should be officially resolved, the libs have been moved to standard
> location.
> 

Thank you! All seems to work without such nasties like comment #11 (LD_LIBRARY_PATH hack)

[ebuild   R   ] dev-libs/nspr-4.8.3-r2  USE="-debug" 0 kB
[ebuild   R   ] dev-libs/nss-3.12.5-r1  USE="-utils" 0 kB
[ebuild   R   ] net-libs/xulrunner-1.9.2-r2  USE="alsa -custom-optimization -dbus -debug -gnome -java -libnotify -startup-notification -wifi" 0 kB
[ebuild   R   ] www-client/mozilla-firefox-3.6-r2  USE="alsa bindist -custom-optimization -dbus -gnome -java -libnotify -startup-notification -wifi" LINGUAS="en -af -ar -as -be -bg -bn -bn_BD -bn_IN -ca -cs -cy -da -de -el -en_GB -en_US -eo -es -es_AR -es_CL -es_ES -es_MX -et -eu -fa -fi -fr -fy -fy_NL -ga -ga_IE -gl -gu -gu_IN -he -hi -hi_IN -hr -hu -id -is -it -ja -ka -kk -kn -ko -ku -lt -lv -mk -ml -mr -nb -nb_NO -nl -nn -nn_NO -oc -or -pa -pa_IN -pl -pt -pt_BR -pt_PT -rm -ro -ru -si -sk -sl -sq -sr -sv -sv_SE -ta -ta_LK -te -th -tr -uk -vi -zh_CN -zh_TW" 0 kB