summaryrefslogtreecommitdiffstats
path: root/chromium/patches/020-musl-no-mallinfo.patch
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/patches/020-musl-no-mallinfo.patch')
-rw-r--r--chromium/patches/020-musl-no-mallinfo.patch93
1 files changed, 93 insertions, 0 deletions
diff --git a/chromium/patches/020-musl-no-mallinfo.patch b/chromium/patches/020-musl-no-mallinfo.patch
new file mode 100644
index 0000000..dc18ca5
--- /dev/null
+++ b/chromium/patches/020-musl-no-mallinfo.patch
@@ -0,0 +1,93 @@
1musl does not implement mallinfo()/mallinfo2()
2(or rather, malloc-ng, musl's allocator, doesn't)
3
4for some reason only outside of x86_64 HAVE_MALLINFO gets weirdly set by something
5--
6--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
7+++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
8@@ -646,7 +645,7 @@ SHIM_ALWAYS_EXPORT int mallopt(int cmd, int value) __THROW {
9
10 #endif // !PA_BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(IS_ANDROID)
11
12-#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
13+#if 0
14 SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
15 partition_alloc::SimplePartitionStatsDumper allocator_dumper;
16 Allocator()->DumpStats("malloc", true, &allocator_dumper);
17--- a/base/process/process_metrics_posix.cc
18+++ b/base/process/process_metrics_posix.cc
19@@ -106,7 +107,8 @@ void IncreaseFdLimitTo(unsigned int max_descriptors) {
20
21 #endif // !BUILDFLAG(IS_FUCHSIA)
22
23-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
24+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || \
25+ BUILDFLAG(IS_ANDROID)
26 namespace {
27
28 size_t GetMallocUsageMallinfo() {
29@@ -132,7 +134,8 @@ size_t ProcessMetrics::GetMallocUsage() {
30 malloc_statistics_t stats = {0};
31 malloc_zone_statistics(nullptr, &stats);
32 return stats.size_in_use;
33-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
34+#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || \
35+ BUILDFLAG(IS_ANDROID)
36 return GetMallocUsageMallinfo();
37 #elif BUILDFLAG(IS_FUCHSIA)
38 // TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
39diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
40index e37fc69c00..394f5dfdbb 100644
41--- a/base/trace_event/malloc_dump_provider.cc
42+++ b/base/trace_event/malloc_dump_provider.cc
43@@ -189,7 +188,6 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
44 #define MALLINFO2_FOUND_IN_LIBC
45 struct mallinfo2 info = mallinfo2();
46 #endif
47-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
48 #if !defined(MALLINFO2_FOUND_IN_LIBC)
49 struct mallinfo info = mallinfo();
50 #endif
51@@ -211,6 +209,7 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
52 MemoryAllocatorDump::kUnitsBytes,
53 total_allocated_size);
54 }
55+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
56 }
57 #endif
58
59@@ -368,7 +367,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
60 &allocated_objects_count);
61 #elif BUILDFLAG(IS_FUCHSIA)
62 // TODO(fuchsia): Port, see https://crbug.com/706592.
63-#else
64+#elif defined(__GLIBC__)
65 ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size,
66 &allocated_objects_size, &allocated_objects_count);
67 #endif
68--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
69+++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
70@@ -133,7 +133,6 @@
71 /* #undef HAVE_MALLCTL */
72
73 /* Define to 1 if you have the `mallinfo' function. */
74-#define HAVE_MALLINFO 1
75
76 /* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
77 /* so we need to check glibc version for the new API to be safe */
78--- a/third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Support/Unix/Process.inc
79+++ b/third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Support/Unix/Process.inc
80@@ -83,11 +83,11 @@ Expected<unsigned> Process::getPageSize() {
81 }
82
83 size_t Process::GetMallocUsage() {
84-#if defined(HAVE_MALLINFO2)
85+#if 0
86 struct mallinfo2 mi;
87 mi = ::mallinfo2();
88 return mi.uordblks;
89-#elif defined(HAVE_MALLINFO)
90+#elif 0
91 struct mallinfo mi;
92 mi = ::mallinfo();
93 return mi.uordblks;