@@ -29,12 +29,20 @@ fn main() {
29
29
30
30
if let Ok ( target) = RiscvTarget :: build ( & target, & cargo_flags) {
31
31
let width = target. width ( ) ;
32
- if matches ! ( width, riscv_target_parser:: Width :: W128 ) {
33
- panic ! ( "Unsupported RISC-V target: {width}" ) ;
34
- }
35
- if target. base_extension ( ) . is_none ( ) {
36
- panic ! ( "Unsupported RISC-V target: no base extension" ) ;
37
- }
32
+ let base_extension = match width {
33
+ riscv_target_parser:: Width :: W32 => match target. base_extension ( ) {
34
+ Some ( riscv_target_parser:: Extension :: I ) => "RV32I" ,
35
+ Some ( riscv_target_parser:: Extension :: E ) => "RV32E" ,
36
+ other => panic ! ( "Unsupported RISC-V target: {:?}-{:?}" , width, other) ,
37
+ } ,
38
+ riscv_target_parser:: Width :: W64 => match target. base_extension ( ) {
39
+ Some ( riscv_target_parser:: Extension :: I ) => "RV64I" ,
40
+ Some ( riscv_target_parser:: Extension :: E ) => "RV64E" ,
41
+ other => panic ! ( "Unsupported RISC-V target: {:?}-{:?}" , width, other) ,
42
+ } ,
43
+ _ => panic ! ( "Unsupported RISC-V target width: {:?}" , width) ,
44
+ } ;
45
+ println ! ( "cargo:rustc-env=RUSTC_CFG_RISCV32I={base_extension}" ) ;
38
46
for flag in target. rustc_flags ( ) {
39
47
// Required until target_feature risc-v is stable and in-use
40
48
println ! ( "cargo:rustc-check-cfg=cfg({flag})" ) ;
0 commit comments