File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
crates/std_detect/src/detect/os/linux Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,15 @@ pub(crate) fn detect_features() -> cache::Initializer {
30
30
31
31
// Handle base ISA.
32
32
let has_i = bit:: test ( auxv. hwcap , ( b'i' - b'a' ) . into ( ) ) ;
33
- // If future RV128I is supported, implement with `enable_feature` here
34
- #[ cfg( target_pointer_width = "64" ) ]
33
+ // If future RV128I is supported, implement with `enable_feature` here.
34
+ // Note that we should use `target_arch` instead of `target_pointer_width`
35
+ // to avoid misdetection caused by experimental ABIs such as RV64ILP32.
36
+ #[ cfg( target_arch = "riscv64" ) ]
35
37
enable_feature ( Feature :: rv64i, has_i) ;
36
- #[ cfg( target_pointer_width = "32 " ) ]
38
+ #[ cfg( target_arch = "riscv32 " ) ]
37
39
enable_feature ( Feature :: rv32i, has_i) ;
38
40
// FIXME: e is not exposed in any of asm/hwcap.h, uapi/asm/hwcap.h, uapi/asm/hwprobe.h
39
- #[ cfg( target_pointer_width = "32 " ) ]
41
+ #[ cfg( target_arch = "riscv32 " ) ]
40
42
enable_feature ( Feature :: rv32e, bit:: test ( auxv. hwcap , ( b'e' - b'a' ) . into ( ) ) ) ;
41
43
42
44
// FIXME: Auxvec does not show supervisor feature support, but this mode may be useful
You can’t perform that action at this time.
0 commit comments