From 8feda0ec5e0fd5b19f417e6af8951426ce9ee73b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 4 Oct 2024 10:31:49 +0200 Subject: [PATCH 1/2] Fix hang in V8 debug builds This is a partial cherry-pick of upstream commit v8/v8@8953e49478. Shows up in debug builds because of a buggy sanity check when computing relationships between command line flags. Example of the hang: #include "v8.h" #include "libplatform/libplatform.h" int main(void) { // works: v8::V8::SetFlagsFromString("--gc-global --noincremental-marking"); v8::V8::SetFlagsFromString("--gc-global"); v8::V8::SetFlagsFromString("--noincremental-marking"); v8::V8::InitializePlatform(v8::platform::NewDefaultPlatform().release()); v8::V8::Initialize(); // hangs in ComputeFlagListHash when defined(DEBUG) } --- libexec/extract-node | 1 + patch/v8-debug-flags-hang.patch | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 patch/v8-debug-flags-hang.patch diff --git a/libexec/extract-node b/libexec/extract-node index 61b5b2a..2fed7c6 100755 --- a/libexec/extract-node +++ b/libexec/extract-node @@ -32,3 +32,4 @@ cd "${src}/node-v${version}" patch -p1 < "${top}"/patch/v8-std-is-trivially-destructible.patch patch -p1 < "${top}"/patch/v8-disable-madv-dontfork.patch patch -p1 < "${top}"/patch/v8-disable-pkey.patch +patch -p1 < "${top}"/patch/v8-debug-flags-hang.patch diff --git a/patch/v8-debug-flags-hang.patch b/patch/v8-debug-flags-hang.patch new file mode 100644 index 0000000..ddfb218 --- /dev/null +++ b/patch/v8-debug-flags-hang.patch @@ -0,0 +1,26 @@ +diff --git a/deps/v8/src/flags/flags-impl.h b/deps/v8/src/flags/flags-impl.h +index d2d440c026..111b9b5b9c 100644 +--- a/deps/v8/src/flags/flags-impl.h ++++ b/deps/v8/src/flags/flags-impl.h +@@ -5,6 +5,8 @@ + #ifndef V8_FLAGS_FLAGS_IMPL_H_ + #define V8_FLAGS_FLAGS_IMPL_H_ + ++#include ++ + #include "src/base/macros.h" + #include "src/base/optional.h" + #include "src/base/vector.h" +@@ -91,9 +93,12 @@ struct Flag { + #ifdef DEBUG + bool ImpliedBy(const void* ptr) const { + const Flag* current = this->implied_by_ptr_; ++ std::unordered_set visited_flags; + while (current != nullptr) { ++ visited_flags.insert(current); + if (current->PointsTo(ptr)) return true; + current = current->implied_by_ptr_; ++ if (visited_flags.contains(current)) break; + } + return false; + } From d8ba248934eb2248d6f6a5805c6c578d885f205f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 4 Oct 2024 10:39:12 +0200 Subject: [PATCH 2/2] Strip symbols in release builds only Words cannot describe the rage one feels when you wait 30 minutes for a debug build to compile, only to find out it's been stripped of actual debug symbols. --- libexec/inject-libv8 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libexec/inject-libv8 b/libexec/inject-libv8 index 2142e1e..11cec84 100755 --- a/libexec/inject-libv8 +++ b/libexec/inject-libv8 @@ -56,7 +56,9 @@ for lib in libv8_monolith.a; do "$AR" "$AREXTRACTFLAGS" "$BASEDIR/out/${BUILDTYPE}/$lib" # strip all objects - "$FIND" -type f -exec "$STRIP" -Sx {} + + if [ "$BUILDTYPE" = "Release" ]; then + "$FIND" -type f -exec "$STRIP" -Sx {} + + fi # rebuild the archive "$FIND" -type f -exec "$AR" "$ARCOLLECTFLAGS" "../$lib" {} +