fix: use real GN arg for linux shared-library TLS mode#1970
Open
crowlKats wants to merge 1 commit into
Open
Conversation
#1911 tried to inject `V8_TLS_USED_IN_LIBRARY` into V8's compilation by writing `extra_cflags=["-DV8_TLS_USED_IN_LIBRARY"]` into args.gn, but `extra_cflags` isn't a declared top-level GN arg anywhere in chromium_build or V8 -- it's only used as an *invoker parameter* inside toolchain definitions in `build/toolchain/gcc_toolchain.gni`. GN silently accepts unknown args, so the define never reached the compiler. V8's thread-locals stayed in `local-exec` TLS model, and linking rusty_v8 into a downstream cdylib failed with: rust-lld: error: relocation R_X86_64_TPOFF32 against v8::internal::g_current_isolate_ cannot be used with -shared You can verify by grepping the generated `gn_out/obj/v8/v8_base_without_compiler.ninja` after a build -- `V8_TLS_USED_IN_LIBRARY` is absent from `defines = ...`. Switch to setting `v8_monolithic_for_shared_library=true`, which is a real declared GN arg in V8's BUILD.gn. The companion denoland/v8 patch (#TBD) wires that arg into `internal_config` so the define actually reaches V8 internal `.cc` files where the TLS variables live.
2 tasks
|
👋 We ran into this issue while trying to link rusty_v8 into a Ruby native extension (cdylib) via |
|
Hello! Is there any chance for this PR to be be merged soon? I have a library for Ruby similar to https://github.com/aglundahl/deno_rider I'd like to publish which depends on it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the shared-library TLS mode injection introduced in #1911 -- the previous implementation wrote
extra_cflags=["-DV8_TLS_USED_IN_LIBRARY"]intoargs.gn, butextra_cflagsis not a declared top-level GN arg anywhere in chromium_build or V8. It's only used as an invoker parameter inside toolchain definitions (build/toolchain/gcc_toolchain.gni:277). GN silently accepts unknown args, so the define never reached the compiler. V8's thread-locals stayed inlocal-execTLS model, and linking rusty_v8 into a downstream cdylib failed with:You can verify on
maintoday: build withV8_FROM_SOURCE=1, then grepgn_out/obj/v8/v8_base_without_compiler.ninja--V8_TLS_USED_IN_LIBRARYis absent from thedefines = ...line, despite being present inargs.gn.Change
Replace the
extra_cflags=[...]injection withv8_monolithic_for_shared_library=true, which is a real declared GN arg in V8'sBUILD.gn:379.Companion change in denoland/v8
This PR alone is not sufficient -- denoland/v8#20 is required to wire
v8_monolithic_for_shared_libraryinto V8'sinternal_configso the define actually reaches V8 internal.ccfiles (where the TLS variables live). Currently the arg only adds the define inside the:featuresconfig, which is consumed only by external embedders, not by V8 itself.This rusty_v8 PR should land after denoland/v8#20 has been picked up by the autoroll into
14.7-lkgr-denolandand the v8 submodule pointer here has been bumped to that commit.Test plan
V8_FROM_SOURCE=1 cargo buildsucceeds for a cdylib downstream (verified locally against Deno'sdenort_desktop).gn_out/obj/v8/v8_base_without_compiler.ninja--V8_TLS_USED_IN_LIBRARYis now indefines = ....