[compiler-rt] don't use mallopt on musl (PR #101055)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 11:22:23 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Daniel Martinez (Calandracas606)

<details>
<summary>Changes</summary>

Fixes a build failure on 19.1.0-rc1 when building on linux with musl as the libc

musl does not provide mallopt, whereas glibc does

---
Full diff: https://github.com/llvm/llvm-project/pull/101055.diff


1 Files Affected:

- (modified) compiler-rt/lib/nsan/nsan_interceptors.cpp (+2-2) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/101055


More information about the llvm-commits mailing list