kumquat-buildroot/package/lvm2/0002-mm-preallocate-memory-only-with-glibc.patch
Simon Rowe c5e9422197 package/lvm2: enable package with musl
LVM relies on the glibc-specific behaviour of assigning to the
standard streams (stdin etc). As a result the package is currently
disabled when using musl.

This commit backports two patches from upstream lvm2 (not yet in a
release) that fix some build issues with musl, and two additional
patches taken from the Gentoo distribution to address more issues.

With those 4 patches combined, lvm2 builds fine with musl and can
therefore be re-enabled in musl configurations.

Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-03-26 22:32:59 +02:00

35 lines
1.2 KiB
Diff

From b668022f9b8aecf52109c9e0b7e5847054231361 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 19 Aug 2022 16:15:17 +0200
Subject: [PATCH] mm: preallocate memory only with glibc
Use mallinfo() only with glibc.
Backported from: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8370d117d7ef8a472c95315a3cd085696c90b3be
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
---
lib/mm/memlock.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 3d1a3927c..efcc6d91f 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -160,7 +160,12 @@ static void _touch_memory(void *mem, size_t size)
static void _allocate_memory(void)
{
-#ifndef VALGRIND_POOL
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
+ /* Memory allocation is currently only tested with glibc
+ * for different C libraries, some other mechanisms might be needed
+ * meanwhile let users use lvm2 code without memory preallocation.
+ * Compilation for VALGRIND tracing also goes without preallocation.
+ */
void *stack_mem;
struct rlimit limit;
int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;
--
2.22.3