Skip to content

Commit f89c4e3

Browse files
committed
fix: enable linux shared-library-safe v8 tls mode by default
1 parent 19b5ecf commit f89c4e3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ is recommended.
157157
Arguments can be passed to `gn` by setting the `$GN_ARGS` environmental
158158
variable.
159159

160+
For Linux targets, `rusty_v8` now defaults to defining
161+
`V8_TLS_USED_IN_LIBRARY` via GN args when building from source so the produced
162+
static archive can be linked into downstream `cdylib`/shared-library targets.
163+
The default injected argument is:
164+
165+
```bash
166+
GN_ARGS='extra_cflags=["-DV8_TLS_USED_IN_LIBRARY"]'
167+
```
168+
169+
Linux prebuilt release archives published by this repository are built with
170+
this shared-library-compatible TLS mode.
171+
160172
Env vars used in when building from source: `SCCACHE`, `CCACHE`, `GN`, `NINJA`,
161173
`CLANG_BASE_PATH`, `GN_ARGS`
162174

build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,20 @@ fn build_v8(is_asan: bool) {
346346
println!("cargo:warning=Not using sccache or ccache");
347347
}
348348

349+
// Use the shared-library-safe TLS mode by default on Linux so downstream
350+
// cdylibs can link rusty_v8 archives.
351+
let mut has_tls_library_mode_define = false;
349352
if let Ok(args) = env::var("GN_ARGS") {
350353
for arg in args.split_whitespace() {
354+
if arg.contains("V8_TLS_USED_IN_LIBRARY") {
355+
has_tls_library_mode_define = true;
356+
}
351357
gn_args.push(arg.to_string());
352358
}
353359
}
360+
if target_os == "linux" && !has_tls_library_mode_define {
361+
gn_args.push(r#"extra_cflags=["-DV8_TLS_USED_IN_LIBRARY"]"#.to_string());
362+
}
354363
// cross-compilation setup
355364
if target_arch == "aarch64" {
356365
gn_args.push(r#"target_cpu="arm64""#.to_string());

0 commit comments

Comments
 (0)