Skip to content

Commit

Permalink
qt5-qtwebengine: progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanaraps committed Jan 17, 2020
1 parent 417cfcf commit 7201e01
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testing/qt5-qtwebengine/checksums
@@ -1,9 +1,17 @@
74f8c11cc318612c8d9dc87cf791badb1efe7080c10d8b3ed5843b249a942d32 qtwebengine-everywhere-src-5.14.0.tar.xz
1be1f8e2851f6420f0676fb4f1562368125f93da8bff977be741f85bb453a9fe 0004-mkspecs-Allow-builds-with-libc-glibc.patch
9cd813f5a0b39795dd8f8822f30f9fd4fd4952bad4b4037cf0bf0f2918a56541 0011-chromium-musl-sandbox-Define-TEMP_FAILURE_RETRY-if-n.patch
9d0b16939513f998da00834b1823743807b6aba04df732e83d42f15620359b35 0012-chromium-musl-Avoid-mallinfo-APIs-on-non-glibc-linux.patch
8ecd920e8c6f69d4c9e1dc177710c79209f9494cc67126b2473bd2f8a020cab8 0013-chromium-musl-include-fcntl.h-for-loff_t.patch
d8c4b9d330704b5fe50335a4ad44d6128cfc134de372018906f437df73dc08df 0014-chromium-musl-use-off64_t-instead-of-the-internal-__.patch
f02c111dab32ba3fbe79b052fbbced25480e4ab3cfcdcb0e5483f5eed37ac85c 0015-chromium-musl-linux-glibc-make-the-distinction.patch
d58511d9d6b04be447459d9f5eebfc2fa67f3c5ffc4482f5a57d8ab60ef41489 0016-chromium-musl-allocator-Do-not-include-glibc_weak_sy.patch
1e87c3f07b134d8f4ded953a0d916b9d5754fb580e1b72b2752ebf49fed6fd19 0017-chromium-musl-Use-correct-member-name-__si_fields-fr.patch
f282d229122574e7573b201280bd3ea7eae171c32f28c57f1fbef66ceb69aa75 0018-chromium-musl-Define-res_ninit-and-res_nclose-for-no.patch
d81774d8049d8cae8a78b12b3abf723565ba87b54e0ccb26424d2c6e6a364588 0019-chromium-musl-Do-not-define-__sbrk-on-musl.patch
eb03407950b724c2131b930fb4b1b330ed5ed30f5584b383b6ba345596552495 0020-chromium-musl-Adjust-default-pthread-stack-size.patch
a58627c95fef502a1a9eeaa29f77bd60d17ab39dd51c994dcc7073fe7590232e 0021-chromium-musl-Use-_fpstate-instead-of-_libc_fpstate-.patch
fe8057b83f02f19e169faa9e4e6ebd11a4e3ba33453ea46df6672293edf9dd09 0022-chromium-musl-elf_reader.cc-include-sys-reg.h-to-get.patch
bd58ef5468799716187e0783c9c0a595eeb17ac619104c35b456c58350cf9b3e 0023-chromium-musl-pread-pwrite.patch
2924bd45f2ca95aa19d303b55368cc72041a2367b233ea6b69c2febf856518f5 0030-chromium-musl-execinfo.patch
6022046c7dd937c2d063fa93632cf9ffd8ce894b422bf14c10815eb7b346b20c 0031-chromium-musl-portable-msghdr.patch
@@ -0,0 +1,33 @@
From d38a63908f5c49705abd85bd9c2aee0ec334221d 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] chromium: musl: sandbox: Define TEMP_FAILURE_RETRY if not
defined

Musl does not define this Macro

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
chromium/sandbox/linux/suid/sandbox.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/chromium/sandbox/linux/suid/sandbox.c b/chromium/sandbox/linux/suid/sandbox.c
index 854819bfbb4..a99d32741d0 100644
--- a/src/3rdparty/chromium/sandbox/linux/suid/sandbox.c
+++ b/src/3rdparty/chromium/sandbox/linux/suid/sandbox.c
@@ -46,6 +46,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)));

