-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
no_mangle causes compilation errors with async-await on armv7-linux-androideabi and aarch64-linux-android targets #70098
Comments
Hi @jonas-schievink, Not sure if this is minimal enough, but I've created a repo to demonstrate the issue at https://github.com/jeswin/rust-lang-issue-70098-mcve Please note that build.sh requires cargo-ndk to build. |
@rustbot ping llvm |
Hey LLVM ICE-breakers! This bug has been identified as a good cc @comex @cuviper @DutchGhost @hanna-kruppe @hdhoang @heyrutvik @JOE1994 @jryans @mmilenko @nagisa @nikic @Noah-Kennedy @SiavoshZarrasvand @spastorino @vertexclique @vgxbj |
@rustbot ping cleanup |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke |
If it's of any use, I tested it with rustc 1.39 and got the same error. I'll be happy to help in any way - should you require. |
Using the repository @jonas-schievink provided, I couldn't reproduce the bug. I'm building on a MacOS Catalina 10.15.3 and I tried Rust stable ( |
Hi @woshilapin, sorry I forgot to mention - my build environment was Linux 64-bit; Ubuntu 19.10 specifically. I can try to reproduce the bug on a fresh Linux install. |
@woshilapin Could you also post the llvm and ndk versions you were able to use successfully? |
Not sure of what I'll provide but if I remember correctly, version of LLVM would be the same as version of
For NDK, I downloaded it testing the current issue so it's pretty recent. I have a
Please tell me if some other information is needed (and how to get them maybe since I'm not an Android developer so I have no background!). |
@woshilapin I was able to reproduce the issue on a fresh install of Ubuntu 19.10 64-bit. My ndk version is the same as yours - 21.0.6113669. I think ndk uses (at least on Linux) clang and llvm bundled and prebuilt with the ndk. For me, it gets installed at ~/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin. The clang --version (from the directory above) is
So there seems to be a problem with compilation on Linux. I'll proceed with testing it on my ancient Macbook. |
@woshilapin I was able to compile it successfully on OSX. So the problem occurs only on Linux. |
I'm experiencing this same issue with a custom, {
"arch": "arm",
"cpu": "arm926ej-s",
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
"llvm-target": "armv5te-none-eabi",
"os": "newlib",
"relocation-model": "pic",
"target-endian": "little",
"target-env": "newlib",
"target-pointer-width": "32",
"target-c-int-width": "32",
"linker": "nspire-gcc",
"linker-flavor": "gcc",
"dynamic-linking": false,
"executables": true,
"features": "+v5te,+soft-float,+strict-align",
"singlethread": true
} Running Arch Linux 5.5.10-arch1-1 and rustc 1.44.0-nightly (7520894 2020-03-27). Here's a sample source: #[no_mangle]
fn main() {
doesnt_work();
does_work();
}
fn doesnt_work() {
Executor::new().run(Task::new(do_stuff()));
}
fn does_work() {
Executor::new().run(Task::new(do_more_stuff()));
}
async fn do_stuff() -> &'static str {
do_more_stuff().await
}
async fn do_more_stuff() -> &'static str {
"test"
} (I'll post the code of the custom types if needed, mostly stolen from this recent blog post) Interestingly enough, the function
Edit: this error does not occur with this test case when changing to an async fn do_more_stuff() -> i32 {
5
} |
@lights0123 the problem in that case might be applying fn main() {
main1();
}
#[no_mangle]
fn main1() {
doesnt_work();
does_work();
}
fn doesnt_work() {
Executor::new().run(Task::new(do_stuff()));
}
fn does_work() {
Executor::new().run(Task::new(do_more_stuff()));
}
async fn do_stuff() -> &'static str {
do_more_stuff().await
}
async fn do_more_stuff() -> &'static str {
"test"
} |
@nikomatsakis Same error:
Just as a note, I won't be able to test running the code like that as I need to export the symbol |
@nikomatsakis @jeswin Minimal example with only 1 dependency: https://github.com/lights0123/ice-70098 This doesn't require installing any toolchains other than cargo-xbuild, which is just one What I learned:
|
Huh! Fascinating. Thanks @lights0123, that's good work. |
Adding the no_mangle attribute to a function which contains an await results in a compilation error for armv7-linux-androideabi and aarch64-linux-android targets. Removing the attribute fixes the issue (though that's not a solution). There are no problems with x86_64-linux-android and i686-linux-android targets.
I expected to see this happen: library should get compiled successfully.
Instead, I get the following error:
Meta
The error exists in the beta and nightly versions. RUST_BACKTRACE=1 doesn't seem to add additional information.
The text was updated successfully, but these errors were encountered: