Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android support 64 bit #270

Closed
wants to merge 1 commit into from
Closed

android support 64 bit #270

wants to merge 1 commit into from

Conversation

90dy
Copy link

@90dy 90dy commented Feb 9, 2020

see https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md
ref denoland/deno#3839

Successful build on aarch-linux-android and x86_64-linux-android 🙌
Other arch (arm and i686) are not currently available

How to

Clone the repo

git clone git@github.com:denoland/rusty_v8 ./rusty_v8
cd ./rusty_v8
git submodule update --init --recursive

Install cross

cargo install cross

Build aarch64

docker build --target aarch64-linux-android --tag denoland/rusty_v8:aarch64-linux-android .
V8_FROM_SOURCE=1 cross build -vv --target aarch64-linux-android

Build x86_64

docker build --target x86_64-linux-android --tag denoland/rusty_v8:x86_64-linux-android .
V8_FROM_SOURCE=1 cross build -vv --target x86_64-linux-android

@90dy
Copy link
Author

90dy commented Feb 10, 2020

I need to use sysroot from $ANDROID_NDK_HOME/sysroot for all android builds
It seems the pr #266 have some update about sysroot builds, I will rebase on its branch to continue

@90dy 90dy force-pushed the android_support branch 5 times, most recently from 5faa334 to b3cd171 Compare February 19, 2020 22:11
@90dy
Copy link
Author

90dy commented Feb 19, 2020

It seems I have a panic in cargo-gn, I'll investigate it

EDIT 1:
On my mac, GN overrides is_mac to be true when building for android target (with target_os="android") and set this two arguments below that cause to fail the build. I'm trying to understand which BUILD.gn overrides it. (see also denoland/chromium_build#3)

clang80++: error: unknown argument: '-fvisibility-global-new-delete-hidden'
clang80++: error: unknown argument: '-ftrivial-auto-var-init=pattern'

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@90dy 90dy force-pushed the android_support branch from 9969a19 to 16bb6b6 Compare March 21, 2020 13:24
@90dy 90dy force-pushed the android_support branch 6 times, most recently from aa17a18 to ae5169f Compare April 1, 2020 17:16
@90dy
Copy link
Author

90dy commented Apr 2, 2020

After digging a lot, and lost a lot of time, I will try to setup v8 from scratch directly with depot_tools to avoid the current configuration that could cause failures and use cargo_gn to build it.
I'll continue to send updates here 👍
see 90dy#1

@90dy 90dy force-pushed the android_support branch from ae5169f to ad12ea1 Compare April 2, 2020 17:36
@90dy
Copy link
Author

90dy commented Apr 3, 2020

After digging today with depot_tools, I start to understand why you choose to use chromium like deps tree since lot of deps doesn't use //v8 path (exemple: libc++ with visibility on //buildtools and not //v8/buildtools).
So it's impossible to use v8 as a gn deps without integrate its dependenicies to the root directory.
An easier solution than current configuration could be to directly fork v8 and/or pull changes from his upstream and use gclient to sync its deps directly.
I will fallback on this branch and retry to make it work.

@90dy 90dy force-pushed the android_support branch 6 times, most recently from beac9e8 to f62a68c Compare April 4, 2020 13:46
@90dy 90dy changed the title wip: android support android support Apr 4, 2020
@ry
Copy link
Member

ry commented Apr 4, 2020

Awesome that you got this working.

@90dy 90dy force-pushed the android_support branch 2 times, most recently from 7129d1a to f64e60f Compare April 4, 2020 15:10
@90dy
Copy link
Author

90dy commented Sep 14, 2020

Hello. Any thoughts on where to go with this ticket?

Hello ! Don't have so much time but I'll give it a try this week (or week end), I want it done too :)

@90dy 90dy force-pushed the android_support branch 8 times, most recently from 45cd23c to 460fa61 Compare September 15, 2020 14:43
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
@90dy
Copy link
Author

90dy commented Sep 16, 2020

Builds are successful but tests fail after handle_scope_param_and_context_must_share_isolate

test handle_scope_param_and_context_must_share_isolate ... ok
libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 8981 (V8 DefaultWorke)
libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 8982 (V8 DefaultWorke)
libc: Unable to open connection to debuggerd: Connection refused
libc: Unable to open connection to debuggerd: Connection refused
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
error: test failed, to rerun pass '--test test_api'

Caused by:
  process didn't exit successfully: `qemu-aarch64 /target/aarch64-linux-android/debug/deps/test_api-b6a7e339767bcaf1` (signal: 11, SIGSEGV: invalid memory reference)
test heap_limits ... 

@piscisaureus
Copy link
Member

Hello. Any thoughts on where to go with this ticket?

We want to support android.
The challenge is to build/test in a reasonable amount of time.

@90dy
Copy link
Author

90dy commented Sep 16, 2020

Okay 👍

@rektide
Copy link

rektide commented Jan 26, 2021

for anyone who might consider trying to hack on this, may be interesting to check out #589 to see what can be gained. my uneducated personal suspicion is that aarch64-unknown-linux and aarch64-android-linux are very different but perhaps some techniques can be borrowed.

