Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nss: cross compile support #58063

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "1ihzqspvqjmysp1c15xxr7kqvj3zm9dqnanxhkaxyjgx71yv6z88";
};

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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to use NATIVE_CC, OS_TEST and CPU_ARCH unconditionally, no?
This way we have less code that is only when cross-compiling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

Copy link
Member

@Ericson2314 Ericson2314 Jun 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait was this done? Oh as many were moved over as possible?

"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