-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
x86_64 linker issue #122
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
Builds correctly for me on macOS with NDK v26.0.10792818, so I suspect the NDK is doing nonsensical things again, or you need to update your cargo-ndk. |
@NiallBunting this is an issue with |
Not sure why you closed this, seems other people are having the same issue with different libraries. |
This has nothing to do with cargo-ndk and everything to do with not linking to the correct libraries. |
Ah I think it might actually be caused by this: rust-lang/rust#109717 |
Made some changes to diff --git a/bindings/matrix-sdk-crypto-ffi/build.rs b/bindings/matrix-sdk-crypto-ffi/build.rs
index a3572f17f..39663cab2 100644
--- a/bindings/matrix-sdk-crypto-ffi/build.rs
+++ b/bindings/matrix-sdk-crypto-ffi/build.rs
@@ -18,13 +18,16 @@ fn setup_x86_64_android_workaround() {
"Unsupported OS. You must use either Linux, MacOS or Windows to build the crate."
),
};
- const DEFAULT_CLANG_VERSION: &str = "14.0.7";
+ const DEFAULT_CLANG_VERSION: &str = "17";
+ const DEFAULT_NDK_VERSION: &str = "26.3.11579264";
let clang_version =
env::var("NDK_CLANG_VERSION").unwrap_or_else(|_| DEFAULT_CLANG_VERSION.to_owned());
+ let ndk_version =
+ env::var("NDK_VERSION").unwrap_or_else(|_| DEFAULT_NDK_VERSION.to_owned());
let linux_x86_64_lib_dir = format!(
- "toolchains/llvm/prebuilt/{build_os}-x86_64/lib64/clang/{clang_version}/lib/linux/"
+ "toolchains/llvm/prebuilt/{build_os}-x86_64/lib/clang/{clang_version}/lib/linux/"
);
- println!("cargo:rustc-link-search={android_ndk_home}/{linux_x86_64_lib_dir}");
+ println!("cargo:rustc-link-search={android_ndk_home}/{ndk_version}/{linux_x86_64_lib_dir}");
println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android");
}
}
diff --git a/bindings/matrix-sdk-ffi/build.rs b/bindings/matrix-sdk-ffi/build.rs
index e22f54451..217b28750 100644
--- a/bindings/matrix-sdk-ffi/build.rs
+++ b/bindings/matrix-sdk-ffi/build.rs
@@ -18,13 +18,16 @@ fn setup_x86_64_android_workaround() {
"Unsupported OS. You must use either Linux, MacOS or Windows to build the crate."
),
};
- const DEFAULT_CLANG_VERSION: &str = "14.0.7";
+ const DEFAULT_CLANG_VERSION: &str = "17";
+ const DEFAULT_NDK_VERSION: &str = "26.3.11579264";
let clang_version =
env::var("NDK_CLANG_VERSION").unwrap_or_else(|_| DEFAULT_CLANG_VERSION.to_owned());
+ let ndk_version =
+ env::var("NDK_VERSION").unwrap_or_else(|_| DEFAULT_NDK_VERSION.to_owned());
let linux_x86_64_lib_dir = format!(
- "toolchains/llvm/prebuilt/{build_os}-x86_64/lib64/clang/{clang_version}/lib/linux/"
+ "toolchains/llvm/prebuilt/{build_os}-x86_64/lib/clang/{clang_version}/lib/linux/"
);
- println!("cargo:rustc-link-search={android_ndk_home}/{linux_x86_64_lib_dir}");
+ println!("cargo:rustc-link-search={android_ndk_home}/{ndk_version}/{linux_x86_64_lib_dir}");
println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android");
}
} |
I'm running the command:
cargo ndk -o ./android -t armeabi-v7a -t x86_64 build
The armeabi builds correctly but I run into a linker issue with the x86_64 build.
Completing with
= note: ld.lld: error: unable to find library -lclang_rt.builtins-x86_64-android clang-17: error: linker command failed with exit code 1 (use -v to see invocation)
The full output is here: https://pastebin.com/sgbyYEUh
I checked NDK to see if that builtin exists and it seems to be here:
/home/nib/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/lib/linux/libclang_rt.builtins-x86_64-android.a
.Also ensured that rustup was correct:
nib@nib-desktop:~/repos/matrix-rust-sdk/bindings/matrix-sdk-ffi$ rustup target install x86_64-linux-android info: component 'rust-std' for target 'x86_64-linux-android' is up to date
.The text was updated successfully, but these errors were encountered: