Skip to content

Commit

Permalink
main/chromium: patch_style = git
Browse files Browse the repository at this point in the history
clean up some ancient shit in here too
  • Loading branch information
nekopsykose committed Oct 1, 2024
1 parent 9cf8ddb commit 8ea339f
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 612 deletions.
13 changes: 0 additions & 13 deletions main/chromium/patches/007-musl-missing-include.patch

This file was deleted.

6 changes: 3 additions & 3 deletions main/chromium/patches/009-gdbinit.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aports is a git tree so these git commands get the wrong directory
--- a/tools/gdb/gdbinit
+++ b/tools/gdb/gdbinit
@@ -50,17 +50,7 @@
@@ -49,17 +49,7 @@ def load_gdb_chrome(src_dir):

def set_src_dir(compile_dir):
global src_dir
Expand All @@ -18,5 +18,5 @@ aports is a git tree so these git commands get the wrong directory
- src_dir = src_dir.decode('utf-8').rstrip()
+ src_dir = os.path.abspath(os.getcwd())

load_libcxx_pretty_printers(src_dir)

# If there's no chrome directory in the repo root, we got the wrong git repo.
# The most common way to have this happen is to be in a git checkout of
11 changes: 0 additions & 11 deletions main/chromium/patches/010-generic-sensors-include.patch

This file was deleted.

3 changes: 2 additions & 1 deletion main/chromium/patches/016-musl-sandbox.patch
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ index 2b78a0c..b6fedb5 100644
#include "sandbox/linux/system_headers/x86_64_linux_syscalls.h"
--- a/sandbox/policy/linux/bpf_renderer_policy_linux.cc
+++ b/sandbox/policy/linux/bpf_renderer_policy_linux.cc
@@ -94,6 +94,9 @@
@@ -94,6 +94,10 @@
case __NR_pwrite64:
+ case __NR_pwritev2:
case __NR_sched_get_priority_max:
case __NR_sched_get_priority_min:
+ case __NR_sched_getparam:
Expand Down
11 changes: 0 additions & 11 deletions main/chromium/patches/019-musl-no-execinfo.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,3 @@ for discussion about this, see https://www.openwall.com/lists/musl/2021/07/16/1
#else
os << "StackTrace::OutputToStream not implemented.";

--- a/base/debug/stack_trace_unittest.cc
+++ b/base/debug/stack_trace_unittest.cc
@@ -33,7 +33,7 @@
typedef testing::Test StackTraceTest;
#endif

-#if !defined(__UCLIBC__) && !defined(_AIX)
+#if !defined(__UCLIBC__) && !defined(_AIX) && defined(__GLIBC__)
// StackTrace::OutputToStream() is not implemented under uclibc, nor AIX.
// See https://crbug.com/706728

232 changes: 134 additions & 98 deletions main/chromium/patches/020-musl-no-mallinfo.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,142 @@
musl does not implement mallinfo()/mallinfo2()
(or rather, malloc-ng, musl's allocator, doesn't)
--
--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
+++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

-#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
-
#include <atomic>
#include <cstddef>
#include <map>
@@ -25,6 +23,7 @@
#include "partition_alloc/partition_root.h"
#include "partition_alloc/partition_stats.h"
#include "partition_alloc/shim/allocator_dispatch.h"
+#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_internal.h"
#include "partition_alloc/shim/allocator_shim_internals.h"

@@ -352,7 +351,7 @@ void* PartitionReallocUnchecked(void* address, size_t size, void* context) {
#if PA_BUILDFLAG(IS_CAST_ANDROID)
extern "C" {
void __real_free(void*);
-} // extern "C"
+} // extern "C"
#endif // PA_BUILDFLAG(IS_CAST_ANDROID)

