51 lines
1.8 KiB
Diff
51 lines
1.8 KiB
Diff
From b9daef67624ac8e2dab0dcf8c82c2f864f76ee6a Mon Sep 17 00:00:00 2001
|
|
From: Ben Noordhuis <info@bnoordhuis.nl>
|
|
Date: Sat, 12 Aug 2017 14:28:06 +0200
|
|
Subject: [PATCH] [wasm] Work around glibc thread-local storage bug
|
|
|
|
glibc before 2.17 has a bug that makes it impossible to execute binaries
|
|
that have single-byte thread-local variables:
|
|
|
|
% node --version
|
|
node: error while loading shared libraries: cannot allocate memory
|
|
in static TLS block
|
|
|
|
Work around that by making the one instance in the V8 code base an int.
|
|
|
|
See: https://sourceware.org/bugzilla/show_bug.cgi?id=14898
|
|
See: https://github.com/nodesource/distributions/issues/513
|
|
See: https://github.com/nodejs/build/pull/809
|
|
Change-Id: Iefd8009100cd93e26cf8dc5dc03f2d622b423385
|
|
---
|
|
|
|
diff --git a/deps/v8/src/trap-handler/handler-shared.cc b/deps/v8/src/trap-handler/handler-shared.cc
|
|
index 7b399f5..242fcba 100644
|
|
--- a/deps/v8/src/trap-handler/handler-shared.cc
|
|
+++ b/deps/v8/src/trap-handler/handler-shared.cc
|
|
@@ -23,7 +23,11 @@
|
|
namespace internal {
|
|
namespace trap_handler {
|
|
|
|
-THREAD_LOCAL bool g_thread_in_wasm_code = false;
|
|
+THREAD_LOCAL int g_thread_in_wasm_code = false;
|
|
+
|
|
+static_assert(sizeof(g_thread_in_wasm_code) > 1,
|
|
+ "sizeof(thread_local_var) must be > 1, see "
|
|
+ "https://sourceware.org/bugzilla/show_bug.cgi?id=14898");
|
|
|
|
size_t gNumCodeObjects = 0;
|
|
CodeProtectionInfoListEntry* gCodeObjects = nullptr;
|
|
diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h
|
|
index 5494c5f..ed94599 100644
|
|
--- a/deps/v8/src/trap-handler/trap-handler.h
|
|
+++ b/deps/v8/src/trap-handler/trap-handler.h
|
|
@@ -65,7 +65,7 @@
|
|
return FLAG_wasm_trap_handler && V8_TRAP_HANDLER_SUPPORTED;
|
|
}
|
|
|
|
-extern THREAD_LOCAL bool g_thread_in_wasm_code;
|
|
+extern THREAD_LOCAL int g_thread_in_wasm_code;
|
|
|
|
inline bool IsThreadInWasm() { return g_thread_in_wasm_code; }
|
|
|