summaryrefslogtreecommitdiff
path: root/sys-devel/mold/files/mold-2.35.1-system-mimalloc.patch
blob: c0abe4b5fd681c3f2cbf18de8f4a43c15842c6ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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 <github@sicherha.de>
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 <github@sicherha.de>
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