Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 436216 - dev-libs/nss-3.13.6: fails to cross compile
Summary: dev-libs/nss-3.13.6: fails to cross compile
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords: EBUILD, PATCH
Depends on:
Blocks:
 
Reported: 2012-09-25 13:20 UTC by Ambroz Bizjak
Modified: 2013-09-30 00:58 UTC (History)
3 users (show)

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


Attachments
ebuild patch (nss.patch,3.49 KB, patch)
2012-09-25 13:22 UTC, Ambroz Bizjak
Details | Diff
Call native nsinstall (nss-3.13.6-nsinstall-path.patch,834 bytes, patch)
2012-09-25 13:23 UTC, Ambroz Bizjak
Details | Diff
Don't sign libraries during the build itself (nss-3.13.6-no-sign.patch,855 bytes, patch)
2012-09-25 13:23 UTC, Ambroz Bizjak
Details | Diff
nss-3.14.ebuild-crosscompile-hdepend.patch (nss-3.14.ebuild-crosscompile-hdepend.patch,3.94 KB, patch)
2012-12-05 22:57 UTC, Ambroz Bizjak
Details | Diff
nss-3.14.ebuild-crosscompile-nohdepend.patch (nss-3.14.ebuild-crosscompile-nohdepend.patch,3.25 KB, patch)
2012-12-05 23:09 UTC, Ambroz Bizjak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ambroz Bizjak 2012-09-25 13:20:01 UTC
There are multiple problems preventing NSS from cross compiling:
1. Ebuild calls nspr-config instead of pkg-config.
2. Build system cannot detect the type of target system and assumes it's the same as the host.
3. Build system tries to run cross-compiled nsinstall program.
4. Build system tries to sign libraries with cross-compiled shlibsign program.
5. pkg_postinst tries to sign libraries with cross-compiled shlibsign program.

Reproducible: Always
Comment 1 Ambroz Bizjak 2012-09-25 13:22:09 UTC
Created attachment 324942 [details, diff]
ebuild patch

This patch fixes all the problems mentioned. Two patches are also needed.

Note that nss-3.13.6-no-sign.patch can be applied always (as compared to cross-compile only) because we're going to sign the libs in pkg_postinst() anyway.
Comment 2 Ambroz Bizjak 2012-09-25 13:23:06 UTC
Created attachment 324944 [details, diff]
Call native nsinstall
Comment 3 Ambroz Bizjak 2012-09-25 13:23:26 UTC
Created attachment 324946 [details, diff]
Don't sign libraries during the build itself
Comment 4 Ambroz Bizjak 2012-12-05 22:57:22 UTC
Created attachment 331578 [details, diff]
nss-3.14.ebuild-crosscompile-hdepend.patch

This is a proper fix utilizing HDEPEND and targetroot. This bug should depend on 317337 (EAPI HDEPEND support).
Comment 5 Ambroz Bizjak 2012-12-05 23:09:21 UTC
Created attachment 331580 [details, diff]
nss-3.14.ebuild-crosscompile-nohdepend.patch

This version of the patch is an immediate fix that does not utilize HDEPEND. It fixes the same problems as the above posted patch, just that there is no host dependency on NSS, and instead a pkg_pretend() check is done.
Comment 6 SpanKY gentoo-dev 2013-01-08 04:00:17 UTC
Comment on attachment 331578 [details, diff]
nss-3.14.ebuild-crosscompile-hdepend.patch

>+	export NSPR_INCLUDE_DIR=${ROOT}/$( $(tc-getPKG_CONFIG) --variable includedir nspr )
>+	export NSPR_LIB_DIR=${ROOT}/$( $(tc-getPKG_CONFIG) --variable libdir nspr )

this is wrong -- you should not be using $ROOT.  running pkg_config should be sufficient.

>+	if [ "${ROOT}" == "/" ]; then

