How to include .S file in cargo project for risc-v?

Is there a way to include assembly.S file in cargo project for risc-v ?
When I tested with test.S in src/asm directory;

src/asm/test.S
#![no_std]
#![no_main]
use core::arch::asm;
asm!( "mret");
src/main.rs
#![no_std]

#![no_main]
global_asm!(include_str!("asm/test.S"));

it throws the error
error**: unexpected token**

However, inline assembly in main.rs asm!( "mret"); works.

What is the correct way to include risc-v assembly file with .S extension?

This is the correct way to do it.

Share with complete error msg from rustc instead of from your IDE.

Thanks, while trying to get you the code, figured out (the cause) that the assembly test.S file had asm! instantiation.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.