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 support for arm-unknown-linux-musleabi #48

Merged
merged 9 commits into from
Aug 8, 2021
Merged

Conversation

imlk0
Copy link
Collaborator

@imlk0 imlk0 commented Aug 5, 2021

The changes included in this PR are intended to add support for the arm-unknown-linux-musleabi target to proot-rs.

The main changes are:

  • Add conditional compilation statements for different architectures due to differences in system calls.
  • Add missing parts for loader.c.
  • ptrace(): added support for reading and writing register sets on arm target.
  • Some additional fixes such as changes to the types of some variables.

@imlk0 imlk0 self-assigned this Aug 5, 2021
@imlk0 imlk0 added this to the v0.0.1 milestone Aug 5, 2021
@imlk0 imlk0 requested a review from oxr463 August 5, 2021 02:37
Copy link
Contributor

@oxr463 oxr463 left a comment

Choose a reason for hiding this comment

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

How can I build for android? I ran cargo build like usual, but it still created an x86_64 binary:

file ./target/debug/proot-rs
./target/debug/proot-rs: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped

@imlk0
Copy link
Collaborator Author

imlk0 commented Aug 5, 2021

How can I build for android? I ran cargo build like usual, but it still created an x86_64 binary:

file ./target/debug/proot-rs
./target/debug/proot-rs: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped

For building for android, I basically followed the steps here:
https://blog.rust-lang.org/2016/05/13/rustup.html#example-running-rust-on-android

Unlike other Linux targets, to build for android you need to first download the NDK and unzip it somewhere. And then edit .cargo/config.toml and add something like the following. (We don't need make-standalone-toolchain.sh anymore, google says this has been deprecated)

[target.arm-linux-androideabi]
linker = "<path-to-ndk-dir>/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi18-clang"

The next steps are the same as for the other targets.
First add target arm-linux-androideabi to current rust toolchain:

rustup target add arm-linux-androideabi

Then specify the target we need to build for and start building

cargo build --target=arm-linux-androideabi

Unfortunately, it is not yet possible to successfully build proot-rs for android (the target arm-linux-androideabi). loader.c is one of the problem, and I am trying to solve it.

But for now we can build to the arm-unknown-linux-musleabi target, with the following commands:

rustup target add arm-unknown-linux-musleabi
cargo build --target=arm-unknown-linux-musleabi

The output will be located at target/arm-unknown-linux-musleabi/debug/proot-rs

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

Successfully merging this pull request may close these issues.

2 participants