use =, not ==
Comment 7 Ambroz Bizjak 2013-01-08 11:27:17 UTC
(In reply to comment #6)
> >+	export NSPR_INCLUDE_DIR=${ROOT}/$( $(tc-getPKG_CONFIG) --variable includedir nspr )
> >+	export NSPR_LIB_DIR=${ROOT}/$( $(tc-getPKG_CONFIG) --variable libdir nspr )
> 
> this is wrong -- you should not be using $ROOT.  running pkg_config should
> be sufficient.

NSPR_INCLUDE_DIR and NSPR_LIB_DIR should be absolute paths. E.g. not "/usr/lib" but "/cross_prefix/usr/lib". But note how the paths within the .pc file are relative to the cross prefix (as they should be), so just reading out the includedir/libdir will give you the wrong value. PKG_CONFIG_SYSROOT_DIR has no effect for "pkg-config --variable", so the cross prefix will not be automatically prepended in this case.

On the other hand, getting the libdir via "pkg-config --libs-only-L" seems impossible, as on my system it prints nothing for NSPR.
Comment 8 Jory A. Pratt gentoo-dev 2013-01-08 13:31:16 UTC
(In reply to comment #6)
> Comment on attachment 331578 [details, diff] [details, diff]
> nss-3.14.ebuild-crosscompile-hdepend.patch
> 
> >+	export NSPR_INCLUDE_DIR=${ROOT}/$( $(tc-getPKG_CONFIG) --variable includedir nspr )
> >+	export NSPR_LIB_DIR=${ROOT}/$( $(tc-getPKG_CONFIG) --variable libdir nspr )
> 
> this is wrong -- you should not be using $ROOT.  running pkg_config should
> be sufficient.
> 
> >+	if [ "${ROOT}" == "/" ]; then
> 
> use =, not ==

If you have tested vapier please feel free to land. Noone in the mozilla team is currently able to test.
Comment 9 SpanKY gentoo-dev 2013-01-21 18:32:16 UTC
(In reply to comment #7)

the build system only uses those paths to add -I/-L flags.  so there is no need to export them to valid locations.  just add the pkg-config output manually to cppflags/ldflags.

(In reply to comment #8)

thanks, i'll commit something in a bit.  hopefully it shouldn't be too ugly.
Comment 10 SpanKY gentoo-dev 2013-01-21 18:39:44 UTC
should be all set now in the tree; thanks for the report!

Commit message: Get cross-compiling working
http://sources.gentoo.org/dev-libs/nss/nss-3.14.1.ebuild?r1=1.8&r2=1.9
Comment 11 Ian Stakenvicius (RETIRED) gentoo-dev 2013-09-13 18:09:02 UTC
(In reply to SpanKY from comment #9)
> (In reply to comment #7)
> 
> the build system only uses those paths to add -I/-L flags.  so there is no
> need to export them to valid locations.  just add the pkg-config output
> manually to cppflags/ldflags.
> 

So while trying to make nss work with multilib-build, on amd64 systems building for ABI=32 the append-ldflags causes a big unresolvable failure:  any existing libnss et. al. libs in /usr/lib32 are used at link time instead of the versions actually being built.  

I bring this up not only because this package needs changing, but other packages may too if append-ldflags is used to add -L's
Comment 12 Ian Stakenvicius (RETIRED) gentoo-dev 2013-09-13 18:55:18 UTC
(In reply to Ian Stakenvicius from comment #11)
> (In reply to SpanKY from comment #9)
> > (In reply to comment #7)
> > 
> > the build system only uses those paths to add -I/-L flags.  so there is no
> > need to export them to valid locations.  just add the pkg-config output
> > manually to cppflags/ldflags.
> > 
> 
> So while trying to make nss work with multilib-build, on amd64 systems
> building for ABI=32 the append-ldflags causes a big unresolvable failure: 
> any existing libnss et. al. libs in /usr/lib32 are used at link time instead
> of the versions actually being built.  
> 
> I bring this up not only because this package needs changing, but other
> packages may too if append-ldflags is used to add -L's

Solution:
@@ -114,9 +114,9 @@
 
        # Take care of nspr settings #436216
        append-cppflags $(${PKG_CONFIG} nspr --cflags)
-       append-ldflags $(${PKG_CONFIG} nspr --libs-only-L)
        unset NSPR_INCLUDE_DIR
-       export NSPR_LIB_DIR=${T}/fake-dir
+       local nsprlibdir=$(${PKG_CONFIG} nspr --libs-only-L |sed -e 's/-L//')
+       export NSPR_LIB_DIR=${nsprlibdir:-${T}/fake-dir}
 
        # Do not let `uname` be used.
        if use kernel_linux ; then


...tested for cross-compile by redlizard with success (well, failure, but the failure seems to do with an unrelated upstream bug)
Comment 13 SpanKY gentoo-dev 2013-09-30 00:58:23 UTC
(In reply to Ian Stakenvicius from comment #12)

i think you're going the wrong way about this.  if LDFLAGS are bleeding across multilib runs, then save/reset the base values before each multilib execution.  if nss is not searching its local dirs first, then update the build to add -L flags to its local paths.