Linux command
riscv64-unknown-elf-gcc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile for RISC-V
riscv64-unknown-elf-gcc -o [output] [source.c]
Compile with specific architecture
riscv64-unknown-elf-gcc -march=rv64imac -o [output] [source.c]
Compile for bare metal
riscv64-unknown-elf-gcc -nostdlib -o [output] [source.c]
Produce assembly
riscv64-unknown-elf-gcc -S [source.c]
说明
riscv64-unknown-elf-gcc is the GCC cross-compiler for RISC-V 64-bit bare-metal targets. It compiles C/C++ code for RISC-V processors without an operating system.
参数
- -march=_arch_
- Target architecture (e.g. rv64imac, rv64gc, rv32imac).
- -mabi=_abi_
- Integer and floating-point calling convention (e.g. lp64, lp64d, lp64f, ilp32).
- -nostdlib
- Do not link standard library or startup files.
- -T _script_
- Use the specified linker script.
- -mcmodel=_model_
- Code model: medlow (default) or medany.
- -msave-restore
- Use smaller but slower prologue/epilogue routines to reduce code size.
- -msmall-data-limit=_n_
- Put global and static data smaller than _n_ bytes in a special section.
- --specs=_file_
- Use the specified specs file (e.g. nano.specs for newlib-nano).
- -O_level_
- Optimization level (0, 1, 2, 3, s, g).
FAQ
What is the riscv64-unknown-elf-gcc command used for?
riscv64-unknown-elf-gcc is the GCC cross-compiler for RISC-V 64-bit bare-metal targets. It compiles C/C++ code for RISC-V processors without an operating system.
How do I run a basic riscv64-unknown-elf-gcc example?
Run `riscv64-unknown-elf-gcc -o [output] [source.c]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -march=_arch_ do in riscv64-unknown-elf-gcc?
Target architecture (e.g. rv64imac, rv64gc, rv32imac).