@@ -0,0 +1,22 @@
From e087d26af9bdd2f045f8a81fdd2688c50b77e938 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] chromium: musl: include fcntl.h for loff_t

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
.../tcmalloc/chromium/src/base/linux_syscall_support.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/chromium/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h b/chromium/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h
index ca5936d6e63..5484dbadfbd 100644
--- a/src/3rdparty/chromium/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h
+++ b/src/3rdparty/chromium/third_party/tcmalloc/chromium/src/base/linux_syscall_support.h
@@ -154,6 +154,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>
@@ -0,0 +1,62 @@
From 5cde4d2fb5affc6e739dba412453b4bf076f19e9 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] chromium: musl: 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>
---
.../tcmalloc/chromium/src/malloc_hook_mmap_linux.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h b/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
index 17415aaf538..59c1b6fb5f6 100644
--- a/src/3rdparty/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
+++ b/src/3rdparty/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
@@ -60,7 +60,7 @@

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);
@@ -73,7 +73,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
@@ -144,7 +144,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
@@ -159,7 +159,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(
@@ -170,7 +170,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 {
@@ -0,0 +1,23 @@
From 04a11fa6f38987091b6b65244950d3d83579c9a8 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] chromium: musl: linux != glibc, make the distinction

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
chromium/base/allocator/allocator_check.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chromium/base/allocator/allocator_check.cc b/chromium/base/allocator/allocator_check.cc
index 5fb86467dde..9864858eb67 100644
--- a/src/3rdparty/chromium/base/allocator/allocator_check.cc
+++ b/src/3rdparty/chromium/base/allocator/allocator_check.cc
@@ -27,7 +27,7 @@ bool IsAllocatorInitialized() {
// Set by allocator_shim_override_ucrt_symbols_win.h 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.
@@ -0,0 +1,24 @@
From 59ab7f11b90bd2114ff8cc16d6502e0ad6bb6538 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] chromium: musl: allocator: Do not include glibc_weak_symbols
for musl

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
chromium/base/allocator/allocator_shim.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chromium/base/allocator/allocator_shim.cc b/chromium/base/allocator/allocator_shim.cc
index e6838ebda84..7296cc9ed81 100644
--- a/src/3rdparty/chromium/base/allocator/allocator_shim.cc
+++ b/src/3rdparty/chromium/base/allocator/allocator_shim.cc
@@ -351,7 +351,7 @@ ALWAYS_INLINE void ShimAlignedFree(void* address, void* context) {
// 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

@@ -0,0 +1,79 @@
From 09c0c63a65770465ef2ec0a3b028e22a9a0164f6 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 7 Jul 2017 15:27:50 -0700
Subject: [PATCH] chromium: musl: Define res_ninit and res_nclose for non-glibc
platforms

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
chromium/net/dns/dns_config_service_posix.cc | 4 +++
chromium/net/dns/dns_reloader.cc | 4 +++
chromium/net/dns/resolv_compat.h | 29 ++++++++++++++++++++
3 files changed, 37 insertions(+)
create mode 100644 chromium/net/dns/resolv_compat.h

diff --git a/chromium/net/dns/dns_config_service_posix.cc b/chromium/net/dns/dns_config_service_posix.cc
index ee2d5721425..bcb83b07f6e 100644
--- a/src/3rdparty/chromium/net/dns/dns_config_service_posix.cc
+++ b/src/3rdparty/chromium/net/dns/dns_config_service_posix.cc
@@ -29,6 +29,10 @@
#include "net/dns/public/dns_protocol.h"
#include "net/dns/serial_worker.h"

+#if defined(OS_LINUX) && !defined(__GLIBC__)
+#include "net/dns/resolv_compat.h"
+#endif
+
#if defined(OS_MACOSX) && !defined(OS_IOS)
#include "net/dns/dns_config_watcher_mac.h"
#endif
diff --git a/chromium/net/dns/dns_reloader.cc b/chromium/net/dns/dns_reloader.cc
index 03e248c9878..9ccda82c7e9 100644
--- a/src/3rdparty/chromium/net/dns/dns_reloader.cc
+++ b/src/3rdparty/chromium/net/dns/dns_reloader.cc
@@ -9,6 +9,10 @@

#include <resolv.h>

+#if defined(OS_LINUX) && !defined(__GLIBC__)
+#include "net/dns/resolv_compat.h"
+#endif
+
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
diff --git a/chromium/net/dns/resolv_compat.h b/chromium/net/dns/resolv_compat.h
new file mode 100644
index 00000000000..4f0e852a19d
--- /dev/null
+++ b/src/3rdparty/chromium/net/dns/resolv_compat.h
@@ -0,0 +1,29 @@
+#if !defined(__GLIBC__)
+/***************************************************************************
+ * resolv_compat.h
+ *
+ * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
+ * Note: res_init() is actually deprecated according to
+ * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
+ **************************************************************************/
+#include <string.h>
+
+static inline int res_ninit(res_state statp)
+{
+ int rc = res_init();
+ if (statp != &_res) {
+ memcpy(statp, &_res, sizeof(*statp));
+ }
+ return rc;
+}
+
+static inline int res_nclose(res_state statp)
+{
+ if (!statp)
+ return -1;
+ if (statp != &_res) {
+ memset(statp, 0, sizeof(*statp));
+ }
+ return 0;
+}
+#endif
@@ -0,0 +1,26 @@
From 57ebdf59c45c70ab13b724a2293fdd78241a8a37 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 7 Jul 2017 15:39:57 -0700
Subject: [PATCH] chromium: musl: Do not define __sbrk on musl

musl libc does not have sbrk. on musl libc will only work when called with 0 as
argument, so we just let it out for now

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
.../third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h b/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
index 59c1b6fb5f6..10f0786d829 100644
--- a/src/3rdparty/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
+++ b/src/3rdparty/chromium/third_party/tcmalloc/chromium/src/malloc_hook_mmap_linux.h
@@ -213,7 +213,7 @@ extern "C" void* mremap(void* old_addr, size_t old_size, size_t new_size,
return result;
}

-#ifndef __UCLIBC__
+#if !defined(__UCLIBC__) && defined(__GLIBC__)
// libc's version:
extern "C" void* __sbrk(intptr_t increment);

@@ -0,0 +1,35 @@
initialize msghdr in a compatible manner

msghdr stuct from socket.h is not same between musl and glibc
where musl claims to be more posix compliant where as glibc seems
to fill whats needed for linux sizewise and chooses long enough types
which maybe questionable, therefore constructing a structure with explicit
constructor is not going to work correctly for musl and glibc at same time

see
https://git.musl-libc.org/cgit/musl/commit/arch/x86_64/bits/socket.h?id=7168790763cdeb794df52be6e3b39fbb021c5a64

This fix initialized the struct to 0 first and then sets the struct elements
by name, so we dont have to hard code the positions of elements when initializing
structure

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>

--- a/src/3rdparty/chromium/net/socket/udp_socket_posix.cc
+++ b/src/3rdparty/chromium/net/socket/udp_socket_posix.cc
@@ -1193,8 +1193,12 @@ SendResult UDPSocketPosixSender::Interna
for (auto& buffer : buffers)
msg_iov->push_back({const_cast<char*>(buffer->data()), buffer->length()});
msgvec->reserve(buffers.size());
- for (size_t j = 0; j < buffers.size(); j++)
- msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0});
+ for (size_t j = 0; j < buffers.size(); j++) {
+ struct msghdr m = {0};
+ m.msg_iov = &msg_iov[j];
+ m.msg_iovlen = 1;
+ msgvec->push_back({m, 0});
+ }
int result = HANDLE_EINTR(Sendmmsg(fd, &msgvec[0], buffers.size(), 0));
SendResult send_result(0, 0, std::move(buffers));
if (result < 0) {
8 changes: 8 additions & 0 deletions testing/qt5-qtwebengine/sources
@@ -1,9 +1,17 @@
http://download.qt-project.org/official_releases/qt/5.14/5.14.0/submodules/qtwebengine-everywhere-src-5.14.0.tar.xz
patches/0004-mkspecs-Allow-builds-with-libc-glibc.patch
patches/0011-chromium-musl-sandbox-Define-TEMP_FAILURE_RETRY-if-n.patch
patches/0012-chromium-musl-Avoid-mallinfo-APIs-on-non-glibc-linux.patch
patches/0013-chromium-musl-include-fcntl.h-for-loff_t.patch
patches/0014-chromium-musl-use-off64_t-instead-of-the-internal-__.patch
patches/0015-chromium-musl-linux-glibc-make-the-distinction.patch
patches/0016-chromium-musl-allocator-Do-not-include-glibc_weak_sy.patch
patches/0017-chromium-musl-Use-correct-member-name-__si_fields-fr.patch
patches/0018-chromium-musl-Define-res_ninit-and-res_nclose-for-no.patch
patches/0019-chromium-musl-Do-not-define-__sbrk-on-musl.patch
patches/0020-chromium-musl-Adjust-default-pthread-stack-size.patch
patches/0021-chromium-musl-Use-_fpstate-instead-of-_libc_fpstate-.patch
patches/0022-chromium-musl-elf_reader.cc-include-sys-reg.h-to-get.patch
patches/0023-chromium-musl-pread-pwrite.patch
patches/0030-chromium-musl-execinfo.patch
patches/0031-chromium-musl-portable-msghdr.patch

0 comments on commit 7201e01

Please sign in to comment.