From 8ec79667c9a785586d53b6f49287cc1f1f60d55d Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 23 Apr 2026 17:25:47 +0200 Subject: [PATCH 1/3] Apply V8_TLS_USED_IN_LIBRARY define to V8 internal_config V8 already declares the `v8_monolithic_for_shared_library` GN arg, but the only place it adds the `V8_TLS_USED_IN_LIBRARY` define is the `:features` config -- which is consumed only by external embedders, not by the `internal_config` that V8's own `.cc` files use. As a result, V8 internal sources (where the `thread_local Isolate*` etc. live) keep their `local-exec` TLS model and emit `R_X86_64_TPOFF32` relocations that fail to link into a downstream cdylib/.so on Linux. Add the same define to `internal_config` under the same arg, and drop the redundant `v8_monolithic &&` part of the existing `:features` condition (the arg already implies its scope). --- ...S_USED_IN_LIBRARY-to-internal_config.patch | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch diff --git a/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch b/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch new file mode 100644 index 00000000000..5fe3ccc8c6a --- /dev/null +++ b/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Kettmeir +Date: Wed, 23 Apr 2026 00:00:00 +0000 +Subject: [PATCH] Apply V8_TLS_USED_IN_LIBRARY to internal_config + +The `v8_monolithic_for_shared_library` GN arg is meant to opt V8 into a +shared-library-safe TLS model so its `thread_local` variables don't emit +`local-exec` relocations (R_X86_64_TPOFF32 against `g_current_isolate_` +etc.) that fail to link into a downstream cdylib. + +It already added the `V8_TLS_USED_IN_LIBRARY` define in `:features`, but +that config is only consumed by external embedders (e.g. rusty_v8's +`rusty_v8_config`) -- it isn't pulled in by `internal_config`, which is +what V8's own `.cc` files use. The TLS variables themselves live in V8 +internal sources (`src/execution/isolate.cc` etc.), so they were never +seeing the define and stayed in `local-exec` mode. + +Fix: add the same define to `internal_config` under the same arg, and +drop the redundant `v8_monolithic &&` part of the existing `:features` +condition (the arg already implies its scope). +--- + BUILD.gn | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/BUILD.gn b/BUILD.gn +index a5c7d847781..75e45b2429b 100644 +--- a/BUILD.gn ++++ b/BUILD.gn +@@ -897,6 +897,14 @@ config("internal_config") { + defines += [ "BUILDING_V8_SHARED" ] + } + ++ # When the resulting V8 archive will be linked into a shared library ++ # downstream (e.g. a cdylib), thread-locals defined in V8 internal sources ++ # must use a TLS model compatible with -fPIC (not "local-exec"). This ++ # define switches them via src/common/thread-local-storage.h. ++ if (v8_monolithic_for_shared_library) { ++ defines += [ "V8_TLS_USED_IN_LIBRARY" ] ++ } ++ + if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { + if (!is_clang) { + libs = [ "atomic" ] +@@ -1229,7 +1237,7 @@ config("features") { + defines += [ "CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS" ] + } + +- if (v8_monolithic && v8_monolithic_for_shared_library) { ++ if (v8_monolithic_for_shared_library) { + defines += [ "V8_TLS_USED_IN_LIBRARY" ] + } + +-- +2.37.3 From c1aa956d32fc902f46c93ae1c60c529c53ea1616 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 23 Apr 2026 17:35:13 +0200 Subject: [PATCH 2/3] Replace bogus patch metadata with real git format-patch output --- ...S_USED_IN_LIBRARY-to-internal_config.patch | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch b/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch index 5fe3ccc8c6a..7e74a23948d 100644 --- a/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch +++ b/patches/0003-Apply-V8_TLS_USED_IN_LIBRARY-to-internal_config.patch @@ -1,22 +1,18 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Leo Kettmeir -Date: Wed, 23 Apr 2026 00:00:00 +0000 -Subject: [PATCH] Apply V8_TLS_USED_IN_LIBRARY to internal_config +From ee882db8c7ac05e1b022d0384fa5dd2ead7178b4 Mon Sep 17 00:00:00 2001 +From: Leo Kettmeir +Date: Thu, 23 Apr 2026 17:31:21 +0200 +Subject: [PATCH] Apply V8_TLS_USED_IN_LIBRARY define to V8 internal_config -The `v8_monolithic_for_shared_library` GN arg is meant to opt V8 into a -shared-library-safe TLS model so its `thread_local` variables don't emit -`local-exec` relocations (R_X86_64_TPOFF32 against `g_current_isolate_` -etc.) that fail to link into a downstream cdylib. +V8 already declares the `v8_monolithic_for_shared_library` GN arg, but +the only place it adds the `V8_TLS_USED_IN_LIBRARY` define is the +`:features` config -- which is consumed only by external embedders, not +by the `internal_config` that V8's own `.cc` files use. As a result, V8 +internal sources (where the `thread_local Isolate*` etc. live) keep +their `local-exec` TLS model and emit `R_X86_64_TPOFF32` relocations +that fail to link into a downstream cdylib/.so on Linux. -It already added the `V8_TLS_USED_IN_LIBRARY` define in `:features`, but -that config is only consumed by external embedders (e.g. rusty_v8's -`rusty_v8_config`) -- it isn't pulled in by `internal_config`, which is -what V8's own `.cc` files use. The TLS variables themselves live in V8 -internal sources (`src/execution/isolate.cc` etc.), so they were never -seeing the define and stayed in `local-exec` mode. - -Fix: add the same define to `internal_config` under the same arg, and -drop the redundant `v8_monolithic &&` part of the existing `:features` +Add the same define to `internal_config` under the same arg, and drop +the redundant `v8_monolithic &&` part of the existing `:features` condition (the arg already implies its scope). --- BUILD.gn | 10 +++++++++- @@ -29,7 +25,7 @@ index a5c7d847781..75e45b2429b 100644 @@ -897,6 +897,14 @@ config("internal_config") { defines += [ "BUILDING_V8_SHARED" ] } - + + # When the resulting V8 archive will be linked into a shared library + # downstream (e.g. a cdylib), thread-locals defined in V8 internal sources + # must use a TLS model compatible with -fPIC (not "local-exec"). This @@ -44,11 +40,12 @@ index a5c7d847781..75e45b2429b 100644 @@ -1229,7 +1237,7 @@ config("features") { defines += [ "CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS" ] } - + - if (v8_monolithic && v8_monolithic_for_shared_library) { + if (v8_monolithic_for_shared_library) { defines += [ "V8_TLS_USED_IN_LIBRARY" ] } + +-- +2.53.0 --- -2.37.3 From 996cb2e8c74dadbd97cd80b72645ae9b1203d911 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Wed, 6 May 2026 14:53:27 +0200 Subject: [PATCH 3/3] add 14.7 to v8_versions --- autoroll.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/autoroll.ts b/autoroll.ts index 300962587f5..b20d0018b1a 100644 --- a/autoroll.ts +++ b/autoroll.ts @@ -1,5 +1,6 @@ const V8_VERSIONS = [ "14.9", + "14.7", ]; const checkVersions = !!Deno.env.get("CHECK_V8_VERSIONS");