mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 05:43:13 -05:00
This commit is contained in:
parent
20b2989186
commit
d11b720654
7 changed files with 136 additions and 28 deletions
|
@ -1,2 +1,5 @@
|
||||||
[target.aarch64-linux-android]
|
[target.aarch64-linux-android]
|
||||||
linker = "./third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++"
|
linker = "./third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++"
|
||||||
|
|
||||||
|
[target.x86_64-linux-android]
|
||||||
|
linker = "./third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang++"
|
||||||
|
|
41
.github/workflows/ci.yml
vendored
41
.github/workflows/ci.yml
vendored
|
@ -30,42 +30,72 @@ jobs:
|
||||||
- os: macOS-latest
|
- os: macOS-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
variant: debug
|
variant: debug
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: macOS-latest
|
- os: macOS-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
variant: release
|
variant: release
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: macos-14
|
- os: macos-14
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
variant: asan
|
variant: asan
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: macos-14
|
- os: macos-14
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
variant: debug
|
variant: debug
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: macos-14
|
- os: macos-14
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
variant: release
|
variant: release
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
variant: debug
|
variant: debug
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
variant: release
|
variant: release
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2019-xxl' || 'windows-2019' }}
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2019-xxl' || 'windows-2019' }}
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
variant: release # Note: we do not support windows debug builds.
|
variant: release # Note: we do not support windows debug builds.
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
variant: debug
|
variant: debug
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
variant: release
|
variant: release
|
||||||
|
cargo: cargo
|
||||||
|
|
||||||
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
|
target: aarch64-linux-android
|
||||||
|
variant: debug
|
||||||
|
cargo: cross
|
||||||
|
|
||||||
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
|
target: aarch64-linux-android
|
||||||
|
variant: release
|
||||||
|
cargo: cross
|
||||||
|
|
||||||
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
|
target: x86_64-linux-android
|
||||||
|
variant: debug
|
||||||
|
cargo: cross
|
||||||
|
|
||||||
|
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
|
||||||
|
target: x86_64-linux-android
|
||||||
|
variant: release
|
||||||
|
cargo: cross
|
||||||
|
|
||||||
env:
|
env:
|
||||||
V8_FROM_SOURCE: true
|
V8_FROM_SOURCE: true
|
||||||
|
@ -113,6 +143,13 @@ jobs:
|
||||||
- name: Write git_submodule_status.txt
|
- name: Write git_submodule_status.txt
|
||||||
run: git submodule status --recursive > git_submodule_status.txt
|
run: git submodule status --recursive > git_submodule_status.txt
|
||||||
|
|
||||||
|
- name: Install cross and build custom image
|
||||||
|
if: contains(matrix.config.target, 'linux-android')
|
||||||
|
run: |
|
||||||
|
mkdir -p /home/runner/.local/bin
|
||||||
|
curl -qL https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-musl.tar.gz | tar xz -C /home/runner/.local/bin
|
||||||
|
sudo docker build --build-arg CROSS_BASE_IMAGE=ghcr.io/cross-rs/${{ matrix.config.target }}:0.2.5 -t cross-rusty_v8:${{ matrix.config.target }} .
|
||||||
|
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
|
@ -175,12 +212,12 @@ jobs:
|
||||||
SCCACHE_IDLE_TIMEOUT: 0
|
SCCACHE_IDLE_TIMEOUT: 0
|
||||||
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
|
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
|
||||||
run:
|
run:
|
||||||
cargo test -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
|
${{ matrix.config.cargo }} test -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
|
||||||
--target ${{ matrix.config.target }}
|
--target ${{ matrix.config.target }}
|
||||||
|
|
||||||
- name: Clippy
|
- name: Clippy
|
||||||
run:
|
run:
|
||||||
cargo clippy --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
|
${{ matrix.config.cargo }} clippy --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
|
||||||
--target ${{ matrix.config.target }} -- -D clippy::all
|
--target ${{ matrix.config.target }} -- -D clippy::all
|
||||||
|
|
||||||
- name: Rustfmt
|
- name: Rustfmt
|
||||||
|
|
19
Cross.toml
19
Cross.toml
|
@ -1,6 +1,3 @@
|
||||||
[target.aarch64-linux-android]
|
|
||||||
image = "cross:aarch64-linux-android-0.2.1"
|
|
||||||
|
|
||||||
[build.env]
|
[build.env]
|
||||||
passthrough = [
|
passthrough = [
|
||||||
"V8_FROM_SOURCE",
|
"V8_FROM_SOURCE",
|
||||||
|
@ -9,3 +6,19 @@ passthrough = [
|
||||||
"SCCACHE_DIR",
|
"SCCACHE_DIR",
|
||||||
"SCCACHE_IDLE_TIMEOUT"
|
"SCCACHE_IDLE_TIMEOUT"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[target.aarch64-linux-android]
|
||||||
|
image = "cross-rusty_v8:aarch64-linux-android"
|
||||||
|
|
||||||
|
[target.aarch64-linux-android.env]
|
||||||
|
passthrough = [
|
||||||
|
"CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=./third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++"
|
||||||
|
]
|
||||||
|
|
||||||
|
[target.x86_64-linux-android]
|
||||||
|
image = "cross-rusty_v8:x86_64-linux-android"
|
||||||
|
|
||||||
|
[target.x86_64-linux-android.env]
|
||||||
|
passthrough = [
|
||||||
|
"CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=./third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang++"
|
||||||
|
]
|
||||||
|
|
12
Dockerfile
12
Dockerfile
|
@ -1,8 +1,9 @@
|
||||||
FROM rustembedded/cross:aarch64-linux-android-0.2.1
|
ARG CROSS_BASE_IMAGE
|
||||||
|
FROM $CROSS_BASE_IMAGE
|
||||||
|
|
||||||
RUN apt update && \
|
RUN apt update && \
|
||||||
apt install -y curl && \
|
apt install -y curl && \
|
||||||
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | tar xzf -
|
curl -L https://github.com/mozilla/sccache/releases/download/v0.7.7/sccache-v0.7.7-x86_64-unknown-linux-musl.tar.gz | tar xzf -
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
ENV TZ=Etc/UTC
|
||||||
COPY ./build/*.sh /chromium_build/
|
COPY ./build/*.sh /chromium_build/
|
||||||
|
@ -10,11 +11,12 @@ RUN \
|
||||||
DEBIAN_FRONTEND=noninteractive \
|
DEBIAN_FRONTEND=noninteractive \
|
||||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
|
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
|
||||||
&& apt-get update && apt-get install -y lsb-release sudo \
|
&& apt-get update && apt-get install -y lsb-release sudo \
|
||||||
&& /chromium_build/install-build-deps-android.sh \
|
&& sed -i 's/snapcraft/snapcraftnoinstall/g' /chromium_build/install-build-deps.sh \
|
||||||
|
&& /chromium_build/install-build-deps.sh --no-prompt --no-chromeos-fonts \
|
||||||
&& rm -rf /chromium_build \
|
&& rm -rf /chromium_build \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN chmod +x /sccache-v0.2.15-x86_64-unknown-linux-musl/sccache
|
RUN chmod +x /sccache-v0.7.7-x86_64-unknown-linux-musl/sccache
|
||||||
|
|
||||||
ENV SCCACHE=/sccache-v0.2.15-x86_64-unknown-linux-musl/sccache
|
ENV SCCACHE=/sccache-v0.7.7-x86_64-unknown-linux-musl/sccache
|
||||||
ENV SCCACHE_DIR=./target/sccache
|
ENV SCCACHE_DIR=./target/sccache
|
||||||
|
|
|
@ -115,6 +115,15 @@ For Mac builds: You'll need Xcode and Xcode CLT installed. Recent macOS versions
|
||||||
will also require you to pass PYTHON=python3 because macOS no longer ships with
|
will also require you to pass PYTHON=python3 because macOS no longer ships with
|
||||||
`python` simlinked to Python 3.
|
`python` simlinked to Python 3.
|
||||||
|
|
||||||
|
For Android builds: You'll need to cross compile from a x86_64 host to the aarch64 or x64 android. You can use the following commands:
|
||||||
|
```bash
|
||||||
|
rustup target add aarch64-linux-android # or x86_64-linux-android
|
||||||
|
V8_FROM_SOURCE=1 cargo build -vv --target aarch64-linux-android
|
||||||
|
# or with cross
|
||||||
|
docker build --build-arg CROSS_BASE_IMAGE=ghcr.io/cross-rs/aarch64-linux-android:0.2.5 -t cross-rusty_v8:aarch64-linux-android .
|
||||||
|
V8_FROM_SOURCE=1 cross build -vv --target aarch64-linux-android
|
||||||
|
```
|
||||||
|
|
||||||
The build depends on several binary tools: `gn`, `ninja` and `clang`. The tools
|
The build depends on several binary tools: `gn`, `ninja` and `clang`. The tools
|
||||||
will automatically be downloaded, if they are not detected in the environment.
|
will automatically be downloaded, if they are not detected in the environment.
|
||||||
|
|
||||||
|
|
47
build.rs
47
build.rs
|
@ -208,18 +208,51 @@ fn build_v8(is_asan: bool) {
|
||||||
maybe_install_sysroot("amd64");
|
maybe_install_sysroot("amd64");
|
||||||
};
|
};
|
||||||
|
|
||||||
if target_triple == "aarch64-linux-android" {
|
let t_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
gn_args.push(r#"v8_target_cpu="arm64""#.to_string());
|
let t_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
gn_args.push(r#"target_os="android""#.to_string());
|
|
||||||
|
|
||||||
|
if t_os == "android" {
|
||||||
|
let arch = if t_arch == "x86_64" {
|
||||||
|
"x64"
|
||||||
|
} else if t_arch == "aarch64" {
|
||||||
|
"arm64"
|
||||||
|
} else {
|
||||||
|
"unknown"
|
||||||
|
};
|
||||||
|
|
||||||
|
if t_arch == "x86_64" {
|
||||||
|
maybe_install_sysroot("amd64");
|
||||||
|
}
|
||||||
|
|
||||||
|
gn_args.push(format!(r#"v8_target_cpu="{}""#, arch).to_string());
|
||||||
|
gn_args.push(format!(r#"target_cpu="{}""#, arch).to_string());
|
||||||
|
gn_args.push(r#"target_os="android""#.to_string());
|
||||||
gn_args.push("treat_warnings_as_errors=false".to_string());
|
gn_args.push("treat_warnings_as_errors=false".to_string());
|
||||||
|
gn_args.push("use_sysroot=true".to_string());
|
||||||
|
|
||||||
// NDK 23 and above removes libgcc entirely.
|
// NDK 23 and above removes libgcc entirely.
|
||||||
// https://github.com/rust-lang/rust/pull/85806
|
// https://github.com/rust-lang/rust/pull/85806
|
||||||
maybe_clone_repo(
|
if !Path::new("./third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++").exists() {
|
||||||
"./third_party/android_ndk",
|
assert!(Command::new("curl")
|
||||||
"https://github.com/denoland/android_ndk.git",
|
.arg("-L")
|
||||||
);
|
.arg("-o").arg("./third_party/android-ndk-r26c-linux.zip")
|
||||||
|
.arg("https://dl.google.com/android/repository/android-ndk-r26c-linux.zip")
|
||||||
|
.status()
|
||||||
|
.unwrap()
|
||||||
|
.success());
|
||||||
|
|
||||||
|
assert!(Command::new("unzip")
|
||||||
|
.arg("-d").arg("./third_party/")
|
||||||
|
.arg("-o")
|
||||||
|
.arg("-q")
|
||||||
|
.arg("./third_party/android-ndk-r26c-linux.zip")
|
||||||
|
.status()
|
||||||
|
.unwrap()
|
||||||
|
.success());
|
||||||
|
|
||||||
|
fs::rename("./third_party/android-ndk-r26c", "./third_party/android_ndk").unwrap();
|
||||||
|
fs::remove_file("./third_party/android-ndk-r26c-linux.zip").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
static CHROMIUM_URI: &str = "https://chromium.googlesource.com";
|
static CHROMIUM_URI: &str = "https://chromium.googlesource.com";
|
||||||
|
|
||||||
|
|
|
@ -7456,11 +7456,13 @@ fn module_snapshot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(all(target_os = "android", target_arch = "x86_64")))]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct TestHeapLimitState {
|
struct TestHeapLimitState {
|
||||||
near_heap_limit_callback_calls: u64,
|
near_heap_limit_callback_calls: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(all(target_os = "android", target_arch = "x86_64")))]
|
||||||
extern "C" fn heap_limit_callback(
|
extern "C" fn heap_limit_callback(
|
||||||
data: *mut c_void,
|
data: *mut c_void,
|
||||||
current_heap_limit: usize,
|
current_heap_limit: usize,
|
||||||
|
@ -7473,6 +7475,7 @@ extern "C" fn heap_limit_callback(
|
||||||
|
|
||||||
// This test might fail due to a bug in V8. The upstream bug report is at
|
// This test might fail due to a bug in V8. The upstream bug report is at
|
||||||
// https://bugs.chromium.org/p/v8/issues/detail?id=10843.
|
// https://bugs.chromium.org/p/v8/issues/detail?id=10843.
|
||||||
|
#[cfg(not(all(target_os = "android", target_arch = "x86_64")))]
|
||||||
#[test]
|
#[test]
|
||||||
fn heap_limits() {
|
fn heap_limits() {
|
||||||
let _setup_guard = setup::parallel_test();
|
let _setup_guard = setup::parallel_test();
|
||||||
|
@ -7508,6 +7511,8 @@ fn heap_limits() {
|
||||||
assert_eq!(1, test_state.near_heap_limit_callback_calls);
|
assert_eq!(1, test_state.near_heap_limit_callback_calls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same as heap_limits()
|
||||||
|
#[cfg(not(all(target_os = "android", target_arch = "x86_64")))]
|
||||||
#[test]
|
#[test]
|
||||||
fn heap_statistics() {
|
fn heap_statistics() {
|
||||||
let _setup_guard = setup::parallel_test();
|
let _setup_guard = setup::parallel_test();
|
||||||
|
@ -8583,6 +8588,8 @@ fn run_with_rust_allocator() {
|
||||||
assert_eq!(count_loaded, 0);
|
assert_eq!(count_loaded, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same as heap_limits()
|
||||||
|
#[cfg(not(all(target_os = "android", target_arch = "x86_64")))]
|
||||||
#[test]
|
#[test]
|
||||||
fn oom_callback() {
|
fn oom_callback() {
|
||||||
extern "C" fn oom_handler(
|
extern "C" fn oom_handler(
|
||||||
|
@ -9028,6 +9035,7 @@ fn compile_function() {
|
||||||
assert_eq!(42 * 1337, result.int32_value(scope).unwrap());
|
assert_eq!(42 * 1337, result.int32_value(scope).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
static EXAMPLE_STRING: v8::OneByteConst =
|
static EXAMPLE_STRING: v8::OneByteConst =
|
||||||
v8::String::create_external_onebyte_const(b"const static");
|
v8::String::create_external_onebyte_const(b"const static");
|
||||||
|
|
||||||
|
@ -9099,16 +9107,19 @@ fn external_strings() {
|
||||||
assert!(latin1.contains_only_onebyte());
|
assert!(latin1.contains_only_onebyte());
|
||||||
|
|
||||||
// one-byte "const" test
|
// one-byte "const" test
|
||||||
assert_eq!(EXAMPLE_STRING.as_bytes(), b"const static");
|
#[cfg(not(target_os = "android"))]
|
||||||
let const_ref_string =
|
{
|
||||||
v8::String::new_from_onebyte_const(scope, &EXAMPLE_STRING).unwrap();
|
assert_eq!(EXAMPLE_STRING.as_bytes(), b"const static");
|
||||||
assert!(const_ref_string.is_external());
|
let const_ref_string =
|
||||||
assert!(const_ref_string.is_external_onebyte());
|
v8::String::new_from_onebyte_const(scope, &EXAMPLE_STRING).unwrap();
|
||||||
assert!(!const_ref_string.is_external_twobyte());
|
assert!(const_ref_string.is_external());
|
||||||
assert!(const_ref_string.is_onebyte());
|
assert!(const_ref_string.is_external_onebyte());
|
||||||
assert!(const_ref_string.contains_only_onebyte());
|
assert!(!const_ref_string.is_external_twobyte());
|
||||||
assert!(const_ref_string
|
assert!(const_ref_string.is_onebyte());
|
||||||
.strict_equals(v8::String::new(scope, "const static").unwrap().into()));
|
assert!(const_ref_string.contains_only_onebyte());
|
||||||
|
assert!(const_ref_string
|
||||||
|
.strict_equals(v8::String::new(scope, "const static").unwrap().into()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue