Skip to content

Coverage 0% when opt-level = 3 and aarch64-linux-android #139907

Open
@loynoir

Description

@loynoir

BUG

Coverage 0% when opt-level = 3 and aarch64-linux-android

reproduce

reproduce code
$ fd -tf -H -X tail -n +1
==> ./rust-toolchain.toml <==
[toolchain]
channel = "nightly-2025-04-14"
targets = [
    "aarch64-linux-android",
    "aarch64-unknown-linux-gnu",
    "x86_64-unknown-linux-gnu", 
]
components = ["llvm-tools"]

==> ./.cargo/config.toml <==
# android-ndk 28
[target.aarch64-linux-android]
linker = "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang"
ar = "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
runner = "/home/vscode/script/runner-ssh-aarch64-linux-android.sh"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
runner = "/home/vscode/script/runner-ssh-aarch64-unknown-linux-gnu.sh"

[profile.x_release_o2]
inherits = "release"
opt-level = 2

[profile.x_release_o3]
inherits = "release"


==> ./Cargo.toml <==
[package]
name = "reproduce"
version = "0.1.0"
edition = "2021"

[dependencies]

==> ./src/lib.rs <==
pub fn add(left: u64, right: u64) -> u64 {
    left + right
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}

actual

Coverage 0% when opt-level = 3 and aarch64-linux-android

$ run_cov_test x_release_o3 aarch64-linux-android

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/reproduce/src/lib.rs           3                 3     0.00%           2                 2     0.00%           7                 7     0.00%           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                               3                 3     0.00%           2                 2     0.00%           7                 7     0.00%           0                 0         -

Coverage 100% when not opt-level = 3 and aarch64-linux-android

$ run_cov_test x_release_o2 aarch64-linux-android

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/reproduce/src/lib.rs           3                 0   100.00%           2                 0   100.00%           7                 0   100.00%           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                               3                 0   100.00%           2                 0   100.00%           7                 0   100.00%           0                 0         -

Every below combo, coverage is 100% like above.

run_cov_test x_release_o2 aarch64-linux-android
# run_cov_test x_release_o3 aarch64-linux-android
run_cov_test x_release_o2 aarch64-unknown-linux-gnu
run_cov_test x_release_o3 aarch64-unknown-linux-gnu
run_cov_test x_release_o2 x86_64-unknown-linux-gnu
run_cov_test x_release_o3 x86_64-unknown-linux-gnu

expected

Coverage should be 100% when opt-level = 3 and aarch64-linux-android.

version

channel = "nightly-2025-04-14"

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.O-androidOperating system: AndroidT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions