@@ -42,10 +42,47 @@ function(_rust_map_target)
42
42
elseif (CONFIG_RISCV )
43
43
if (CONFIG_RISCV_ISA_RV64I )
44
44
# TODO: Should fail if the extensions don't match.
45
- set (RUST_TARGET "riscv64imac-unknown-none-elf" PARENT_SCOPE )
45
+ # We have multiple choices, try to pick the best.
46
+ # Note that Rust currently only supports "riscv64gc" and "riscv64imac" targets!
47
+ set (RUST_TARGET "riscv64" )
48
+ if (CONFIG_RISCV_ISA_EXT_G )
49
+ set (RUST_TARGET "${RUST_TARGET} g" )
50
+ else ()
51
+ set (RUST_TARGET "${RUST_TARGET} i" )
52
+ if (CONFIG_RISCV_ISA_EXT_M )
53
+ set (RUST_TARGET "${RUST_TARGET} m" )
54
+ endif ()
55
+ if (CONFIG_RISCV_ISA_EXT_A )
56
+ set (RUST_TARGET "${RUST_TARGET} a" )
57
+ endif ()
58
+ if (CONFIG_RISCV_ISA_EXT_F )
59
+ set (RUST_TARGET "${RUST_TARGET} f" )
60
+ endif ()
61
+ if (CONFIG_RISCV_ISA_EXT_D )
62
+ set (RUST_TARGET "${RUST_TARGET} d" )
63
+ endif ()
64
+ endif ()
65
+ if (CONFIG_RISCV_ISA_EXT_C )
66
+ set (RUST_TARGET "${RUST_TARGET} c" )
67
+ endif ()
68
+ set (RUST_TARGET "${RUST_TARGET} -unknown-none-elf" PARENT_SCOPE )
46
69
elseif (CONFIG_RISCV_ISA_RV32I )
47
- # TODO: We have multiple choices, try to pick the best.
48
- set (RUST_TARGET "riscv32i-unknown-none-elf" PARENT_SCOPE )
70
+ # We have multiple choices, try to pick the best.
71
+ # Note that Rust currently only supports subsets of "riscv32imafc" targets!
72
+ set (RUST_TARGET "riscv32i" )
73
+ if (CONFIG_RISCV_ISA_EXT_M )
74
+ set (RUST_TARGET "${RUST_TARGET} m" )
75
+ endif ()
76
+ if (CONFIG_RISCV_ISA_EXT_A )
77
+ set (RUST_TARGET "${RUST_TARGET} a" )
78
+ endif ()
79
+ if (CONFIG_RISCV_ISA_EXT_F )
80
+ set (RUST_TARGET "${RUST_TARGET} f" )
81
+ endif ()
82
+ if (CONFIG_RISCV_ISA_EXT_C )
83
+ set (RUST_TARGET "${RUST_TARGET} c" )
84
+ endif ()
85
+ set (RUST_TARGET "${RUST_TARGET} -unknown-none-elf" PARENT_SCOPE )
49
86
else ()
50
87
message (FATAL_ERROR "Rust: Unsupported riscv ISA" )
51
88
endif ()
0 commit comments