-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chromium: Fix build for musl platforms
Signed-off-by: Khem Raj <raj.khem@gmail.com>
- Loading branch information
Showing
18 changed files
with
679 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...pes-browser/chromium/chromium/0001-sandbox-Define-TEMP_FAILURE_RETRY-if-not-defined.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 89d6283c91f2229cc51f473eed344de97d09e946 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 14:01:12 -0700 | ||
Subject: [PATCH 01/12] sandbox: Define TEMP_FAILURE_RETRY if not defined | ||
|
||
Musl does not define this Macro | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
sandbox/linux/suid/sandbox.c | 9 +++++++++ | ||
1 file changed, 9 insertions(+) | ||
|
||
diff --git a/sandbox/linux/suid/sandbox.c b/sandbox/linux/suid/sandbox.c | ||
index b655d1c79..3de34e36f 100644 | ||
--- a/sandbox/linux/suid/sandbox.c | ||
+++ b/sandbox/linux/suid/sandbox.c | ||
@@ -44,6 +44,15 @@ static bool DropRoot(); | ||
|
||
#define HANDLE_EINTR(x) TEMP_FAILURE_RETRY(x) | ||
|
||
+#ifndef TEMP_FAILURE_RETRY | ||
+# define TEMP_FAILURE_RETRY(expression) \ | ||
+ (__extension__ \ | ||
+ ({ long int __result; \ | ||
+ do __result = (long int) (expression); \ | ||
+ while (__result == -1L && errno == EINTR); \ | ||
+ __result; })) | ||
+#endif | ||
+ | ||
static void FatalError(const char* msg, ...) | ||
__attribute__((noreturn, format(printf, 1, 2))); | ||
|
||
-- | ||
2.13.2 | ||
|
40 changes: 40 additions & 0 deletions
40
...browser/chromium/chromium/0002-breakpad-Replace-__WORDSIZE-with-defines-from-limits.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 819e83dfbd0af9fa37f674f6d3783556b7ccb867 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 14:03:18 -0700 | ||
Subject: [PATCH 02/12] breakpad: Replace __WORDSIZE with defines from limits.h | ||
|
||
Fixes | ||
elf_core_dump.h:59:2: error: #error "Unsupported __WORDSIZE for ElfCoreDump." | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
breakpad/src/common/linux/elf_core_dump.h | 5 +++-- | ||
1 file changed, 3 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/breakpad/src/common/linux/elf_core_dump.h b/breakpad/src/common/linux/elf_core_dump.h | ||
index d03c7a88d..78ca9dd92 100644 | ||
--- a/breakpad/src/common/linux/elf_core_dump.h | ||
+++ b/breakpad/src/common/linux/elf_core_dump.h | ||
@@ -36,6 +36,7 @@ | ||
#include <elf.h> | ||
#include <link.h> | ||
#include <stddef.h> | ||
+#include <limits.h> | ||
|
||
#include "common/memory_range.h" | ||
|
||
@@ -51,9 +52,9 @@ class ElfCoreDump { | ||
typedef ElfW(Phdr) Phdr; | ||
typedef ElfW(Word) Word; | ||
typedef ElfW(Addr) Addr; | ||
-#if __WORDSIZE == 32 | ||
+#if ULONG_MAX == 0xffffffff | ||
static const int kClass = ELFCLASS32; | ||
-#elif __WORDSIZE == 64 | ||
+#elif ULONG_MAX == 0xffffffffffffffff | ||
static const int kClass = ELFCLASS64; | ||
#else | ||
#error "Unsupported __WORDSIZE for ElfCoreDump." | ||
-- | ||
2.13.2 | ||
|
48 changes: 48 additions & 0 deletions
48
recipes-browser/chromium/chromium/0003-Avoid-mallinfo-APIs-on-non-glibc-linux.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From 8defe37306b0d1548592afc12baa45f4aec5375c Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 14:09:06 -0700 | ||
Subject: [PATCH 03/12] Avoid mallinfo() APIs on non-glibc/linux | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
base/trace_event/malloc_dump_provider.cc | 3 ++- | ||
content/child/content_child_helpers.cc | 2 +- | ||
2 files changed, 3 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc | ||
index 3b1a933bc..a554d0373 100644 | ||
--- a/base/trace_event/malloc_dump_provider.cc | ||
+++ b/base/trace_event/malloc_dump_provider.cc | ||
@@ -103,6 +103,7 @@ MallocDumpProvider::~MallocDumpProvider() {} | ||
// the current process. | ||
bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, | ||
ProcessMemoryDump* pmd) { | ||
+#if defined(__GLIBC__) | ||
size_t total_virtual_size = 0; | ||
size_t resident_size = 0; | ||
size_t allocated_objects_size = 0; | ||
@@ -195,7 +196,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, | ||
pmd->DumpHeapUsage(metrics_by_context, overhead, "malloc"); | ||
} | ||
tid_dumping_heap_ = kInvalidThreadId; | ||
- | ||
+#endif // __GLIBC__ | ||
return true; | ||
} | ||
|
||
diff --git a/content/child/content_child_helpers.cc b/content/child/content_child_helpers.cc | ||
index 7ddeb4d16..b8c73b09c 100644 | ||
--- a/content/child/content_child_helpers.cc | ||
+++ b/content/child/content_child_helpers.cc | ||
@@ -25,7 +25,7 @@ namespace content { | ||
// though, this provides only a partial and misleading value. | ||
// Unfortunately some telemetry benchmark rely on it and these need to | ||
// be refactored before getting rid of this. See crbug.com/581365 . | ||
-#if defined(OS_LINUX) || defined(OS_ANDROID) | ||
+#if defined(__GLIBC__) || defined(OS_ANDROID) | ||
size_t GetMemoryUsageKB() { | ||
struct mallinfo minfo = mallinfo(); | ||
uint64_t mem_usage = | ||
-- | ||
2.13.2 | ||
|
25 changes: 25 additions & 0 deletions
25
recipes-browser/chromium/chromium/0004-include-fcntl.h-for-loff_t.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From a0b40dcdfb3331d2b8351bdfb27f1ba3e8a2c33c Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 14:37:49 -0700 | ||
Subject: [PATCH 04/12] include fcntl.h for loff_t | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
third_party/tcmalloc/chromium/src/base/linux_syscall_support.h | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h b/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h | ||
index bdbc4b7e3..b53dd46c5 100644 | ||
--- a/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h | ||
+++ b/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h | ||
@@ -151,6 +151,7 @@ extern "C" { | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
+#include <fcntl.h> | ||
#include <sys/ptrace.h> | ||
#include <sys/resource.h> | ||
#include <sys/time.h> | ||
-- | ||
2.13.2 | ||
|
65 changes: 65 additions & 0 deletions
65
recipes-browser/chromium/chromium/0005-use-off64_t-instead-of-the-internal-__off64_t.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
From badea43b85346525b7c43c38c32d150b7eb85b13 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 14:38:37 -0700 | ||
Subject: [PATCH 05/12] use off64_t instead of the internal __off64_t | ||
|
||
- only do the glibc 32-bit ABI check for mmap/mmap64 on gnu libc. musl | ||
does not support the 32-bit ABI. | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h | 10 +++++----- | ||
1 file changed, 5 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h b/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h | ||
index 715c045f6..edc8cf2db 100644 | ||
--- a/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h | ||
+++ b/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h | ||
@@ -77,7 +77,7 @@ typedef off64_t __off64_t; | ||
|
||
static inline void* do_mmap64(void *start, size_t length, | ||
int prot, int flags, | ||
- int fd, __off64_t offset) __THROW { | ||
+ int fd, off64_t offset) __THROW { | ||
// The original gperftools uses sys_mmap() here. But, it is not allowed by | ||
// Chromium's sandbox. | ||
return (void *)syscall(SYS_mmap, start, length, prot, flags, fd, offset); | ||
@@ -90,7 +90,7 @@ static inline void* do_mmap64(void *start, size_t length, | ||
|
||
static inline void* do_mmap64(void *start, size_t length, | ||
int prot, int flags, | ||
- int fd, __off64_t offset) __THROW { | ||
+ int fd, off64_t offset) __THROW { | ||
void *result; | ||
|
||
// Try mmap2() unless it's not supported | ||
@@ -161,7 +161,7 @@ static inline void* do_mmap64(void *start, size_t length, | ||
|
||
extern "C" { | ||
void* mmap64(void *start, size_t length, int prot, int flags, | ||
- int fd, __off64_t offset ) __THROW | ||
+ int fd, off64_t offset ) __THROW | ||
ATTRIBUTE_SECTION(malloc_hook); | ||
void* mmap(void *start, size_t length,int prot, int flags, | ||
int fd, off_t offset) __THROW | ||
@@ -178,7 +178,7 @@ extern "C" { | ||
} | ||
|
||
extern "C" void* mmap64(void *start, size_t length, int prot, int flags, | ||
- int fd, __off64_t offset) __THROW { | ||
+ int fd, off64_t offset) __THROW { | ||
MallocHook::InvokePreMmapHook(start, length, prot, flags, fd, offset); | ||
void *result; | ||
if (!MallocHook::InvokeMmapReplacement( | ||
@@ -189,7 +189,7 @@ extern "C" void* mmap64(void *start, size_t length, int prot, int flags, | ||
return result; | ||
} | ||
|
||
-# if !defined(__USE_FILE_OFFSET64) || !defined(__REDIRECT_NTH) | ||
+# if defined(__GLIBC__) && (!defined(__USE_FILE_OFFSET64) || !defined(__REDIRECT_NTH)) | ||
|
||
extern "C" void* mmap(void *start, size_t length, int prot, int flags, | ||
int fd, off_t offset) __THROW { | ||
-- | ||
2.13.2 | ||
|
26 changes: 26 additions & 0 deletions
26
recipes-browser/chromium/chromium/0006-linux-glibc-make-the-distinction.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 4913850cd644e1fd44ecade5e9faa460de35a7d6 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 14:54:38 -0700 | ||
Subject: [PATCH 06/12] linux != glibc, make the distinction | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
base/allocator/allocator_check.cc | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/base/allocator/allocator_check.cc b/base/allocator/allocator_check.cc | ||
index 5a0564d2f..8c2dc6491 100644 | ||
--- a/base/allocator/allocator_check.cc | ||
+++ b/base/allocator/allocator_check.cc | ||
@@ -21,7 +21,7 @@ bool IsAllocatorInitialized() { | ||
#if defined(OS_WIN) && defined(ALLOCATOR_SHIM) | ||
// Set by allocator_shim_win.cc when the shimmed _set_new_mode() is called. | ||
return g_is_win_shim_layer_initialized; | ||
-#elif defined(OS_LINUX) && defined(USE_TCMALLOC) && \ | ||
+#elif defined(__GLIBC__) && defined(USE_TCMALLOC) && \ | ||
!defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | ||
// From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h. | ||
// TODO(primiano): replace with an include once base can depend on allocator. | ||
-- | ||
2.13.2 | ||
|
26 changes: 26 additions & 0 deletions
26
...browser/chromium/chromium/0007-allocator-Do-not-include-glibc_weak_symbols-for-musl.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 482e77e9562b8a158b5b212e9f1c83c697fed2e2 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 15:09:02 -0700 | ||
Subject: [PATCH 07/12] allocator: Do not include glibc_weak_symbols for musl | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
base/allocator/allocator_shim.cc | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc | ||
index 57a398aaa..54c79063a 100644 | ||
--- a/base/allocator/allocator_shim.cc | ||
+++ b/base/allocator/allocator_shim.cc | ||
@@ -263,7 +263,7 @@ void ShimFree(void* address) { | ||
// In the case of tcmalloc we also want to plumb into the glibc hooks | ||
// to avoid that allocations made in glibc itself (e.g., strdup()) get | ||
// accidentally performed on the glibc heap instead of the tcmalloc one. | ||
-#if defined(USE_TCMALLOC) | ||
+#if defined(USE_TCMALLOC) && defined(__GLIBC__) | ||
#include "base/allocator/allocator_shim_override_glibc_weak_symbols.h" | ||
#endif | ||
|
||
-- | ||
2.13.2 | ||
|
26 changes: 26 additions & 0 deletions
26
...browser/chromium/chromium/0008-Use-correct-member-name-__si_fields-from-LinuxSigInf.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 3d12eb821e105111cbd88f5598746bd77c3a9ef0 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 15:12:39 -0700 | ||
Subject: [PATCH 08/12] Use correct member name __si_fields from LinuxSigInfo | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
sandbox/linux/seccomp-bpf/trap.cc | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/sandbox/linux/seccomp-bpf/trap.cc b/sandbox/linux/seccomp-bpf/trap.cc | ||
index 003708d2c..0fef3148f 100644 | ||
--- a/sandbox/linux/seccomp-bpf/trap.cc | ||
+++ b/sandbox/linux/seccomp-bpf/trap.cc | ||
@@ -168,7 +168,7 @@ void Trap::SigSys(int nr, LinuxSigInfo* info, ucontext_t* ctx) { | ||
// most versions of glibc don't include this information in siginfo_t. So, | ||
// we need to explicitly copy it into a arch_sigsys structure. | ||
struct arch_sigsys sigsys; | ||
- memcpy(&sigsys, &info->_sifields, sizeof(sigsys)); | ||
+ memcpy(&sigsys, &info->__si_fields, sizeof(sigsys)); | ||
|
||
#if defined(__mips__) | ||
// When indirect syscall (syscall(__NR_foo, ...)) is made on Mips, the | ||
-- | ||
2.13.2 | ||
|
47 changes: 47 additions & 0 deletions
47
recipes-browser/chromium/chromium/0009-Match-syscalls-to-match-musl.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
From 5843df01580b0fb956ee4b7e1a60c0130c8c90f9 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 7 Jul 2017 15:24:49 -0700 | ||
Subject: [PATCH 09/12] Match syscalls to match musl | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
third_party/lss/linux_syscall_support.h | 16 ++++++++++++++++ | ||
1 file changed, 16 insertions(+) | ||
|
||
diff --git a/third_party/lss/linux_syscall_support.h b/third_party/lss/linux_syscall_support.h | ||
index 9dbd2391b..a715de177 100644 | ||
--- a/third_party/lss/linux_syscall_support.h | ||
+++ b/third_party/lss/linux_syscall_support.h | ||
@@ -793,6 +793,14 @@ struct kernel_statfs { | ||
#endif | ||
|
||
|
||
+#undef stat64 | ||
+#undef fstat64 | ||
+ | ||
+#ifndef __NR_fstatat | ||
+#define __NR_fstatat __NR_fstatat64 | ||
+#endif | ||
+ | ||
+ | ||
#if defined(__x86_64__) | ||
#ifndef ARCH_SET_GS | ||
#define ARCH_SET_GS 0x1001 | ||
@@ -1210,6 +1218,14 @@ struct kernel_statfs { | ||
#ifndef __NR_fallocate | ||
#define __NR_fallocate 285 | ||
#endif | ||
+ | ||
+#ifndef __NR_pread | ||
+#define __NR_pread __NR_pread64 | ||
+#endif | ||
+#ifndef __NR_pwrite | ||
+#define __NR_pwrite __NR_pwrite64 | ||
+#endif | ||
+ | ||
/* End of x86-64 definitions */ | ||
#elif defined(__mips__) | ||
#if _MIPS_SIM == _MIPS_SIM_ABI32 | ||
-- | ||
2.13.2 | ||
|
Oops, something went wrong.