Merge pull request #285792 from ElvishJerricco/mongodb-cross

mongodb: Cleanups and fix cross compilation.
This commit is contained in:
Will Fancher 2024-02-10 21:30:08 -05:00 committed by GitHub
commit c898ce2283
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
{ lib { lib
, stdenv , stdenv
, fetchurl , fetchurl
, scons_3_1_2 , buildPackages
, boost , boost
, gperftools , gperftools
, pcre-cpp , pcre-cpp
@ -32,38 +32,19 @@ with lib;
}: }:
let let
variants = scons = buildPackages.scons;
if versionAtLeast version "6.0" python = scons.python.withPackages (ps: with ps; [
then rec { pyyaml
python = scons.python.withPackages (ps: with ps; [ cheetah3
pyyaml psutil
cheetah3 setuptools
psutil ] ++ lib.optionals (versionAtLeast version "6.0") [
setuptools packaging
packaging pymongo
pymongo ]);
]);
scons = scons_3_1_2; mozjsVersion = "60";
mozjsReplace = "defined(HAVE___SINCOS)";
mozjsVersion = "60";
mozjsReplace = "defined(HAVE___SINCOS)";
}
else rec {
python = scons.python.withPackages (ps: with ps; [
pyyaml
cheetah3
psutil
setuptools
]);
scons = scons_3_1_2;
mozjsVersion = "60";
mozjsReplace = "defined(HAVE___SINCOS)";
};
system-libraries = [ system-libraries = [
"boost" "boost"
@ -87,8 +68,10 @@ in stdenv.mkDerivation rec {
inherit sha256; inherit sha256;
}; };
nativeBuildInputs = [ variants.scons ] nativeBuildInputs = [
++ lib.optionals (versionAtLeast version "4.4") [ xz ]; scons
python
] ++ lib.optional stdenv.isLinux net-snmp;
buildInputs = [ buildInputs = [
boost boost
@ -99,13 +82,12 @@ in stdenv.mkDerivation rec {
openssl openssl
openldap openldap
pcre-cpp pcre-cpp
variants.python
sasl sasl
snappy snappy
zlib zlib
] ++ lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ] ] ++ lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ]
++ lib.optionals stdenv.isLinux [ net-snmp ]; ++ lib.optional stdenv.isLinux net-snmp
++ lib.optionals (versionAtLeast version "4.4") [ xz ];
# MongoDB keeps track of its build parameters, which tricks nix into # MongoDB keeps track of its build parameters, which tricks nix into
# keeping dependencies to build inputs in the final output. # keeping dependencies to build inputs in the final output.
@ -127,7 +109,7 @@ in stdenv.mkDerivation rec {
# remove -march overriding, we know better. # remove -march overriding, we know better.
sed -i 's/env.Append.*-march=.*$/pass/' SConstruct sed -i 's/env.Append.*-march=.*$/pass/' SConstruct
'' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") '' '' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") ''
substituteInPlace src/third_party/mozjs-${variants.mozjsVersion}/extract/js/src/jsmath.cpp --replace '${variants.mozjsReplace}' 0 substituteInPlace src/third_party/mozjs-${mozjsVersion}/extract/js/src/jsmath.cpp --replace '${mozjsReplace}' 0
'' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") '' '' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") ''
substituteInPlace src/third_party/s2/s1angle.cc --replace drem remainder substituteInPlace src/third_party/s2/s1angle.cc --replace drem remainder
substituteInPlace src/third_party/s2/s1interval.cc --replace drem remainder substituteInPlace src/third_party/s2/s1interval.cc --replace drem remainder
@ -162,6 +144,7 @@ in stdenv.mkDerivation rec {
preBuild = '' preBuild = ''
sconsFlags+=" CC=$CC" sconsFlags+=" CC=$CC"
sconsFlags+=" CXX=$CXX" sconsFlags+=" CXX=$CXX"
sconsFlags+=" AR=$AR"
'' + optionalString stdenv.isAarch64 '' '' + optionalString stdenv.isAarch64 ''
sconsFlags+=" CCFLAGS='-march=armv8-a+crc'" sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
''; '';