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

Daniel Martinez via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 12:39:45 PDT 2024


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

>From c3a9242d60fa110dc26f842a597db61e238dcc85 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] Remove mallopt to fix build on musl

Other sanitizers don't use mallopt, musl doesn't provide mallopt,
and tcmalloc ignores mallopt. Its easiest jut to remove it
---
 compiler-rt/lib/nsan/nsan_interceptors.cpp | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan_interceptors.cpp b/compiler-rt/lib/nsan/nsan_interceptors.cpp
index 544b44f53cc42..852524bd37332 100644
--- a/compiler-rt/lib/nsan/nsan_interceptors.cpp
+++ b/compiler-rt/lib/nsan/nsan_interceptors.cpp
@@ -21,10 +21,6 @@
 
 #include <wchar.h>
 
-#if SANITIZER_LINUX
-extern "C" int mallopt(int param, int value);
-#endif
-
 using namespace __sanitizer;
 using __nsan::nsan_init_is_running;
 using __nsan::nsan_initialized;
@@ -209,12 +205,6 @@ void __nsan::InitializeInterceptors() {
   static bool initialized = false;
   CHECK(!initialized);
 
-  // Instruct libc malloc to consume less memory.
-#if SANITIZER_LINUX
-  mallopt(1, 0);          // M_MXFAST
-  mallopt(-3, 32 * 1024); // M_MMAP_THRESHOLD
-#endif
-
   InitializeMallocInterceptors();
 
   INTERCEPT_FUNCTION(memset);



More information about the llvm-commits mailing list