nss: fix build for FreeBSD (#387520)

authored by

John Ericson and committed by
GitHub
bc8fbef5 3f894873

+31 -12
+31 -12
pkgs/development/libraries/nss/generic.nix
··· 102 102 platform.parsed.cpu.name; 103 103 # yes, this is correct. nixpkgs uses "host" for the platform the binary will run on whereas nss uses "host" for the platform that the build is running on 104 104 target = getArch stdenv.hostPlatform; 105 + target_system = stdenv.hostPlatform.uname.system; 105 106 host = getArch stdenv.buildPlatform; 107 + 108 + buildFlags = 109 + [ 110 + "-v" 111 + "--opt" 112 + "--with-nspr=${nspr.dev}/include:${nspr.out}/lib" 113 + "--system-sqlite" 114 + "--enable-legacy-db" 115 + "--target ${target}" 116 + "-Dhost_arch=${host}" 117 + "-Duse_system_zlib=1" 118 + "--enable-libpkix" 119 + "-j" 120 + "$NIX_BUILD_CORES" 121 + ] 122 + ++ lib.optional enableFIPS "--enable-fips" 123 + ++ lib.optional stdenv.hostPlatform.isDarwin "--clang" 124 + ++ lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 125 + "-DOS=${target_system}" 126 + "--disable-tests" 127 + ]; 106 128 in 107 129 '' 108 130 runHook preBuild 109 131 110 132 sed -i 's|nss_dist_dir="$dist_dir"|nss_dist_dir="'$out'"|;s|nss_dist_obj_dir="$obj_dir"|nss_dist_obj_dir="'$out'"|' build.sh 111 - ./build.sh -v --opt \ 112 - --with-nspr=${nspr.dev}/include:${nspr.out}/lib \ 113 - --system-sqlite \ 114 - --enable-legacy-db \ 115 - --target ${target} \ 116 - -Dhost_arch=${host} \ 117 - -Duse_system_zlib=1 \ 118 - --enable-libpkix \ 119 - -j $NIX_BUILD_CORES \ 120 - ${lib.optionalString enableFIPS "--enable-fips"} \ 121 - ${lib.optionalString stdenv.hostPlatform.isDarwin "--clang"} \ 122 - ${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "--disable-tests"} 133 + ./build.sh ${lib.concatStringsSep " " buildFlags} 123 134 124 135 runHook postBuild 125 136 ''; ··· 134 145 ] 135 146 ++ lib.optionals stdenv.hostPlatform.isILP32 [ 136 147 "-DNS_PTR_LE_32=1" # See RNG_RandomUpdate() in drdbg.c 148 + ] 149 + ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ 150 + "-D_XOPEN_SOURCE=700" 151 + "-D__BSD_VISIBLE" 152 + # uses compiler intrinsics gated behind runtime checks for cpu feature flags 153 + "-mavx2" 154 + "-maes" 155 + "-mpclmul" 137 156 ] 138 157 ); 139 158