Skip to content

Commit 3265641

Browse files
committed
chromium: Fix build with musl
chromium version upgrades means the musl patches also needs to be forward ported or removed if not needed. Tested on rpi4-64 Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 parent dfcc7c5 commit 3265641

13 files changed

+188
-349
lines changed

meta-chromium/recipes-browser/chromium/chromium-gn.inc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,18 @@ SRC_URI:append:libc-musl = "\
3636
file://musl/0007-__libc_malloc-is-internal-to-glibc.patch \
3737
file://musl/0008-gnu_libc_version-API-is-glibc-specific.patch \
3838
file://musl/0009-provide-res_ninit-and-nclose-APIs-on-non-glibc-linux.patch \
39-
file://musl/0010-__off64_t-is-internal-private-define-from-glibc.patch \
4039
file://musl/0011-crashpad-Fix-build-with-musl.patch \
4140
file://musl/0012-debug-Fix-build-with-musl.patch \
4241
file://musl/0013-socket-initialize-msghdr-in-a-compatible-manner.patch \
43-
file://musl/0014-no-__environ-in-musl.patch \
4442
file://musl/0015-mallopt-is-glibc-specific-API.patch \
45-
file://musl/0016-tcmalloc-undef-mmap64.patch \
46-
file://musl/0017-tcmalloc-no-__sbrk.patch \
4743
file://musl/0018--Use-monotonic-clock-for-pthread_cond_timedwait-with-.patch \
4844
file://musl/0019-adjust-thread-stack-sizes.patch \
4945
file://musl/0020-Fix-tab-crashes-on-musl.patch \
5046
file://musl/0021-pthread_getname_np.patch \
5147
file://musl/0022-sys-stat.patch \
5248
file://musl/scoped-file.patch \
5349
file://musl/fix-narrowing-cast.patch \
50+
file://musl/credentials-header.patch \
5451
"
5552

5653
ANY_OF_DISTRO_FEATURES = "opengl vulkan"

