Skip to content

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

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

Open
loynoir opened this issue Apr 16, 2025 · 0 comments
Open

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

loynoir opened this issue Apr 16, 2025 · 0 comments
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug. O-android Operating system: Android T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@loynoir
Copy link

loynoir commented Apr 16, 2025

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"
@loynoir loynoir added the C-bug Category: This is a bug. label Apr 16, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 16, 2025
@bjorn3 bjorn3 added O-android Operating system: Android A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) labels Apr 16, 2025
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug. O-android Operating system: Android T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants