From bae4239b72d0e5ced19b5ef899edc7baca505136 Mon Sep 17 00:00:00 2001
From: Adrian Pistol <vifino@tty.sh>
Date: Mon, 27 Mar 2023 15:52:10 +0200
Subject: [PATCH] mongodb: Stop overriding -march and -mtune on <5.0.

---
 pkgs/servers/nosql/mongodb/mongodb.nix | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pkgs/servers/nosql/mongodb/mongodb.nix b/pkgs/servers/nosql/mongodb/mongodb.nix
index 76c3ab7691a7..ea4ac699d4d0 100644
--- a/pkgs/servers/nosql/mongodb/mongodb.nix
+++ b/pkgs/servers/nosql/mongodb/mongodb.nix
@@ -116,6 +116,9 @@ in stdenv.mkDerivation rec {
     #include <string>'
     substituteInPlace src/mongo/db/exec/plan_stats.h --replace '#include <string>' '#include <optional>
     #include <string>'
+  '' + lib.optionalString (versionOlder version "5.0") ''
+    # remove -march overriding, we know better.
+    sed -i 's/env.Append.*-march=.*$/pass/' SConstruct
   '' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") ''
     substituteInPlace src/third_party/mozjs-${variants.mozjsVersion}/extract/js/src/jsmath.cpp --replace '${variants.mozjsReplace}' 0
   '' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") ''