package/mongodb: fix build with glibc >= 2.34

Fix the following build failure with glibc >= 2.34:

In file included from /home/giuliobenetti/autobuild/run/instance-0/output-1/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/signal.h:328,
                 from /home/giuliobenetti/autobuild/run/instance-0/output-1/host/arm-buildroot-linux-gnueabihf/include/c++/11.2.0/csignal:42,
                 from src/mongo/stdx/thread.h:33,
                 from src/mongo/db/client.h:46,
                 from src/mongo/db/operation_context.h:36,
                 from src/mongo/db/pipeline/variables.h:32,
                 from src/mongo/db/pipeline/dependencies.h:37,
                 from src/mongo/db/matcher/expression.h:38,
                 from src/mongo/db/matcher/expression_parser.h:34,
                 from src/mongo/db/pipeline/document_source_list_sessions.cpp:34:
src/mongo/stdx/thread.h:107:56: error: call to non-'constexpr' function 'long int sysconf(int)'
  107 |         std::max(kMongoMinSignalStackSize, std::size_t{MINSIGSTKSZ});
      |

Fixes:
 - http://autobuild.buildroot.org/results/6be8efb96547f8ec6e9b776abae8c1b51501e9ed

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Fabrice Fontaine 2021-11-13 09:35:57 +01:00 committed by Yann E. MORIN
parent bff1c6ada5
commit 82f5b76577

View file

@ -0,0 +1,49 @@
From ef08d0dbc99db8c4620512e92bfb3154282eb5d3 Mon Sep 17 00:00:00 2001
From: Andrew Morrow <acm@mongodb.com>
Date: Wed, 15 Sep 2021 15:23:42 -0400
Subject: [PATCH] SERVER-59459 With glibc-2.34, MINSIGSTKSZ is no longer a
constant
[Retrieved (and backported) from:
https://github.com/mongodb/mongo/commit/ef08d0dbc99db8c4620512e92bfb3154282eb5d3]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
src/mongo/stdx/thread.h | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/mongo/stdx/thread.h b/src/mongo/stdx/thread.h
index 7b15bb561bd9..6f1e16cdeb36 100644
--- a/src/mongo/stdx/thread.h
+++ b/src/mongo/stdx/thread.h
@@ -76,11 +76,19 @@ class SigAltStackController {
}
private:
+ static size_t _getStackSize() {
+ // It would be nice for this to be a constexpr, but
+ // MINSIGSTKSZ became a macro that invoked `sysconf` in glibc
+ // 2.34.
+ static const std::size_t kMinSigStkSz = MINSIGSTKSZ;
+ return std::max(kMongoMinSignalStackSize, kMinSigStkSz);
+ }
+
void _install() const {
stack_t ss;
ss.ss_sp = _stackStorage.get();
ss.ss_flags = 0;
- ss.ss_size = kStackSize;
+ ss.ss_size = _getStackSize();
if (sigaltstack(&ss, nullptr)) {
abort();
}
@@ -107,9 +115,7 @@ class SigAltStackController {
// ( https://jira.mongodb.org/secure/attachment/233569/233569_stacktrace-writeup.txt )
static constexpr std::size_t kMongoMinSignalStackSize = std::size_t{64} << 10;
- static constexpr std::size_t kStackSize =
- std::max(kMongoMinSignalStackSize, std::size_t{MINSIGSTKSZ});
- std::unique_ptr<std::byte[]> _stackStorage = std::make_unique<std::byte[]>(kStackSize);
+ std::unique_ptr<std::byte[]> _stackStorage = std::make_unique<std::byte[]>(_getStackSize());
#else // !MONGO_HAS_SIGALTSTACK
auto makeInstallGuard() const {