Skip to content
Permalink
Browse files
[WPE] Build fixes for musl C library on Linux
https://bugs.webkit.org/show_bug.cgi?id=210068

Patch by Khem Raj <raj.khem@gmail.com> on 2021-04-08
Reviewed by Carlos Alberto Lopez Perez.

Source/JavaScriptCore:

Use OS(LINUX) to include musl in platform test
for linux and consolidate all linux platfrom
under same test. Use smaller limits for JSC
stack size per thread and reserved zone size.

* runtime/MachineContext.h:
(JSC::MachineContext::stackPointerImpl):
(JSC::MachineContext::framePointerImpl):
(JSC::MachineContext::instructionPointerImpl):
(JSC::MachineContext::argumentPointer<1>):
(JSC::MachineContext::llintInstructionPointer):
* runtime/OptionsList.h:

Source/WTF:

Define 128KB DEFAULT_THREAD_STACK_SIZE_IN_KB for musl
Use OS(LINUX) check to include musl when building for
Linux based platforms.

* wtf/PlatformHave.h:
* wtf/Threading.cpp:

Canonical link: https://commits.webkit.org/236306@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kraj authored and webkit-commit-queue committed Apr 8, 2021
1 parent 375833a commit 6884d1313c76c26469b52eab390eac393f9445d4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 10 deletions.
@@ -1,3 +1,23 @@
2021-04-08 Khem Raj <raj.khem@gmail.com>

[WPE] Build fixes for musl C library on Linux
https://bugs.webkit.org/show_bug.cgi?id=210068

Reviewed by Carlos Alberto Lopez Perez.

Use OS(LINUX) to include musl in platform test
for linux and consolidate all linux platfrom
under same test. Use smaller limits for JSC
stack size per thread and reserved zone size.

* runtime/MachineContext.h:
(JSC::MachineContext::stackPointerImpl):
(JSC::MachineContext::framePointerImpl):
(JSC::MachineContext::instructionPointerImpl):
(JSC::MachineContext::argumentPointer<1>):
(JSC::MachineContext::llintInstructionPointer):
* runtime/OptionsList.h:

2021-04-07 Yusuke Suzuki <ysuzuki@apple.com>

[JSC] DUCET level-1 weighs are equal if characters are alphabets
@@ -196,7 +196,7 @@ static inline void*& stackPointerImpl(mcontext_t& machineContext)
#error Unknown Architecture
#endif

#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
#elif OS(FUCHSIA) || OS(LINUX)

#if CPU(X86)
return reinterpret_cast<void*&>((uintptr_t&) machineContext.gregs[REG_ESP]);
@@ -347,7 +347,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext)
#error Unknown Architecture
#endif

#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
#elif OS(FUCHSIA) || OS(LINUX)

// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -498,7 +498,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext)
#error Unknown Architecture
#endif

#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
#elif OS(FUCHSIA) || OS(LINUX)

// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -656,7 +656,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext)
#error Unknown Architecture
#endif

#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
#elif OS(FUCHSIA) || OS(LINUX)

// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -773,7 +773,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext)
#error Unknown Architecture
#endif

#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__)
#elif OS(FUCHSIA) || OS(LINUX)

// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -71,6 +71,18 @@ JS_EXPORT_PRIVATE bool canUseJITCage();
// On instantiation of the first VM instance, the Options will be write protected
// and cannot be modified thereafter.

#if OS(LINUX) && !defined(__BIONIC__) && !defined(__GLIBC__)
// non-glibc/non-android options on linux ( musl )
constexpr unsigned jscMaxPerThreadStack = 128 * KB;
constexpr unsigned jscSoftReservedZoneSize = 32 * KB;
constexpr unsigned jscReservedZoneSize = 16 * KB;
#else
// default
constexpr unsigned jscMaxPerThreadStack = 5 * MB;
constexpr unsigned jscSoftReservedZoneSize = 128 * KB;
constexpr unsigned jscReservedZoneSize = 64 * KB;
#endif

#define FOR_EACH_JSC_OPTION(v) \
v(Bool, useKernTCSM, defaultTCSMValue(), Normal, "Note: this needs to go before other options since they depend on this value.") \
v(Bool, validateOptions, false, Normal, "crashes if mis-typed JSC options were passed to the VM") \
@@ -86,9 +98,9 @@ JS_EXPORT_PRIVATE bool canUseJITCage();
\
v(Bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \
\
v(Unsigned, maxPerThreadStackUsage, 5 * MB, Normal, "Max allowed stack usage by the VM") \
v(Unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \
v(Unsigned, maxPerThreadStackUsage, jscMaxPerThreadStack, Normal, "Max allowed stack usage by the VM") \
v(Unsigned, softReservedZoneSize, jscSoftReservedZoneSize, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
v(Unsigned, reservedZoneSize, jscReservedZoneSize, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \
\
v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a crash if we attempt to enter the VM when disallowed") \
v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \
@@ -611,7 +623,7 @@ class OptionRange {
bool init(const char*);
bool isInRange(unsigned);
const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }

void dump(PrintStream& out) const;

private:
@@ -1,3 +1,17 @@
2021-04-08 Khem Raj <raj.khem@gmail.com>

[WPE] Build fixes for musl C library on Linux
https://bugs.webkit.org/show_bug.cgi?id=210068

Reviewed by Carlos Alberto Lopez Perez.

Define 128KB DEFAULT_THREAD_STACK_SIZE_IN_KB for musl
Use OS(LINUX) check to include musl when building for
Linux based platforms.

* wtf/PlatformHave.h:
* wtf/Threading.cpp:

2021-04-08 Chris Dumez <cdumez@apple.com>

OfflineAudioContext objects are leaking
@@ -206,7 +206,7 @@
#define HAVE_HOSTED_CORE_ANIMATION 1
#endif

#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || defined(__GLIBC__) || defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
#define HAVE_MACHINE_CONTEXT 1
#endif

@@ -52,6 +52,8 @@ static Optional<size_t> stackSize(ThreadType threadType)
#elif OS(DARWIN) && ASAN_ENABLED
if (threadType == ThreadType::Compiler)
return 1 * MB; // ASan needs more stack space (especially on Debug builds).
#elif OS(LINUX) && !defined(__BIONIC__) && !defined(__GLIBC__) // MUSL default thread stack size.
return 128 * KB;
#else
UNUSED_PARAM(threadType);
#endif

0 comments on commit 6884d13

Please sign in to comment.