Skip to content

Commit 055fcd8

Browse files
committed
patches on top of bun, scripts to make things more dynamically discoverable on any build machine
1 parent daf4c7e commit 055fcd8

File tree

6 files changed

+109
-0
lines changed

6 files changed

+109
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/webkit/Source/WTF/wtf/android/LoggingAndroid.cpp b/webkit/Source/WTF/wtf/android/LoggingAndroid.cpp
2+
--- a/webkit/Source/WTF/wtf/android/LoggingAndroid.cpp
3+
+++ b/webkit/Source/WTF/wtf/android/LoggingAndroid.cpp
4+
@@ -32,20 +32,15 @@
5+
6+
String logLevelString()
7+
{
8+
- const char* propertyValue = nullptr;
9+
+ constexpr auto propertyName = "debug." LOG_CHANNEL_WEBKIT_SUBSYSTEM ".log";
10+
+ char propertyValue[PROP_VALUE_MAX] { };
11+
+ int length = __system_property_get(propertyName, propertyValue);
12+
13+
- if (const auto* propertyInfo = __system_property_find("debug." LOG_CHANNEL_WEBKIT_SUBSYSTEM ".log")) {
14+
- __system_property_read_callback(propertyInfo, [](void *userData, const char*, const char* value, unsigned) {
15+
- auto **propertyValue = static_cast<const char**>(userData);
16+
- *propertyValue = value;
17+
- }, &propertyValue);
18+
- }
19+
-
20+
// Disable all log channels if the property is unset or empty.
21+
- if (!propertyValue || !*propertyValue)
22+
- return makeString("-all"_s);
23+
+ if (length <= 0)
24+
+ return "-all"_s;
25+
26+
- return String::fromLatin1(propertyValue);
27+
+ return String::fromLatin1(propertyValue);
28+
}
29+
30+
} // namespace WTF
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/webkit/Source/cmake/OptionsCommon.cmake b/webkit/Source/cmake/OptionsCommon.cmake
2+
index ea7d508967d6..b4de9ef50bbf 100644
3+
--- a/webkit/Source/cmake/OptionsCommon.cmake
4+
+++ b/webkit/Source/cmake/OptionsCommon.cmake
5+
@@ -1,7 +1,11 @@
6+
-set(CMAKE_CXX_STANDARD 23)
7+
+set(CMAKE_CXX_STANDARD 20)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
set(CMAKE_CXX_EXTENSIONS OFF)
10+
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP OFF)
11+
+
12+
+# Android builds rely on downstream flags, so keep CMake from adding -O3 automatically.
13+
+set(CMAKE_C_COMPILE_OPTIONS_RELEASE -DNDEBUG CACHE STRING "" FORCE)
14+
+set(CMAKE_CXX_COMPILE_OPTIONS_RELEASE -DNDEBUG CACHE STRING "" FORCE)
15+
16+
add_definitions(-DBUILDING_WITH_CMAKE=1)
17+
add_definitions(-DBUILDING_WEBKIT=1)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/webkit/Source/bmalloc/bmalloc/SystemHeap.cpp b/webkit/Source/bmalloc/bmalloc/SystemHeap.cpp
2+
--- a/webkit/Source/bmalloc/bmalloc/SystemHeap.cpp
3+
+++ b/webkit/Source/bmalloc/bmalloc/SystemHeap.cpp
4+
@@ -210,7 +210,13 @@ void* SystemHeap::malloc(size_t size, FailureAction action)
5+
6+
void* SystemHeap::memalign(size_t alignment, size_t size, FailureAction action)
7+
{
8+
- void* result = ::aligned_alloc(alignment, size);
9+
+ void* result = nullptr;
10+
+#if PAS_OS(ANDROID)
11+
+ if (::posix_memalign(&result, alignment, size))
12+
+ result = nullptr;
13+
+#else
14+
+ result = ::aligned_alloc(alignment, size);
15+
+#endif
16+
RELEASE_BASSERT(action == FailureAction::ReturnNull || result);
17+
return result;
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/webkit/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c b/webkit/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c
2+
--- a/webkit/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c
3+
+++ b/webkit/Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c
4+
@@ -221,9 +221,13 @@ static void dump_thread_diagnostics(pthread_t thread)
5+
#endif
6+
#if PAS_PLATFORM(PLAYSTATION)
7+
getname_result = pthread_get_name_np(thread, thread_name);
8+
+#else
9+
+#if PAS_OS(ANDROID)
10+
+ getname_result = -1;
11+
#else
12+
getname_result = pthread_getname_np(thread, thread_name, sizeof(thread_name));
13+
#endif
14+
+#endif
15+
if (!getname_result)
16+
pas_log("[%d] thread %p has name %s\n", getpid(), (void*)thread, thread_name);
17+
else

scripts/patch.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ JSC_PATCHSET=(
5050

5151
# Avoid ICU formatting dependencies when validating time zones
5252
"jsc_android_timezone_validate.patch"
53+
54+
# Force Android builds to use C++20 and drop toolchain -O3 defaults
55+
"jsc_android_release_flags.patch"
56+
57+
# Avoid pthread_getname_np usage on Android where it's unavailable
58+
"jsc_android_thread_name_guard.patch"
59+
60+
# Use posix_memalign when aligned_alloc is missing on older Android
61+
"jsc_android_systemheap_posix_memalign.patch"
62+
63+
# Use legacy system property getter on older Android
64+
"jsc_android_logging_property.patch"
5365
)
5466

5567
######################################################################################

scripts/start.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ if [[ -z "$ANDROID_NDK" || ! -d "$ANDROID_NDK" ]]; then
1616
export ANDROID_NDK="$DEFAULT_ANDROID_NDK"
1717
fi
1818

19+
if [[ -z "$JAVA_HOME" || ! -x "$JAVA_HOME/bin/java" ]]; then
20+
if [[ "$(uname -s)" == "Darwin" ]]; then
21+
if command -v brew >/dev/null 2>&1; then
22+
HOMEBREW_JAVA_ROOT="$(brew --prefix openjdk@17 2>/dev/null)/libexec/openjdk.jdk/Contents/Home"
23+
if [[ -x "$HOMEBREW_JAVA_ROOT/bin/java" ]]; then
24+
export JAVA_HOME="$HOMEBREW_JAVA_ROOT"
25+
fi
26+
fi
27+
fi
28+
fi
29+
30+
if [[ -n "$JAVA_HOME" && -x "$JAVA_HOME/bin/java" ]]; then
31+
export PATH="$JAVA_HOME/bin:$PATH"
32+
fi
33+
1934
source $ROOTDIR/scripts/env.sh
2035
source $ROOTDIR/scripts/info.sh
2136
export JSC_VERSION=${npm_package_version}

0 commit comments

Comments
 (0)