Added musl suport to chromium package

This commit is contained in:
Amon-Ra 2015-11-27 17:02:40 +01:00 committed by Juan RP
parent dd89ad4889
commit 7c2c84269f
7 changed files with 475 additions and 2 deletions

View file

@ -0,0 +1,230 @@
--- ./third_party/lss/linux_syscall_support.h.orig
+++ ./third_party/lss/linux_syscall_support.h
@@ -1127,6 +1127,12 @@
#ifndef __NR_fallocate
#define __NR_fallocate 285
#endif
+
+#undef __NR_pread
+#define __NR_pread __NR_pread64
+#undef __NR_pwrite
+#define __NR_pwrite __NR_pwrite64
+
/* End of x86-64 definitions */
#elif defined(__mips__)
#if _MIPS_SIM == _MIPS_SIM_ABI32
--- ./breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc.orig
+++ ./breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
@@ -49,7 +49,7 @@
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
- const struct _libc_fpstate* fp) {
+ const struct _fpstate* fp) {
const greg_t* regs = uc->uc_mcontext.gregs;
out->context_flags = MD_CONTEXT_X86_FULL |
@@ -97,7 +97,7 @@
}
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
- const struct _libc_fpstate* fpregs) {
+ const struct _fpstate* fpregs) {
const greg_t* regs = uc->uc_mcontext.gregs;
out->context_flags = MD_CONTEXT_AMD64_FULL;
--- ./breakpad/src/client/linux/dump_writer_common/ucontext_reader.h.orig
+++ ./breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
@@ -50,7 +50,7 @@
// info: the collection of register structures.
#if defined(__i386__) || defined(__x86_64)
static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
- const struct _libc_fpstate* fp);
+ const struct _fpstate* fp);
#elif defined(__aarch64__)
static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
const struct fpsimd_context* fpregs);
--- ./breakpad/src/client/linux/minidump_writer/minidump_writer.h.orig
+++ ./breakpad/src/client/linux/minidump_writer/minidump_writer.h
@@ -48,7 +48,7 @@
#if defined(__aarch64__)
typedef struct fpsimd_context fpstate_t;
#elif !defined(__ARM_EABI__) && !defined(__mips__)
-typedef struct _libc_fpstate fpstate_t;
+typedef struct _fpstate fpstate_t;
#endif
// These entries store a list of memory regions that the client wants included
--- ./breakpad/src/common/linux/elf_core_dump.h.orig
+++ ./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 @@
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."
--- ./sandbox/linux/suid/process_util.h.orig
+++ ./sandbox/linux/suid/process_util.h
@@ -11,6 +11,14 @@
#include <stdbool.h>
#include <sys/types.h>
+// Some additional functions
+# define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ \
+ ({ long int __result; \
+ do __result = (long int) (expression); \
+ while (__result == -1L && errno == EINTR); \
+ __result; }))
+
// This adjusts /proc/process/oom_score_adj so the Linux OOM killer
// will prefer certain process types over others. The range for the
// adjustment is [-1000, 1000], with [0, 1000] being user accessible.
--- ./sandbox/linux/seccomp-bpf/trap.cc.orig
+++ ./sandbox/linux/seccomp-bpf/trap.cc
@@ -156,7 +156,7 @@
// 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
--- ./net/base/dns_reloader.cc.orig
+++ ./net/base/dns_reloader.cc
@@ -5,7 +5,7 @@
#include "net/base/dns_reloader.h"
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \
- !defined(OS_ANDROID)
+ !defined(OS_ANDROID) && !defined(_GNU_SOURCE)
#include <resolv.h>
--- ./net/dns/dns_config_service_posix.cc.orig
+++ ./net/dns/dns_config_service_posix.cc
@@ -116,7 +116,7 @@
ConfigParsePosixResult ReadDnsConfig(DnsConfig* config) {
ConfigParsePosixResult result;
config->unhandled_options = false;
-#if defined(OS_OPENBSD)
+#if defined(OS_OPENBSD) || defined(_GNU_SOURCE)
// Note: res_ninit in glibc always returns 0 and sets RES_INIT.
// res_init behaves the same way.
memset(&_res, 0, sizeof(_res));
--- ./third_party/ffmpeg/libavutil/cpu.c.orig
+++ ./third_party/ffmpeg/libavutil/cpu.c
@@ -38,7 +38,6 @@
#include <sys/param.h>
#endif
#include <sys/types.h>
-#include <sys/sysctl.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
--- ./third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp.orig
+++ ./third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp
@@ -58,7 +58,7 @@
// FIXME: On Mac OSX and Linux, this method cannot estimate stack size
// correctly for the main thread.
-#if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
+#if OS(LINUX) || OS(ANDROID) || OS(FREEBSD)
// pthread_getattr_np() can fail if the thread is not invoked by
// pthread_create() (e.g., the main thread of webkit_unit_tests).
// In this case, this method returns 0 and the caller must handle it.
@@ -105,7 +105,7 @@
void* StackFrameDepth::getStackStart()
{
-#if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
+#if OS(LINUX) || OS(ANDROID) || OS(FREEBSD)
pthread_attr_t attr;
int error;
#if OS(FREEBSD)
--- ./chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc.orig
+++ ./chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
@@ -26,7 +26,7 @@
#include "ui/events/event_switches.h"
#include "ui/gfx/screen.h"
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(__GLIBC__) && !defined(OS_CHROMEOS)
#include <gnu/libc-version.h>
#include "base/version.h"
--- ./chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc.orig
+++ ./chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
@@ -116,7 +116,7 @@
}
void RecordLinuxGlibcVersion() {
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(__GLIBC__) && !defined(OS_CHROMEOS)
Version version(gnu_get_libc_version());
UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE;
@@ -140,7 +140,7 @@
#endif
}
-#if defined(USE_X11) && !defined(OS_CHROMEOS)
+#if defined(__GLIBC__) && defined(USE_X11) && !defined(OS_CHROMEOS)
UMALinuxWindowManager GetLinuxWindowManager() {
switch (ui::GuessWindowManager()) {
case ui::WM_UNKNOWN:
@@ -239,7 +239,7 @@
void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() {
RecordLinuxGlibcVersion();
-#if defined(USE_X11) && !defined(OS_CHROMEOS)
+#if defined(__GLIBC__) && defined(USE_X11) && !defined(OS_CHROMEOS)
UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager",
GetLinuxWindowManager(),
UMA_LINUX_WINDOW_MANAGER_COUNT);
--- ./third_party/ffmpeg/libavutil/autorename_libavutil_cpu.c.orig
+++ ./third_party/ffmpeg/libavutil/autorename_libavutil_cpu.c
@@ -38,7 +38,6 @@
#include <sys/param.h>
#endif
#include <sys/types.h>
-#include <sys/sysctl.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
--- ./device/serial/serial_io_handler_posix.cc.orig
+++ ./device/serial/serial_io_handler_posix.cc
@@ -6,6 +6,7 @@
#include <sys/ioctl.h>
#include <termios.h>
+#include <asm-generic/ioctls.h>
#include "base/posix/eintr_wrapper.h"
--- ./base/logging.cc
+++ ./base/logging.cc.orig
@@ -543,7 +543,7 @@
}
LogMessage::~LogMessage() {
-#if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__)
+#if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && defined(__GLIBC__)
if (severity_ == LOG_FATAL) {
// Include a stack trace on a fatal.
base::debug::StackTrace trace;

View file

@ -0,0 +1,66 @@
--- ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc.cld
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
@@ -111,23 +111,13 @@
// CLONE_VM, nor CLONE_THREAD, which includes all fork() implementations.
ResultExpr RestrictCloneToThreadsAndEPERMFork() {
const Arg<unsigned long> flags(0);
+ const int required = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_THREAD | CLONE_SYSVSEM;
+ const int safe = CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
+ CLONE_DETACHED;
+ const BoolExpr thread_clone_ok = (flags&~safe)==required;
- // TODO(mdempsky): Extend DSL to support (flags & ~mask1) == mask2.
- const uint64_t kAndroidCloneMask = CLONE_VM | CLONE_FS | CLONE_FILES |
- CLONE_SIGHAND | CLONE_THREAD |
- CLONE_SYSVSEM;
- const uint64_t kObsoleteAndroidCloneMask = kAndroidCloneMask | CLONE_DETACHED;
-
- const uint64_t kGlibcPthreadFlags =
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD |
- CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
- const BoolExpr glibc_test = flags == kGlibcPthreadFlags;
-
- const BoolExpr android_test = flags == kAndroidCloneMask ||
- flags == kObsoleteAndroidCloneMask ||
- flags == kGlibcPthreadFlags;
-
- return If(IsAndroid() ? android_test : glibc_test, Allow())
+ return If(thread_clone_ok, Allow())
.ElseIf((flags & (CLONE_VM | CLONE_THREAD)) == 0, Error(EPERM))
.Else(CrashSIGSYSClone());
}
--- ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc.orig
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
@@ -416,12 +416,12 @@
#endif
case __NR_epoll_create1:
case __NR_epoll_ctl:
+ case __NR_epoll_pwait:
return true;
default:
#if defined(__x86_64__)
case __NR_epoll_ctl_old:
#endif
- case __NR_epoll_pwait:
#if defined(__x86_64__)
case __NR_epoll_wait_old:
#endif
--- ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc.orig
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
@@ -494,6 +494,7 @@
case __NR_mlock:
case __NR_munlock:
case __NR_munmap:
+ case __NR_mremap:
return true;
case __NR_madvise:
case __NR_mincore:
@@ -509,7 +510,6 @@
case __NR_modify_ldt:
#endif
case __NR_mprotect:
- case __NR_mremap:
case __NR_msync:
case __NR_munlockall:
case __NR_readahead:

View file

@ -0,0 +1,103 @@
--- ./base/debug/stack_trace_posix.cc.orig
+++ ./base/debug/stack_trace_posix.cc
@@ -22,7 +22,7 @@
#if defined(__GLIBCXX__)
#include <cxxabi.h>
#endif
-#if !defined(__UCLIBC__)
+#if defined(HAVE_BACKTRACE)
#include <execinfo.h>
#endif
@@ -73,7 +73,7 @@
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
+#if defined(__GLIBCXX__) && defined(HAVE_BACKTRACE)
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -169,7 +169,7 @@
handler->HandleOutput("\n");
}
-#elif !defined(__UCLIBC__)
+#elif defined(HAVE_BACKTRACE)
bool printed = false;
// Below part is async-signal unsafe (uses malloc), so execute it only
@@ -738,7 +738,7 @@
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-#if !defined(__UCLIBC__)
+#if defined(HAVE_BACKTRACE)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = base::saturated_cast<size_t>(backtrace(trace_, arraysize(trace_)));
@@ -751,13 +751,13 @@
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-#if !defined(__UCLIBC__)
+#if defined(HAVE_BACKTRACE)
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
#endif
}
-#if !defined(__UCLIBC__)
+#if defined(HAVE_BACKTRACE)
void StackTrace::OutputToStream(std::ostream* os) const {
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
--- ./third_party/WebKit/Source/wtf/Assertions.cpp.orig
+++ ./third_party/WebKit/Source/wtf/Assertions.cpp
@@ -61,7 +61,7 @@
#define HAVE_ISDEBUGGERPRESENT 1
#endif
-#if OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))
+#if defined(HAVE_BACKTRACE)
#include <cxxabi.h>
#include <dlfcn.h>
#include <execinfo.h>
@@ -222,7 +222,7 @@
void WTFGetBacktrace(void** stack, int* size)
{
-#if OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))
+#if defined(HAVE_BACKTRACE)
*size = backtrace(stack, *size);
#elif OS(WIN)
// The CaptureStackBackTrace function is available in XP, but it is not defined
@@ -260,7 +260,7 @@
: m_name(0)
, m_cxaDemangled(0)
{
-#if OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))
+#if defined(HAVE_BACKTRACE)
Dl_info info;
if (!dladdr(addr, &info) || !info.dli_sname)
return;
--- ./third_party/webrtc/base/checks.cc.orig
+++ ./third_party/webrtc/base/checks.cc
@@ -16,7 +16,7 @@
#include <cstdio>
#include <cstdlib>
-#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
+#if defined(HAVE_BACKTRACE)
#include <cxxabi.h>
#include <execinfo.h>
#endif
@@ -55,7 +55,7 @@
// to get usable symbols on Linux. This is copied from V8. Chromium has a more
// advanced stace trace system; also more difficult to copy.
void DumpBacktrace() {
-#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
+#if defined(HAVE_BACKTRACE)
void* trace[100];
int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
char** symbols = backtrace_symbols(trace, size);

View file

@ -0,0 +1,19 @@
--- ./breakpad/src/client/linux/handler/exception_handler.cc.orig
+++ ./breakpad/src/client/linux/handler/exception_handler.cc
@@ -460,7 +460,6 @@
siginfo.si_code = SI_USER;
siginfo.si_pid = getpid();
struct ucontext context;
- getcontext(&context);
return HandleSignal(sig, &siginfo, &context);
}
@@ -628,8 +627,6 @@
sys_prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
CrashContext context;
- int getcontext_result = getcontext(&context.context);
- if (getcontext_result)
return false;
#if defined(__i386__)

View file

@ -0,0 +1,29 @@
--- ./content/child/content_child_helpers.cc.orig
+++ ./content/child/content_child_helpers.cc
@@ -15,7 +15,7 @@
namespace content {
-#if defined(OS_LINUX) || defined(OS_ANDROID)
+#if defined(__GLIBC__) || defined(OS_ANDROID)
size_t GetMemoryUsageKB() {
struct mallinfo minfo = mallinfo();
uint64_t mem_usage =
--- ./base/trace_event/malloc_dump_provider.cc
+++ ./base/trace_event/malloc_dump_provider.cc
@@ -30,6 +30,7 @@
// the current process.
bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
ProcessMemoryDump* pmd) {
+#if defined(__GLIBC__)
struct mallinfo info = mallinfo();
DCHECK_GE(info.arena + info.hblkhd, info.uordblks);
@@ -47,6 +48,7 @@
MemoryAllocatorDump* inner_dump = pmd->CreateAllocatorDump(kAllocatedObjects);
inner_dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, info.uordblks);
+#endif
return true;
}

View file

@ -0,0 +1,24 @@
--- ./net/dns/host_resolver_impl.cc.orig
+++ ./net/dns/host_resolver_impl.cc
@@ -1881,8 +1881,7 @@
#endif
NetworkChangeNotifier::AddIPAddressObserver(this);
NetworkChangeNotifier::AddDNSObserver(this);
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \
- !defined(OS_ANDROID)
+#if defined(__GLIBC__)
EnsureDnsReloaderInit();
#endif
--- ./net/dns/host_resolver_proc.cc.orig
+++ ./net/dns/host_resolver_proc.cc
@@ -193,8 +193,7 @@
// Restrict result set to only this socket type to avoid duplicates.
hints.ai_socktype = SOCK_STREAM;
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \
- !defined(OS_ANDROID)
+#if defined(__GLIBC__)
DnsReloaderMaybeReload();
#endif
int err = getaddrinfo(host.c_str(), NULL, &hints, &ai);

View file

@ -11,7 +11,7 @@ distfiles="https://commondatastorage.googleapis.com/${pkgname}-browser-official/
checksum=ee18d28ac80ff958e8a6c770bfc0d7d770b55452ed91a87f731e1b432a7d1d92
# XXX musl disabled for now (needs some patches from Alpine)
only_for_archs="i686 x86_64"
only_for_archs="i686 x86_64 x86_64-musl"
lib32disabled=yes
nodebug=yes
@ -150,6 +150,8 @@ do_configure() {
case "${XBPS_TARGET_MACHINE}" in
i686*) conf+=" -Ddisable_nacl=1 -Ddisable_pnacl=1";;
x86_64-musl*) conf+=" -Duse_allocator=none -Ddisable_nacl=1 -Ddisable_pnacl=1 -Dtarget_arch=x64";;
i686-musl*) conf+=" -Duse_allocator=none -Dtarget_arch=ia32";;
arm*) conf+="
-Dtarget_arch=arm
-Ddisable_pnacl=1
@ -182,7 +184,7 @@ do_configure() {
-Dv8_can_use_vfp_instructions=false
-Dv8_can_use_vfp2_instructions=true";;
esac
build/linux/unbundle/replace_gyp_files.py ${conf}
build/gyp_chromium --depth=. ${conf} -Drelease_extra_cflags="${CFLAGS}"
}