Skip to content

Commit

Permalink
Merge pull request #58063 from illegalprime/nss-cross
Browse files Browse the repository at this point in the history
nss: cross compile support
  • Loading branch information
matthewbauer authored Jun 11, 2019
2 parents d641d2b + 6261601 commit fc04ec9
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions pkgs/development/libraries/nss/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, nspr, perl, zlib, sqlite, fixDarwinDylibNames }:
{ stdenv, fetchurl, nspr, perl, zlib, sqlite, fixDarwinDylibNames, buildPackages }:

let
nssPEM = fetchurl {
Expand All @@ -17,7 +17,11 @@ in stdenv.mkDerivation rec {
sha256 = "1zvabgxlyvz3fnv4w89y4a5qkscjmm88naf929dgvvgfnrchwqm5";
};

buildInputs = [ perl zlib sqlite ]
depsBuildBuild = [ buildPackages.stdenv.cc ];

nativeBuildInputs = [ perl ];

buildInputs = [ zlib sqlite ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;

propagatedBuildInputs = [ nspr ];
Expand All @@ -43,7 +47,9 @@ in stdenv.mkDerivation rec {

preConfigure = "cd nss";

makeFlags = [
makeFlags = let
cpu = stdenv.hostPlatform.parsed.cpu.name;
in [
"NSPR_INCLUDE_DIR=${nspr.dev}/include"
"NSPR_LIB_DIR=${nspr.out}/lib"
"NSDISTMODE=copy"
Expand All @@ -52,6 +58,12 @@ in stdenv.mkDerivation rec {
"NSS_ENABLE_ECC=1"
"USE_SYSTEM_ZLIB=1"
"NSS_USE_SYSTEM_SQLITE=1"
"NATIVE_CC=${buildPackages.stdenv.cc}/bin/cc"
] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
"OS_TEST=${cpu}"
"CPU_ARCH=${cpu}"
"CROSS_COMPILE=1"
"NSS_DISABLE_GTESTS=1" # don't want to build tests when cross-compiling
] ++ stdenv.lib.optional stdenv.is64bit "USE_64=1"
++ stdenv.lib.optional stdenv.isDarwin "CCC=clang++";

Expand Down Expand Up @@ -95,7 +107,10 @@ in stdenv.mkDerivation rec {
chmod 0755 $out/bin/nss-config
'';

postFixup = ''
postFixup = let
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
nss = if isCross then buildPackages.nss.tools else "$out";
in ''
for libname in freebl3 nssdbm3 softokn3
do '' +
(if stdenv.isDarwin
Expand All @@ -106,7 +121,7 @@ in stdenv.mkDerivation rec {
libfile="$out/lib/lib$libname.so"
LD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \
'') + ''
$out/bin/shlibsign -v -i "$libfile"
${nss}/bin/shlibsign -v -i "$libfile"
done
moveToOutput bin "$tools"
Expand Down

0 comments on commit fc04ec9

Please sign in to comment.