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

Add android runner to run android binaries. #720

Merged
merged 2 commits into from
May 28, 2022

Conversation

Alexhuszagh
Copy link
Contributor

@Alexhuszagh Alexhuszagh commented May 25, 2022

Android binaries currently fail to run linking against certain dependencies, because libc++_shared.so is not found, so ensure the library is preloaded via LD_PRELOAD. This creates a simple android-runner file, so any additional changes can be added there.

This merely links to the proper libc++_shared.so, so it doesn't fix other issues. The hello world project now compiles and runs on aarch64-linux-android, but not i686-linux-android, which seems to be entirely unrelated (likely a permission error on the cloud Fedora server I'm running).

error getting old personality value: Operation not permitted
libc: error getting old personality value: Operation not permitted
Aborted (core dumped)

Linked Issues: #82

@Alexhuszagh Alexhuszagh requested a review from a team as a code owner May 25, 2022 18:53
@Emilgardis
Copy link
Member

would it be possible to add a runner to the ci?

@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented May 25, 2022

would it be possible to add a runner to the ci?

We already have a runner, but I believe to reproduce this error we require the cc dependency. rust-cpp-hello-world fails, but cargo init --bin --name hello . && cross run --target aarch64-linux-android passes.

Should we try to build against a project with a cc dependency in test.sh rather than just against an empty hello world project?

@Emilgardis
Copy link
Member

Emilgardis commented May 25, 2022

we can make a new test repo for it to try on

@Emilgardis
Copy link
Member

bors try --target android

bors bot added a commit that referenced this pull request May 25, 2022
@bors
Copy link
Contributor

bors bot commented May 25, 2022

try

Build succeeded:

Android binaries currently fail to run, because `libc++_shared.so` is
not found, so ensure the library is preloaded via `LD_PRELOAD`. This
creates a simple `android-runner` file, so any additional changes can be
added there.

Linked Issues: cross-rs#82
Add qemu-user runners and C++ support for android, to test that the
LD_PRELOAD works.
@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented May 27, 2022

This should be complete, I'm not sure if we need a 3rd party repository since we already test C++ support. The libc++_shared.so library is well documented, but we could use LD_LIBRARY_PATH instead if required. I think LD_PRELOAD is a better option. We also shouldn't need to provide LD_LIBRARY_PATH for /android-ndk/sysroot/usr/lib/$target/$ndk_version, which contains more complex logic (like vulkan, GLES layers, etc.), but I believe apps requiring this functionality are unlikely to run without a full Android emulator anyway.

Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented May 28, 2022

Build succeeded:

@bors bors bot merged commit e4d429d into cross-rs:main May 28, 2022
@Emilgardis Emilgardis added this to the v0.2.2 milestone Jun 15, 2022
@Alexhuszagh Alexhuszagh deleted the android_runner branch November 6, 2022 16:34
@Alexhuszagh Alexhuszagh added enhancement A-android Area: android targets labels Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-android Area: android targets enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants