Skip to content

Commit

Permalink
Merge pull request denoland#1 from arthurprs/main
Browse files Browse the repository at this point in the history
Add feature flag for not using custom libcxx and link the system libc…
  • Loading branch information
arthurprs authored Mar 14, 2022
2 parents 0c43be2 + 262ce40 commit 7316c73
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,35 @@ jobs:
variant: release
cargo: cargo

- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }}
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }}
target: x86_64-unknown-linux-gnu
variant: debug
cargo: cargo

- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }}
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }}
target: x86_64-unknown-linux-gnu
variant: release
cargo: cargo

- os: windows-2019
target: x86_64-pc-windows-msvc
variant: release # Note: we do not support windows debug builds.
cargo: cargo
# - os: windows-2019
# target: x86_64-pc-windows-msvc
# variant: release # Note: we do not support windows debug builds.
# cargo: cargo

- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }}
target: aarch64-unknown-linux-gnu
variant: debug
cargo: cargo
# - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }}
# target: aarch64-unknown-linux-gnu
# variant: debug
# cargo: cargo

- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }}
target: aarch64-unknown-linux-gnu
variant: release
cargo: cargo
# - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }}
# target: aarch64-unknown-linux-gnu
# variant: release
# cargo: cargo

- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-18.04' }}
target: aarch64-linux-android
variant: release # Note: v8 debug builds on QEMU is buggy.
cargo: cross
# - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-20.04-xl' || 'ubuntu-20.04' }}
# target: aarch64-linux-android
# variant: release # Note: v8 debug builds on QEMU is buggy.
# cargo: cross

env:
V8_FROM_SOURCE: true
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
env:
SCCACHE_IDLE_TIMEOUT: 0
run:
${{ matrix.config.cargo }} test -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
${{ matrix.config.cargo }} test --no-default-features -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
--target ${{ matrix.config.target }}

- name: Clippy
Expand All @@ -203,7 +203,7 @@ jobs:
# https://github.com/softprops/action-gh-release/issues/139
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22
if: >-
github.repository == 'denoland/rusty_v8' &&
github.repository == 'getditto/rusty_v8' &&
startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ exclude = [
"!v8/tools/testrunner/utils/dump_build_config.py",
]

[features]
default = ["use_custom_libcxx"]
use_custom_libcxx = []

[dependencies]
lazy_static = "1.4.0"
libc = "0.2.93"
Expand Down
24 changes: 24 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use which::which;

fn main() {
println!("cargo:rerun-if-changed=src/binding.cc");
println!("cargo:rerun-if-changed=build.rs");

// These are all the environment variables that we check. This is
// probably more than what is needed, but missing an important
Expand Down Expand Up @@ -109,6 +110,10 @@ fn build_v8() {
vec!["is_debug=false".to_string()]
};

if cfg!(not(feature = "use_custom_libcxx")) {
gn_args.push("use_custom_libcxx=false".to_string());
}

if !is_debug() {
gn_args.push("v8_enable_handle_zapping=false".to_string());
}
Expand Down Expand Up @@ -398,6 +403,25 @@ fn download_static_lib_binaries() {
fn print_link_flags() {
println!("cargo:rustc-link-lib=static=rusty_v8");

let should_dyn_link_libcxx = cfg!(not(feature = "use_custom_libcxx"))
|| env::var("GN_ARGS").map_or(false, |gn_args| {
gn_args
.split_whitespace()
.any(|ba| ba == "use_custom_libcxx=false")
});

if should_dyn_link_libcxx {
let target = env::var("TARGET").unwrap();
if target.contains("apple")
|| target.contains("freebsd")
|| target.contains("openbsd")
{
println!("cargo:rustc-link-lib=dylib=c++");
} else if target.contains("linux") {
println!("cargo:rustc-link-lib=dylib=stdc++");
}
}

if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=dylib=winmm");
println!("cargo:rustc-link-lib=dylib=dbghelp");
Expand Down

0 comments on commit 7316c73

Please sign in to comment.