Add bmcweb_multithread as a DISTRO_FEATURE

There has been a crash on bmcweb multithread that requires changes
in the absl library due to absl::Mutex::Lock crashing in specific
contexts in coroutines.

The ideal fix would be to run in absl release mode, however this is
not possible as we run into the following upstream issue.
https://github.com/abseil/abseil-cpp/issues/1624

This is a temporary workaround until upstream issue is resolved

When using either
TARGET_CFLAGS:append:gbmc = " -DNDEBUG"
EXTRA_OECMAKE:append:gbmc = " -DCMAKE_BUILD_TYPE=RelWithDebInfo"

libprotobuf cannot compile. Same error as upstream issue listed above

This is an opt-in feature so currently there is no functional change
for this commit.

fusion2: N/A, there is no firmware change being made

Tested:
Run bmcweb stress test for 16 hours and no crash.
https://fusion2.corp.google.com/7785efa0-d440-4d70-8227-3b0c5736071b
(Test failed due to machine reservation timeout

Google-Bug-Id: 351900567
Change-Id: Id5301d79849683586d91bfa1e334be8a8808babc
Signed-off-by: Edward Lee <edwarddl@google.com>
(cherry picked from commit 5cf720504d416ce7a2ec89b83ca5a3ed7e55f503)
diff --git a/conf/layer.conf b/conf/layer.conf
index 8729b30..e7aabea 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -26,3 +26,7 @@
 # You can turn off it by removing "gbmcfork" from OVERRIDES on your machine,
 # or by removing "gbmcfork" from your DISTRO_FEATURES.
 OVERRIDES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'gbmcfork', ':gbmcfork', '', d)}"
+
+# Adding multithread as a feature to opt into. Cannot just make it a
+# PACKAGECONFIG change as there are patches that need to go with it as well
+OVERRIDES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'bmcweb_multithread', ':bmcweb_multithread', '', d)}"
diff --git a/recipes-devtools/abseil-cpp/abseil-cpp/0001-Set-NDEBUG-to-true-to-avoid-DebugOnlyChecks.patch b/recipes-devtools/abseil-cpp/abseil-cpp/0001-Set-NDEBUG-to-true-to-avoid-DebugOnlyChecks.patch
new file mode 100644
index 0000000..52841bd
--- /dev/null
+++ b/recipes-devtools/abseil-cpp/abseil-cpp/0001-Set-NDEBUG-to-true-to-avoid-DebugOnlyChecks.patch
@@ -0,0 +1,32 @@
+From 6345ace11db2cbe7c1ed9b2acd194a0f8f2ef9b2 Mon Sep 17 00:00:00 2001
+From: Edward Lee <edwarddl@google.com>
+Date: Mon, 22 Jul 2024 20:09:09 +0000
+Subject: [PATCH] Set NDEBUG to true to avoid DebugOnlyChecks
+
+The problem is that with kDebugMode=true, we perform stack traces in every
+mutex lock. This causes issues as coroutines that are yielding execution to
+another job do not have correctly setup stack frames.
+
+More information in cl/653791685
+
+Signed-off-by: Edward Lee <edwarddl@google.com>
+---
+ absl/synchronization/mutex.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc
+index cb751927..c6893b51 100644
+--- a/absl/synchronization/mutex.cc
++++ b/absl/synchronization/mutex.cc
+@@ -722,7 +722,7 @@ static const Mutex::MuHow kExclusive = &kExclusiveS;  // exclusive lock
+ #ifdef NDEBUG
+ static constexpr bool kDebugMode = false;
+ #else
+-static constexpr bool kDebugMode = true;
++static constexpr bool kDebugMode = false;
+ #endif
+ 
+ #ifdef ABSL_INTERNAL_HAVE_TSAN_INTERFACE
+-- 
+2.45.2.1089.g2a221341d9-goog
+
diff --git a/recipes-devtools/abseil-cpp/abseil-cpp_%.bbappend b/recipes-devtools/abseil-cpp/abseil-cpp_%.bbappend
index 37f0aca..46db64f 100644
--- a/recipes-devtools/abseil-cpp/abseil-cpp_%.bbappend
+++ b/recipes-devtools/abseil-cpp/abseil-cpp_%.bbappend
@@ -5,3 +5,7 @@
 EXTRA_OECMAKE:append:gbmc = " -DCMAKE_CXX_STANDARD=17"
 
 SRC_URI:remove:gbmc = " file://0004-Avoid-using-both-Win32Waiter-and-PthreadWaiter-on-Mi.patch"
+
+FILESEXTRAPATHS:prepend:gbmc:bmcweb_multithread := "${THISDIR}/${PN}:"
+
+SRC_URI:append:gbmc:bmcweb_multithread = " file://0001-Set-NDEBUG-to-true-to-avoid-DebugOnlyChecks.patch"
diff --git a/recipes-phosphor/interfaces/bmcweb_%.bbappend b/recipes-phosphor/interfaces/bmcweb_%.bbappend
index 18c61d6..93f1325 100644
--- a/recipes-phosphor/interfaces/bmcweb_%.bbappend
+++ b/recipes-phosphor/interfaces/bmcweb_%.bbappend
@@ -18,6 +18,10 @@
     ${@bb.utils.contains('MACHINE_FEATURES', 'gbmc-baremetal', '-Dgoogle-baremetal=enabled', '-Dgoogle-baremetal=disabled', d)} \
 "
 
+EXTRA_OEMESON:append:gbmc:bmcweb_multithread = " \
+    -Dmulti-thread-get=enabled \
+"
+
 SRC_URI:append:gbmc = " \
   file://service-override.conf \
   file://delay-reset@.service \