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

Fix building on Android #112

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

saruman9
Copy link

@saruman9 saruman9 commented Oct 4, 2023

This PR contains several workarounds in order to be able to use the crate for Android. Some of them look quite messy, but unfortunately I couldn't find a way to do it better.

For NDK versions 25 and higher, it is also necessary to create a symbolic link to ar, since there is no longer the ability to set custom ar in Rust (cargo config, codegen options):

$ ln -s ./llvm-ar $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-ar
$ ln -s ./llvm-ar $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar

If someone knows how to solve this, then I will add it to the PR.

Copy link
Contributor

@s1341 s1341 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

You're right that some of this is quite ugly, especially the requirement to symlink ar. Surely there is a better solution?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this file get respected when frida-rust is used as a library, or only when running cargo build from this directory?

Copy link
Author

Choose a reason for hiding this comment

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

Only for local building and building of examples. In the case of using the crate as a library, an user must take care of creating this file in his own crate.

@saruman9
Copy link
Author

saruman9 commented Oct 5, 2023

Surely there is a better solution?

To be honest, I'm not sure, I tried to do it as much as possible without the user's involvement, but this is impossible, because in addition to having to create symbolic links, you still have to set environment variables for Android.

FYI rust-lang/cargo#12183 (comment)

@meme
Copy link
Collaborator

meme commented Oct 11, 2023

Symlinks are a no-go because they don't function correctly under Windows. Honestly, I'm not clear on why it's needed at all because we have the frida-build crate which is around to provide shared code for build.rs. Can we use that instead please? Thanks.

@saruman9
Copy link
Author

Unfortunately, I did not find any way to set the path to ar (the Rust developers removed this feature), including via build.rs or Cargo config file. And anyway: making changes to Android NDK by Frida --- is wrong. An user himself must understand what he/she is doing, what he/she is making changes to the files already installed on his/her system.

These changes (including symlinks) are only necessary to build and run examples or libraries and executables that will include Frida as a dependency:

I can delete them, nothing will change from this except that the examples will no longer be built for Android platform. I added these changes so that an user would have an example of how and what to do to build Frida as a dependency for his/her Android project, but unfortunately I still run into a problem with ar.

Once again, I did not find another way to set the path to ar, so I had to modify the files as part of Android NDK. If someone knows the solution, then I would be happy to add it to the PR!

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.

3 participants