-
Notifications
You must be signed in to change notification settings - Fork 75
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
note: ld: error: unable to find library -lgcc #75
Comments
it seems it was fixed with this PR rust-lang/rust#85806 however, it doesn't seem to work for me. I'm running
|
@sonwh98 thanks for the report. I'm sorry that I haven't much to advise: it looks like you're running into a Rust-specific issue with the very modern NDK version you're trying to use, and not something to do with If you do get to the bottom of this, please let us know what's going on in this ticket! |
@ncalexan I think there maybe a problem with calling the script make_standalone_toolchain.py This script is obsolete according to this document. |
Indeed. And I see that the pre-built toolchains are not yet default: https://github.com/mozilla/rust-android-gradle#prebuilttoolchains. Could you try with the pre-built toolchains and see if this is still an issue? We might mutate this ticket to be "make pre-built the default". |
@ncalexan actually args.remove("-lgcc")
args.append("/home/sto/android/ndk/22.1.7171670/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/libgcc.a") published this plugin locally with then rebuild my project with then tested it with sto@big:~/workspace/gossipy$ adb push ./app/src/main/rust/target/armv7-linux-androideabi/debug/hello-rust /data/local/tmp
./app/src/main/rust/target/armv7-linux-androideabi/debug/hello-rust: 1 file pushed, 0 skipped. 250.7 MB/s (3264536 bytes in 0.012s)
sto@big:~/workspace/gossipy$ adb shell /data/local/tmp/hello-rust
Hello, rust world!
is there a better way to do this? the plugin should have a way of including static libraries there should also be an option to change the linker-wrapper.py to not link -lgcc and use static version instead |
It's not a good idea to allow monkeying with those arguments (any more than we do in |
@ncalexan
linker-wrapper.py is called from linker-wrapper.sh . Is there a way the plugin allows me to over ride -C linker with my own custom shell script? |
No, I don't think we have a method to change the linker wrapper. In fact, we'd like to remove it: see #49, IIRC. Again: don't solve this by monkeying with these plugin details. Fix the problem at the right level, which is teaching |
I am new to Rust and Cargo. Can you give some guidance? It seems libgcc is a required dependency and its linked as a shared library but since the latest NDK has stop distributing libgcc linking it as a shared library will fail. libgcc.a from an previous version of NDK should be used to statically link to satisfy rust dependency. The logic is Or remove libgcc as a dependency in Rust. Why is Rust dependent on gcc? it can't be built using LLVM? |
This could be challenging to address. If you look at the Rust patch, it's actually patching one of the build scripts: rust-lang/rust@965997b. The first thing to do is to dig into the build failures you're seeing and figure out which build scripts is injecting the Can you share the underlying Rust project? I may be able to help you track down what's asking for |
@ncalexan https://github.com/sonwh98/gossipy/tree/master/app/src/main/rust its just a simple hello world just to test thanks for any help! |
Yeah, no dependencies at all! Isn't the question then: why not use an NDK that Rust supports? Can you set |
yes its possible. I am just experimenting . I have a solution by hacking the python script if i need to use the latest NDK. However, Rust should work with the latest NDK. Rust is an official supported language for developing android right? |
What does that even mean? Google (or AOSP) gives no support for building Android applications that I am aware of. Rust does support targeting Android, but the You're at the bleeding edge and bleeding. I suggest you move back from the edge. In any case, there is no indication that this is a |
https://source.android.com/setup/build/rust/building-rust-modules/overview |
TIL! All very new, and very cool. |
@ncalexan can this plugin support modern NDK version (e.g. 23r version)? |
@mercurydaihui no. the most recently supported NDK is 22.1.7171670 with NDK 23 and greater, libgcc has to be statically linked because libgcc has been removed from NDK 23. if you must use NDK 23+, see my work around by hacking the python script #75 (comment) . Its not recommended but it worked for me |
I am just trying to get a simple hello world to compile with gradle. there's no linking with java
but running
gradle cargoBuild
results in
note: ld: error: unable to find library -lgcc
Cargo.toml
app/build.gradle
My output-bin-hello-rust
The text was updated successfully, but these errors were encountered: