Skip to content

Commit

Permalink
mongodb: add avxSupport override
Browse files Browse the repository at this point in the history
Starting with mongodb 5, the default build produces binaries that throw a trap
invalid opcode on machines without the avx cpu flag. While most modern cpus
support this flag, some recent lower end Intel CPUs (N5105) do not. Allow
mongodb to build without such flags.
  • Loading branch information
qubitnano committed Apr 20, 2024
1 parent dcc83cd commit f2447a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkgs/servers/nosql/mongodb/5.0.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools, avxSupport ? true }:

let
buildMongoDB = callPackage ./mongodb.nix {
Expand All @@ -18,6 +18,7 @@ let
};
in
buildMongoDB {
inherit avxSupport;
version = variants.version;
sha256 = variants.sha256;
patches = [
Expand Down
3 changes: 2 additions & 1 deletion pkgs/servers/nosql/mongodb/6.0.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{ stdenv, callPackage, lib, fetchpatch, sasl, boost, Security, CoreFoundation, cctools }:
{ stdenv, callPackage, lib, fetchpatch, sasl, boost, Security, CoreFoundation, cctools, avxSupport ? true }:

let
buildMongoDB = callPackage ./mongodb.nix {
inherit sasl boost Security CoreFoundation cctools stdenv;
};
in
buildMongoDB {
inherit avxSupport;
version = "6.0.13";
sha256 = "sha256-BD3XrTdv4sCa3h37o1A2s3/R0R8zHiR59a4pY0RxLGU=";
patches = [
Expand Down
4 changes: 4 additions & 0 deletions pkgs/servers/nosql/mongodb/mongodb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ with lib;

{ version, sha256, patches ? []
, license ? lib.licenses.sspl
, avxSupport ? true
}:

let
Expand Down Expand Up @@ -112,6 +113,9 @@ in stdenv.mkDerivation rec {
# don't fail by default on i686
substituteInPlace src/mongo/db/storage/storage_options.h \
--replace 'engine("wiredTiger")' 'engine("mmapv1")'
'' + lib.optionalString (!avxSupport) ''
substituteInPlace SConstruct \
--replace-fail "default=['+sandybridge']," 'default=[],'
'';

env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
Expand Down

0 comments on commit f2447a5

Please sign in to comment.