void PartitionFree(void* object, void* context) {
@@ -646,7 +645,7 @@ SHIM_ALWAYS_EXPORT int mallopt(int cmd, int value) __THROW {

#endif // !PA_BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(IS_ANDROID)

-#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
+#if 0
SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
partition_alloc::SimplePartitionStatsDumper allocator_dumper;
Allocator()->DumpStats("malloc", true, &allocator_dumper);
--- a/base/process/process_metrics_posix.cc
+++ b/base/process/process_metrics_posix.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

-#include "base/process/process_metrics.h"
-
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
@@ -12,6 +10,7 @@

#include "base/allocator/buildflags.h"
#include "base/logging.h"
+#include "base/process/process_metrics.h"
#include "build/blink_buildflags.h"
#include "build/build_config.h"

@@ -71,8 +70,9 @@ size_t GetMaxFds() {
max_fds = nofile.rlim_cur;
}

- if (max_fds > INT_MAX)
+ if (max_fds > INT_MAX) {
max_fds = INT_MAX;
+ }

return static_cast<size_t>(max_fds);
}
@@ -90,8 +90,9 @@ void IncreaseFdLimitTo(unsigned int max_descriptors) {
struct rlimit limits;
if (getrlimit(RLIMIT_NOFILE, &limits) == 0) {
rlim_t new_limit = max_descriptors;
- if (max_descriptors <= limits.rlim_cur)
+ if (max_descriptors <= limits.rlim_cur) {
return;
+ }
if (limits.rlim_max > 0 && limits.rlim_max < max_descriptors) {
new_limit = limits.rlim_max;
}
@@ -106,7 +107,8 @@ void IncreaseFdLimitTo(unsigned int max_descriptors) {

#endif // !BUILDFLAG(IS_FUCHSIA)

-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || \
+ BUILDFLAG(IS_ANDROID)
namespace {

size_t GetMallocUsageMallinfo() {
@@ -132,7 +134,8 @@ size_t ProcessMetrics::GetMallocUsage() {
malloc_statistics_t stats = {0};
malloc_zone_statistics(nullptr, &stats);
return stats.size_in_use;
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || \
+ BUILDFLAG(IS_ANDROID)
return GetMallocUsageMallinfo();
#elif BUILDFLAG(IS_FUCHSIA)
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index e37fc69c00..394f5dfdbb 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -185,7 +185,6 @@
@@ -7,8 +7,6 @@
#pragma allow_unsafe_buffers
#endif

-#include "base/trace_event/malloc_dump_provider.h"
-
#include <stddef.h>

#include <unordered_map>
@@ -19,6 +17,7 @@
#include "base/metrics/histogram_functions.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
+#include "base/trace_event/malloc_dump_provider.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/traced_value.h"
#include "build/build_config.h"
@@ -189,7 +188,6 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
#define MALLINFO2_FOUND_IN_LIBC
struct mallinfo2 info = mallinfo2();
#endif
-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
#if !defined(MALLINFO2_FOUND_IN_LIBC)
struct mallinfo info = mallinfo();
#endif
@@ -205,6 +204,7 @@
sys_alloc_dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, info.uordblks);
@@ -211,6 +209,7 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
MemoryAllocatorDump::kUnitsBytes,
total_allocated_size);
}
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
}
#endif

@@ -339,7 +340,7 @@
@@ -368,7 +367,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
&allocated_objects_count);
#elif BUILDFLAG(IS_FUCHSIA)
// TODO(fuchsia): Port, see https://crbug.com/706592.
Expand All @@ -28,97 +145,16 @@ musl does not implement mallinfo()/mallinfo2()
ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size,
&allocated_objects_size, &allocated_objects_count);
#endif
--- a/base/process/process_metrics_posix.cc
+++ b/base/process/process_metrics_posix.cc
@@ -105,7 +105,7 @@

#endif // !BUILDFLAG(IS_FUCHSIA)

-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
namespace {

size_t GetMallocUsageMallinfo() {
@@ -123,7 +123,7 @@
}

} // namespace
-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
+#endif // (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) ||
// BUILDFLAG(IS_ANDROID)

size_t ProcessMetrics::GetMallocUsage() {
@@ -131,9 +131,9 @@
malloc_statistics_t stats = {0};
malloc_zone_statistics(nullptr, &stats);
return stats.size_in_use;
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
+#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
return GetMallocUsageMallinfo();
-#elif BUILDFLAG(IS_FUCHSIA)
+#else
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
return 0;
#endif
--- ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc.orig
+++ ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
@@ -35,7 +35,7 @@

MemoryUsage GetMemoryUsage() {
MemoryUsage result;
-#ifdef __linux__
+#if defined(__linux__) && defined(__GLIBC__)
rusage res;
diff --git a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
index 9a4428ec45..07defd5ded 100644
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
@@ -43,7 +43,7 @@ MemoryUsage GetMemoryUsage() {
if (getrusage(RUSAGE_SELF, &res) == 0) {
result.max_rss_kb = res.ru_maxrss;
--- ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc
+++ ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc.orig
@@ -86,11 +86,11 @@
}

size_t Process::GetMallocUsage() {
-#if defined(HAVE_MALLINFO2)
+#if defined(HAVE_MALLINFO2) && defined(__GLIBC__)
struct mallinfo2 mi;
mi = ::mallinfo2();
return mi.uordblks;
-#elif defined(HAVE_MALLINFO)
+#elif defined(HAVE_MALLINFO) && defined(__GLIBC__)
struct mallinfo mi;
mi = ::mallinfo();
return mi.uordblks;

--- ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h.orig 2019-09-30 13:03:42.556880537 -0400
+++ ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h 2019-09-30 13:07:27.989821227 -0400
@@ -122,7 +122,9 @@
/* #undef HAVE_MALLCTL */

/* Define to 1 if you have the `mallinfo' function. */
+#if defined(__GLIBC__)
#define HAVE_MALLINFO 1
+#endif

/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
+++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
@@ -717,7 +717,7 @@

#endif // !PA_BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(IS_ANDROID)

-#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
+#if 0
SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
partition_alloc::SimplePartitionStatsDumper allocator_dumper;
Allocator()->DumpStats("malloc", true, &allocator_dumper);
--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc
+++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc
@@ -24,7 +24,7 @@
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)

// Platforms on which we override weak libc symbols.
-#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
+#if (PA_BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || PA_BUILDFLAG(IS_CHROMEOS)

PA_NOINLINE void FreeForTest(void* data) {
free(data);
result.mem_footprint_kb = res.ru_maxrss;
}
-#if defined(__NO_MALLINFO__)
+#if 1
result.total_allocated_bytes = -1;
result.in_use_allocated_bytes = -1;
#elif defined(__GLIBC__) && __GLIBC_MINOR__ >= 33
24 changes: 14 additions & 10 deletions main/chromium/patches/023-aarch64-no-memtag.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,43 @@ missing some required interface headers for it, and it's not clear how
to make the partalloc support code for it work.
note: also disables bti
--
diff --git a/base/allocator/partition_allocator/partition_alloc.gni b/base/allocator/partition_allocator/partition_alloc.gni
index e7f2f679b5..bafdbde410 100644
--- a/base/allocator/partition_allocator/partition_alloc.gni
+++ b/base/allocator/partition_allocator/partition_alloc.gni
@@ -29,8 +29,7 @@
assert(false, "Unknown CPU: $current_cpu")
}
@@ -30,8 +30,7 @@ if (is_nacl) {
# Increases the size of the empty slot span ring.
use_large_empty_slot_span_ring = is_mac

-has_memory_tagging =
- current_cpu == "arm64" && is_clang && !is_asan && (is_linux || is_android)
+has_memory_tagging = false

declare_args() {
# Causes all the allocations to be routed via allocator_shim.cc. Usually,
diff --git a/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h b/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h
index 600d4ed784..37defaa364 100644
--- a/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h
+++ b/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h
@@ -10,7 +10,7 @@
#include "partition_alloc/build_config.h"
#include "partition_alloc/partition_alloc_buildflags.h"
#include "partition_alloc/buildflags.h"

-#if PA_BUILDFLAG(IS_ANDROID) || PA_BUILDFLAG(IS_LINUX)
+#if PA_BUILDFLAG(IS_ANDROID) || (PA_BUILDFLAG(IS_LINUX) && defined(__GLIBC__))
#define HAS_HW_CAPS
#endif

diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc
index 295d0cebc2..2a9b409968 100644
--- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc
+++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc
@@ -8,8 +8,8 @@
@@ -8,7 +8,7 @@
#include "partition_alloc/buildflags.h"
#include "partition_alloc/page_allocator.h"
#include "partition_alloc/partition_alloc_buildflags.h"

-#if PA_BUILDFLAG(HAS_MEMORY_TAGGING) || \
- (defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1))
+#if 0 && (PA_BUILDFLAG(HAS_MEMORY_TAGGING) || \
+ (defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)))
+#if 0 && PA_BUILDFLAG(HAS_MEMORY_TAGGING) || \
(defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1))
struct __ifunc_arg_t;

#include "partition_alloc/aarch64_support.h"
Loading

0 comments on commit 8ea339f

Please sign in to comment.