Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ is recommended.
Arguments can be passed to `gn` by setting the `$GN_ARGS` environmental
variable.

For Linux targets, `rusty_v8` now defaults to defining
`V8_TLS_USED_IN_LIBRARY` via GN args when building from source so the produced
static archive can be linked into downstream `cdylib`/shared-library targets.
The default injected argument is:

```bash
GN_ARGS='extra_cflags=["-DV8_TLS_USED_IN_LIBRARY"]'
```

Linux prebuilt release archives published by this repository are built with
this shared-library-compatible TLS mode.

Env vars used in when building from source: `SCCACHE`, `CCACHE`, `GN`, `NINJA`,
`CLANG_BASE_PATH`, `GN_ARGS`

Expand Down
16 changes: 12 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,18 @@ fn build_v8(is_asan: bool) {
println!("cargo:warning=Not using sccache or ccache");
}

if let Ok(args) = env::var("GN_ARGS") {
for arg in args.split_whitespace() {
gn_args.push(arg.to_string());
}
// Use the shared-library-safe TLS mode by default on Linux so downstream
// cdylibs can link rusty_v8 archives.
let mut has_tls_library_mode_define = false;
if let Ok(raw_gn_args) = env::var("GN_ARGS")
&& !raw_gn_args.trim().is_empty()
{
has_tls_library_mode_define =
raw_gn_args.contains("V8_TLS_USED_IN_LIBRARY");
gn_args.push(raw_gn_args);
}
if target_os == "linux" && !has_tls_library_mode_define {
gn_args.push(r#"extra_cflags=["-DV8_TLS_USED_IN_LIBRARY"]"#.to_string());
}
// cross-compilation setup
if target_arch == "aarch64" {
Expand Down
Loading