https://github.com/rui314/mold/commit/9c9145eb6e5381b69f47bdfb11eeffb7b9febb8b https://github.com/rui314/mold/commit/ac9568f17b9054e92fed95a862ec83701336cd37 From 9c9145eb6e5381b69f47bdfb11eeffb7b9febb8b Mon Sep 17 00:00:00 2001 From: Christoph Erhardt Date: Thu, 19 Dec 2024 21:55:41 +0100 Subject: [PATCH] Add missing `#include "common.h"` This allows the compiler to make sure that the implementation of `set_mimalloc_options()` matches its declaration. More importantly, it indirectly pulls in `config.h`, where the macros `MOLD_USE_SYSTEM_MIMALLOC` and `MOLD_USE_MIMALLOC` are conditionally defined. Without these, the build configuration is ignored. --- lib/mimalloc.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mimalloc.cc b/lib/mimalloc.cc index 637d5e8ce7..823b91b8e9 100644 --- a/lib/mimalloc.cc +++ b/lib/mimalloc.cc @@ -1,3 +1,5 @@ +#include "common.h" + // Including mimalloc-new-delete.h overrides new/delete operators. // We need it only when we are using mimalloc as a dynamic library. #if MOLD_USE_SYSTEM_MIMALLOC From ac9568f17b9054e92fed95a862ec83701336cd37 Mon Sep 17 00:00:00 2001 From: Christoph Erhardt Date: Thu, 19 Dec 2024 23:40:12 +0100 Subject: [PATCH] Disable mimalloc when a sanitizer is used Combining mimalloc and AddressSanitizer triggers a segmentation fault in many tests. Combining mimalloc and ThreadSanitizer leads to duplicate symbols for the `new` and `delete` operators, causing the build to fail. Example message from a failed GitHub Actions build: ``` mold: error: duplicate symbol: third-party/mimalloc/libmimalloc-debug.a(alloc.c.o): /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.tsan_cxx-x86_64.a(tsan_new_delete.cpp.o): operator delete(void*, std::align_val_t) ``` --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8643961d9..c451ea952a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,7 +180,7 @@ endif() # be stable on 32-bit targets. cmake_dependent_option( MOLD_USE_MIMALLOC "Use mimalloc" ON - "CMAKE_SIZEOF_VOID_P EQUAL 8; NOT APPLE; NOT ANDROID; NOT OPENBSD" OFF) + "CMAKE_SIZEOF_VOID_P EQUAL 8; NOT APPLE; NOT ANDROID; NOT OPENBSD; NOT MOLD_USE_ASAN; NOT MOLD_USE_TSAN" OFF) cmake_dependent_option( MOLD_USE_SYSTEM_MIMALLOC "Use system or vendored mimalloc" OFF