From 52ce497ce3d7b4c11322eea8139c27fe8dc4eee5 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Sat, 7 Sep 2024 22:39:00 +0100 Subject: [PATCH] Fix detection of `riscv64-linux-android` target features --- cargo-auditable/src/object_file.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cargo-auditable/src/object_file.rs b/cargo-auditable/src/object_file.rs index 6dcb9bc..5d4808f 100644 --- a/cargo-auditable/src/object_file.rs +++ b/cargo-auditable/src/object_file.rs @@ -194,6 +194,12 @@ fn riscv_features(target_triple: &str) -> String { if extensions.contains('g') { extensions.push_str("imadf"); } + // Most but not all riscv targets declare target features. + // A notable exception is `riscv64-linux-android`. + // We assume that all Linux-capable targets are -gc. + if target_triple.contains("linux") { + extensions.push_str("imadfc"); + } extensions } @@ -234,6 +240,11 @@ mod tests { assert!(!features.contains('c')); assert!(!features.contains('d')); assert!(features.contains('f')); + // real-world Android riscv target + let features = riscv_features("riscv64-linux-android"); + assert!(features.contains('c')); + assert!(features.contains('d')); + assert!(features.contains('f')); } #[test]