Skip to content

no_mangle causes compilation errors with async-await on armv7-linux-androideabi and aarch64-linux-android targets #70098

Open
@jeswin

Description

@jeswin

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.

#![cfg(target_os = "android")]
#![allow(non_snake_case)]

use tokio::{runtime::Runtime };

#[no_mangle]
pub fn Java_blah_blah_func() -> &'static str {
    Runtime::new().unwrap().block_on(async {
        myfunc().await
    })
}

async fn myfunc() -> &'static str {
    "hello"
}

I expected to see this happen: library should get compiled successfully.

Instead, I get the following error:

Function return type does not match operand type of return inst!
  ret i32 undef
 { i8*, i32 }in function _ZN80_$LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h2e6af84f5e832d75E
LLVM ERROR: Broken function found, compilation aborted!

Meta

The error exists in the beta and nightly versions. RUST_BACKTRACE=1 doesn't seem to add additional information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-androidOperating system: AndroidP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions