[compiler-rt] don't use mallopt on musl (PR #101055)
Daniel Martinez via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 11:21:51 PDT 2024
https://github.com/Calandracas606 created https://github.com/llvm/llvm-project/pull/101055
Fixes a build failure on 19.1.0-rc1 when building with musl as the libc
musl does not provide mallopt, whereas glibc does
>From ab03fed23ad6cff13b067e6f401c1144690909bf Mon Sep 17 00:00:00 2001
From: Daniel Martinez <danielmartinez at cock.li>
Date: Mon, 29 Jul 2024 14:15:51 -0400
Subject: [PATCH] don't use mallopt on musl
---
compiler-rt/lib/nsan/nsan_interceptors.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/nsan/nsan_interceptors.cpp b/compiler-rt/lib/nsan/nsan_interceptors.cpp
index 544b44f53cc42..baa8185994113 100644
--- a/compiler-rt/lib/nsan/nsan_interceptors.cpp
+++ b/compiler-rt/lib/nsan/nsan_interceptors.cpp
@@ -21,7 +21,7 @@
#include <wchar.h>
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX && defined(__GLIBC__)
extern "C" int mallopt(int param, int value);
#endif
@@ -210,7 +210,7 @@ void __nsan::InitializeInterceptors() {
CHECK(!initialized);
// Instruct libc malloc to consume less memory.
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX && defined(__GLIBC__)
mallopt(1, 0); // M_MXFAST
mallopt(-3, 32 * 1024); // M_MMAP_THRESHOLD
#endif
More information about the llvm-commits
mailing list