-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
saruman9
wants to merge
4
commits into
frida:main
Choose a base branch
from
saruman9:fix_android_building
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6792215
fix(gum-sys): set a sysroot if target_os is Andorid
saruman9 e1a32a3
fix(gum-sys): make `g_object_unref` visible for Android
saruman9 45d4dc4
feat(cargo): add default linkers (NDK r26) for {x86_64,aarch64}-linux…
saruman9 99db3e6
fix(examples): add workaround for building on Android
saruman9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[target.x86_64-linux-android] | ||
linker = "x86_64-linux-android26-clang" | ||
|
||
[target.aarch64-linux-android] | ||
linker = "aarch64-linux-android26-clang" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::env; | ||
|
||
/// Adds a temporary workaround for an issue with the Rust compiler and Android | ||
/// in x86_64/aarch64 devices: https://github.com/rust-lang/rust/issues/109717. | ||
/// The workaround comes from: https://github.com/mozilla/application-services/pull/5442 | ||
fn setup_android_workaround() { | ||
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set"); | ||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set"); | ||
if (target_arch == "x86_64" || target_arch == "aarch64") && target_os == "android" { | ||
let android_ndk_home = env::var("ANDROID_NDK_HOME").expect("ANDROID_NDK_HOME not set"); | ||
let build_os = match env::consts::OS { | ||
"linux" => "linux", | ||
"macos" => "darwin", | ||
"windows" => "windows", | ||
_ => panic!( | ||
"Unsupported OS. You must use either Linux, MacOS or Windows to build the crate." | ||
), | ||
}; | ||
// NDK r25c | ||
const DEFAULT_CLANG_VERSION: &str = "14.0.7"; | ||
let clang_version = | ||
env::var("NDK_CLANG_VERSION").unwrap_or_else(|_| DEFAULT_CLANG_VERSION.to_owned()); | ||
// Another workaround for NDK r26 | ||
let lib_path = if clang_version == "17" { | ||
"lib" | ||
} else { | ||
"lib64" | ||
}; | ||
let linux_x86_64_lib_dir = format!( | ||
"toolchains/llvm/prebuilt/{build_os}-x86_64/{lib_path}/clang/{clang_version}/lib/linux/" | ||
); | ||
println!("cargo:rustc-link-search={android_ndk_home}/{linux_x86_64_lib_dir}"); | ||
println!("cargo:rustc-link-lib=static=clang_rt.builtins-{target_arch}-android"); | ||
} | ||
} | ||
|
||
fn main() { | ||
setup_android_workaround(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.