meta-chromium/recipes-browser/chromium/files/musl/0001-mallinfo-implementation-is-glibc-specific.patch

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,85 +6,85 @@ Subject: [PATCH] mallinfo implementation is glibc specific
66
Upstream-Status: Pending
77
Signed-off-by: Khem Raj <raj.khem@gmail.com>
88
---
9-
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
10-
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
11-
@@ -35,7 +35,7 @@ bool MemoryUsage::IsSupported() {
12-
13-
MemoryUsage GetMemoryUsage() {
14-
MemoryUsage result;
15-
-#ifdef __linux__
16-
+#if defined(__linux__) && defined(__GLIBC__)
17-
rusage res;
18-
if (getrusage(RUSAGE_SELF, &res) == 0) {
19-
result.max_rss_kb = res.ru_maxrss;
9+
--- a/base/trace_event/malloc_dump_provider.cc
10+
+++ b/base/trace_event/malloc_dump_provider.cc
11+
@@ -220,7 +220,7 @@ bool MallocDumpProvider::OnMemoryDump(co
12+
&allocated_objects_count);
13+
#elif BUILDFLAG(IS_FUCHSIA)
14+
// TODO(fuchsia): Port, see https://crbug.com/706592.
15+
-#else
16+
+#elif defined(__GLIBC__)
17+
#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
18+
#if __GLIBC_PREREQ(2, 33)
19+
#define MALLINFO2_FOUND_IN_LIBC
2020
--- a/base/process/process_metrics_posix.cc
2121
+++ b/base/process/process_metrics_posix.cc
2222
@@ -105,7 +105,7 @@ void IncreaseFdLimitTo(unsigned int max_
2323

24-
#endif // !defined(OS_FUCHSIA)
24+
#endif // !BUILDFLAG(IS_FUCHSIA)
2525

26-
-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
27-
+#if (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
26+
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
27+
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
2828
namespace {
2929

3030
size_t GetMallocUsageMallinfo() {
31-
@@ -127,16 +127,16 @@ size_t GetMallocUsageMallinfo() {
31+
@@ -123,7 +123,7 @@ size_t GetMallocUsageMallinfo() {
3232
}
3333

3434
} // namespace
35-
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
36-
+#endif // (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
35+
-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
36+
+#endif // (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) ||
37+
// BUILDFLAG(IS_ANDROID)
3738

3839
size_t ProcessMetrics::GetMallocUsage() {
39-
#if defined(OS_APPLE)
40+
@@ -131,9 +131,9 @@ size_t ProcessMetrics::GetMallocUsage()
4041
malloc_statistics_t stats = {0};
4142
malloc_zone_statistics(nullptr, &stats);
4243
return stats.size_in_use;
43-
-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
44-
+#elif (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
44+
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
45+
+#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
4546
return GetMallocUsageMallinfo();
46-
-#elif defined(OS_FUCHSIA)
47+
-#elif BUILDFLAG(IS_FUCHSIA)
4748
+#else
4849
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
4950
return 0;
5051
#endif
51-
--- a/base/trace_event/malloc_dump_provider.cc
52-
+++ b/base/trace_event/malloc_dump_provider.cc
53-
@@ -219,7 +219,6 @@ bool MallocDumpProvider::OnMemoryDump(co
54-
#define MALLINFO2_FOUND_IN_LIBC
55-
struct mallinfo2 info = mallinfo2();
56-
#endif
57-
-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
58-
#if !defined(MALLINFO2_FOUND_IN_LIBC)
59-
struct mallinfo info = mallinfo();
60-
#endif
61-
@@ -232,6 +231,7 @@ bool MallocDumpProvider::OnMemoryDump(co
62-
63-
// Total allocated space is given by |uordblks|.
64-
allocated_objects_size = info.uordblks;
65-
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
66-
#endif
67-
68-
MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc");
69-
--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
70-
+++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
71-
@@ -133,7 +133,7 @@
72-
/* #undef HAVE_MALLCTL */
52+
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
53+
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
54+
@@ -35,7 +35,7 @@ bool MemoryUsage::IsSupported() {
7355

74-
/* Define to 1 if you have the `mallinfo' function. */
75-
-#define HAVE_MALLINFO 1
76-
+/* #undef HAVE_MALLINFO */
56+
MemoryUsage GetMemoryUsage() {
57+
MemoryUsage result;
58+
-#ifdef __linux__
59+
+#if defined(__linux__) && defined(__GLIBC__)
60+
rusage res;
61+
if (getrusage(RUSAGE_SELF, &res) == 0) {
62+
result.max_rss_kb = res.ru_maxrss;
63+
--- a/third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc
64+
+++ b/third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc
65+
@@ -86,11 +86,11 @@ unsigned Process::getPageSize() {
66+
}
7767

78-
/* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
79-
/* so we need to check glibc version for the new API to be safe */
68+
size_t Process::GetMallocUsage() {
69+
-#if defined(HAVE_MALLINFO2)
70+
+#if defined(HAVE_MALLINFO2) && defined(__GLIBC__)
71+
struct mallinfo2 mi;
72+
mi = ::mallinfo2();
73+
return mi.uordblks;
74+
-#elif defined(HAVE_MALLINFO)
75+
+#elif defined(HAVE_MALLINFO) && defined(__GLIBC__)
76+
struct mallinfo mi;
77+
mi = ::mallinfo();
78+
return mi.uordblks;
8079
--- a/third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
8180
+++ b/third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
82-
@@ -128,7 +128,7 @@
81+
@@ -128,7 +128,9 @@
8382
/* #undef HAVE_MALLCTL */
8483

8584
/* Define to 1 if you have the `mallinfo' function. */
86-
-#define HAVE_MALLINFO 1
87-
+/* #undef HAVE_MALLINFO */
85+
+#if defined(__GLIBC__)
86+
#define HAVE_MALLINFO 1
87+
+#endif
8888

8989
/* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
9090
/* so we need to check glibc version for the new API to be safe */

meta-chromium/recipes-browser/chromium/files/musl/0004-blink-Fix-build-with-musl.patch

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1212
third_party/blink/renderer/platform/wtf/stack_util.cc | 4 ++--
1313
1 file changed, 2 insertions(+), 2 deletions(-)
1414

15-
diff --git a/third_party/blink/renderer/platform/wtf/stack_util.cc b/third_party/blink/renderer/platform/wtf/stack_util.cc
16-
index 71b901f404..f33aba04bc 100644
1715
--- a/third_party/blink/renderer/platform/wtf/stack_util.cc
1816
+++ b/third_party/blink/renderer/platform/wtf/stack_util.cc
1917
@@ -29,7 +29,7 @@ size_t GetUnderestimatedStackSize() {
2018
// FIXME: On Mac OSX and Linux, this method cannot estimate stack size
2119
// correctly for the main thread.
2220

23-
-#elif defined(__GLIBC__) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \
24-
+#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \
25-
defined(OS_FUCHSIA)
21+
-#elif defined(__GLIBC__) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
22+
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
23+
BUILDFLAG(IS_FUCHSIA)
2624
// pthread_getattr_np() can fail if the thread is not invoked by
2725
// pthread_create() (e.g., the main thread of blink_unittests).
28-
@@ -97,7 +97,7 @@ return Threading::ThreadStackSize();
26+
@@ -97,7 +97,7 @@ size_t GetUnderestimatedStackSize() {
2927
}
3028

3129
void* GetStackStart() {
32-
-#if defined(__GLIBC__) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \
33-
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \
34-
defined(OS_FUCHSIA)
30+
-#if defined(__GLIBC__) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
31+
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
32+
BUILDFLAG(IS_FUCHSIA)
3533
pthread_attr_t attr;
3634
int error;

meta-chromium/recipes-browser/chromium/files/musl/0007-__libc_malloc-is-internal-to-glibc.patch

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1313

1414
--- a/base/process/memory_linux.cc
1515
+++ b/base/process/memory_linux.cc
16-
@@ -119,7 +119,7 @@ bool UncheckedMalloc(size_t size, void**
17-
(!defined(LIBC_GLIBC) && !BUILDFLAG(USE_TCMALLOC))
16+
@@ -111,7 +111,7 @@ bool UncheckedMalloc(size_t size, void**
17+
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || !defined(LIBC_GLIBC)
1818
*result = malloc(size);
19-
#elif defined(LIBC_GLIBC) && !BUILDFLAG(USE_TCMALLOC)
19+
#elif defined(LIBC_GLIBC)
2020
- *result = __libc_malloc(size);
2121
+ *result = malloc(size);
22-
#elif BUILDFLAG(USE_TCMALLOC)
23-
*result = tc_malloc_skip_new_handler(size);
2422
#endif
23+
return *result != nullptr;
24+
}
25+
@@ -122,7 +122,7 @@ void UncheckedFree(void* ptr) {
26+
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || !defined(LIBC_GLIBC)
27+
free(ptr);
28+
#elif defined(LIBC_GLIBC)
29+
- __libc_free(ptr);
30+
+ free(ptr);
31+
#endif
32+
}
33+

meta-chromium/recipes-browser/chromium/files/musl/0008-gnu_libc_version-API-is-glibc-specific.patch

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,52 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1313

1414
--- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
1515
+++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
16-
@@ -62,8 +62,9 @@
16+
@@ -57,14 +57,14 @@
17+
1718
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
1819
// of lacros-chrome is complete.
19-
#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
20-
+#if defined(__GLIBC__)
20+
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
21+
+#if defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
2122
#include <gnu/libc-version.h>
22-
-
23-
+#endif
23+
2424
#include "base/linux_util.h"
2525
#include "base/strings/string_split.h"
2626
#include "base/strings/string_util.h"
27-
@@ -248,7 +249,7 @@ void RecordStartupMetrics() {
27+
#include "base/version.h"
28+
-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
29+
+#endif // defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
30+
31+
#if defined(USE_OZONE)
32+
#include "ui/events/devices/device_data_manager.h"
33+
@@ -237,7 +237,7 @@ void RecordStartupMetrics() {
2834

2935
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
3036
// of lacros-chrome is complete.
31-
-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
37+
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
3238
+#if defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
3339
void RecordLinuxDistroSpecific(const std::string& version_string,
3440
size_t parts,
3541
const char* histogram_name) {
36-
@@ -331,7 +332,8 @@ void RecordLinuxDistro() {
42+
@@ -315,12 +315,12 @@ void RecordLinuxDistro() {
43+
44+
base::UmaHistogramSparse("Linux.Distro2", distro_result);
45+
}
46+
-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
47+
+#endif // defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
48+
3749
void RecordLinuxGlibcVersion() {
3850
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
3951
// of lacros-chrome is complete.
40-
-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
52+
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
4153
+#if defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
42-
+
4354
base::Version version(gnu_get_libc_version());
4455

4556
UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE;
46-
@@ -832,7 +834,7 @@ void ChromeBrowserMainExtraPartsMetrics:
57+
@@ -610,7 +610,7 @@ void ChromeBrowserMainExtraPartsMetrics:
4758
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN};
4859
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
4960
// of lacros-chrome is complete.
50-
-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
61+
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
5162
+#if defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
5263
base::ThreadPool::PostTask(FROM_HERE, kBestEffortTaskTraits,
5364
base::BindOnce(&RecordLinuxDistro));

0 commit comments

Comments
 (0)