Base automatically changed from master to main February 14, 2021 15:15
@gcxfd
Copy link

gcxfd commented May 12, 2021

run V8_FROM_SOURCE=1 cross build -vv --target aarch64-linux-android

get this error


     Running `CARGO=/rust/bin/cargo CARGO_CRATE_NAME=rusty_v8 CARGO_MANIFEST_DIR=/project CARGO_PKG_AUTHORS='the Deno authors' CARGO_PKG_DESCRIPTION='Rust bindings to V8' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=rusty_v8 CARGO_PKG_REPOSITORY='https://github.com/denoland/rusty_v8' CARGO_PKG_VERSION=0.22.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=22 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/target/debug/deps:/rust/lib' OUT_DIR=/target/aarch64-linux-android/debug/build/rusty_v8-8e7a016a8aa01878/out rustc --crate-name rusty_v8 --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=596c3da87292c38b -C extra-filename=-596c3da87292c38b --out-dir /target/aarch64-linux-android/debug/deps --target aarch64-linux-android -C linker=aarch64-linux-android-gcc -C incremental=/target/aarch64-linux-android/debug/incremental -L dependency=/target/aarch64-linux-android/debug/deps -L dependency=/target/debug/deps --extern bitflags=/target/aarch64-linux-android/debug/deps/libbitflags-a80620455f69555c.rmeta --extern lazy_static=/target/aarch64-linux-android/debug/deps/liblazy_static-34ba37aa1ecf29c5.rmeta --extern libc=/target/aarch64-linux-android/debug/deps/liblibc-f2e221155d40d661.rmeta -L /target/aarch64-linux-android/debug/gn_out/obj -l static=rusty_v8`
error: failed to add native library /target/aarch64-linux-android/debug/gn_out/obj/librusty_v8.a: file too small to be an archive

error: aborting due to previous error

error: could not compile `rusty_v8`

Caused by:
  process didn't exit successfully: `CARGO=/rust/bin/cargo CARGO_CRATE_NAME=rusty_v8 CARGO_MANIFEST_DIR=/project CARGO_PKG_AUTHORS='the Deno authors' CARGO_PKG_DESCRIPTION='Rust bindings to V8' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=rusty_v8 CARGO_PKG_REPOSITORY='https://github.com/denoland/rusty_v8' CARGO_PKG_VERSION=0.22.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=22 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/target/debug/deps:/rust/lib' OUT_DIR=/target/aarch64-linux-android/debug/build/rusty_v8-8e7a016a8aa01878/out rustc --crate-name rusty_v8 --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=596c3da87292c38b -C extra-filename=-596c3da87292c38b --out-dir /target/aarch64-linux-android/debug/deps --target aarch64-linux-android -C linker=aarch64-linux-android-gcc -C incremental=/target/aarch64-linux-android/debug/incremental -L dependency=/target/aarch64-linux-android/debug/deps -L dependency=/target/debug/deps --extern bitflags=/target/aarch64-linux-android/debug/deps/libbitflags-a80620455f69555c.rmeta --extern lazy_static=/target/aarch64-linux-android/debug/deps/liblazy_static-34ba37aa1ecf29c5.rmeta --extern libc=/target/aarch64-linux-android/debug/deps/liblibc-f2e221155d40d661.rmeta -L /target/aarch64-linux-android/debug/gn_out/obj -l static=rusty_v8` (exit status: 1)

image

@gcxfd
Copy link

gcxfd commented May 14, 2021

i see a project https://github.com/NativeScript/android-v8

@ry
Copy link
Member

ry commented Aug 4, 2021

This PR is very old. We would like to support Android - but we need to build and test (emulated) in a reasonable amount of time. The diffs provided here will help us in the future when we attempt to undertake this feature. But for now, I am closing this because it is not mergeable.

Thank you @90dy

@ry ry closed this Aug 4, 2021
@90dy
Copy link
Author

90dy commented Aug 4, 2021

Yes, no problem. Sorry to not having time to finish this. And hope I can help you later ✌️

@littledivy
Copy link
Member

Builds are successful but tests fail after handle_scope_param_and_context_must_share_isolate

test handle_scope_param_and_context_must_share_isolate ... ok
libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 8981 (V8 DefaultWorke)
libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 8982 (V8 DefaultWorke)
libc: Unable to open connection to debuggerd: Connection refused
libc: Unable to open connection to debuggerd: Connection refused
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
error: test failed, to rerun pass '--test test_api'

Caused by:
  process didn't exit successfully: `qemu-aarch64 /target/aarch64-linux-android/debug/deps/test_api-b6a7e339767bcaf1` (signal: 11, SIGSEGV: invalid memory reference)
test heap_limits ... 

FYI this is most likely to be a QEMU bug. I am able to run all the tests perfectly fine on real device (Redmi 8 Android 11) :

$ adb push target/release/aarch64-linux-android/debug/deps/test_concurrent_isolate_creation_and_disposal-066cb67cbf6c4e80 /data/local/tmp/rusty_v8_test
$ adb shell /data/local/tmp/rusty_v8_test

running 1 test
test concurrent_isolate_creation_and_disposal ... ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants