core-agent-ide/patches/v8_source_portability.patch
Channing Conger ded7854f09
V8 Bazel Build (#15021)
Alternative approach, we use rusty_v8 for all platforms that its
predefined, but lets build from source a musl v8 version with bazel for
x86 and aarch64 only. We would need to release this on github and then
use the release.
2026-03-19 18:05:23 -07:00

78 lines
3.2 KiB
Diff

# What: make upstream V8 sources build cleanly in this hermetic toolchain setup.
# Scope: minimal source-level portability fixes only, such as libexecinfo guards,
# weak glibc symbol handling, and warning annotations; no dependency
# include-path rewrites or intentional V8 feature changes.
diff --git a/orig/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc b/mod/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc
index 6176ed4..a02043d 100644
--- a/orig/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc
+++ b/mod/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc
@@ -64,6 +64,7 @@ namespace {
volatile sig_atomic_t in_signal_handler = 0;
bool dump_stack_in_signal_handler = true;
+#if HAVE_EXECINFO_H
// The prefix used for mangled symbols, per the Itanium C++ ABI:
// http://www.codesourcery.com/cxx-abi/abi.html#mangling
const char kMangledSymbolPrefix[] = "_Z";
@@ -73,7 +74,6 @@ const char kMangledSymbolPrefix[] = "_Z";
const char kSymbolCharacters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
-#if HAVE_EXECINFO_H
// Demangles C++ symbols in the given text. Example:
//
// "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]"
diff --git a/orig/v8-14.6.202.11/src/base/platform/platform-posix.cc b/mod/v8-14.6.202.11/src/base/platform/platform-posix.cc
index 4c7d878..0e45eb3 100644
--- a/orig/v8-14.6.202.11/src/base/platform/platform-posix.cc
+++ b/mod/v8-14.6.202.11/src/base/platform/platform-posix.cc
@@ -95,7 +95,7 @@
#endif
#if defined(V8_LIBC_GLIBC)
-extern "C" void* __libc_stack_end;
+extern "C" void* __libc_stack_end V8_WEAK;
#endif
namespace v8 {
@@ -1461,10 +1461,13 @@
// pthread_getattr_np can fail for the main thread.
// For the main thread we prefer using __libc_stack_end (if it exists) since
// it generally provides a tighter limit for CSS.
- return __libc_stack_end;
+ if (__libc_stack_end != nullptr) {
+ return __libc_stack_end;
+ }
#else
return nullptr;
#endif // !defined(V8_LIBC_GLIBC)
+ return nullptr;
}
void* base;
size_t size;
@@ -1476,7 +1479,8 @@
// __libc_stack_end is process global and thus is only valid for
// the main thread. Check whether this is the main thread by checking
// __libc_stack_end is within the thread's stack.
- if ((base <= __libc_stack_end) && (__libc_stack_end <= stack_start)) {
+ if (__libc_stack_end != nullptr &&
+ (base <= __libc_stack_end) && (__libc_stack_end <= stack_start)) {
DCHECK(MainThreadIsCurrentThread());
return __libc_stack_end;
}
diff --git a/orig/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc b/mod/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc
index bda0e43..b44f1d9 100644
--- a/orig/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc
+++ b/mod/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc
@@ -23,7 +23,7 @@ extern int pkey_free(int pkey) V8_WEAK;
namespace {
-bool KernelHasPkruFix() {
+[[maybe_unused]] bool KernelHasPkruFix() {
// PKU was broken on Linux kernels before 5.13 (see
// https://lore.kernel.org/all/20210623121456.399107624@linutronix.de/).
// A fix is also included in the 5.4.182 and 5.10.103 versions ("x86/fpu: