This project provides a script to automate the extraction and comparison of available RISC-V extensions across different versions of the SiFive Freedom Tools RISC-V toolchain.
The script will:
- Load each specified toolchain module.
- Run
riscv64-unknown-elf-gcc -march=help
andriscv64-unknown-elf-clang --print-supported-extensions
to extract supported extensions. - Convert the outputs to CSV format.
- Merge all CSVs into a combined, sorted output file showing which extensions are supported in each toolchain version.
- Bash shell
module
command (e.g., Lmod or Environment Modules)- Python 3
- RISC-V toolchains available as modules
- Two Python scripts in the same directory:
gen_txt2csv.py
— Converts GCC/Clang output to CSVmerge_riscv_extensions.py
— Merges all CSVs into one
.
├── gen_compiler_ext.sh # The main bash script
├── gen_txt2csv.py # Converts compiler output to CSV
├── merge_riscv_extensions.py # Merges multiple CSV files
└── csv/ # Output folder (auto-generated)
Run full processing (if csv/ doesn't exist):
./gen_compiler_ext.sh
Force full processing (even if output folder exists):
./gen_compiler_ext.sh --force
The script supports several command-line options:
Options:
--help, -h Show help message and exit
--force Force regeneration of all output files
--output-dir DIR Set output directory (default: ./csv)
--merged-file FILE Set merged output file name (default: compiler-ext.csv)
--gcc-triple NAME Use specific GCC triple name (default: riscv64-unknown-elf-gcc)
--clang-triple NAME Use specific Clang triple name (default: riscv64-unknown-elf-clang)
--version VER Process specific version only
--list-versions List available versions and exit
--no-description Filter out description column in the merged output
Process all toolchain versions:
./gen_compiler_ext.sh
Process a specific version only:
./gen_compiler_ext.sh --version 3.1.4
Change the output directory:
./gen_compiler_ext.sh --output-dir ./my-reports
Use a different GCC triple:
./gen_compiler_ext.sh --gcc-triple riscv64-linux-gnu-gcc
List all available versions:
./gen_compiler_ext.sh --list-versions
Filter out description column from output:
```bash
./gen_compiler_ext.sh --no-description
After successful execution, you will get:
csv/
├── gcc-1.0.6.csv
├── gcc-1.0.7.csv
├── ...
├── gcc-3.1.4.csv
├── clang-1.0.6.csv
├── clang-1.0.7.csv
├── ...
└── clang-3.1.4.csv
compiler-ext.csv # Combined & sorted CSV of all versions
The merged CSV file includes columns for each toolchain version, showing whether each extension is supported ('Y') or not ('N').
You can convert the generated CSV file to a formatted Excel spreadsheet using the included csv_to_xlsx.py
script:
python csv_to_xlsx.py compiler-ext.csv
Options:
--output, -o FILE Specify output XLSX filename
--freeze, -f Freeze the first two columns (Name, Version)
--separate-sheets, -s Create additional separate sheets for GCC and Clang
# Basic conversion
python csv_to_xlsx.py compiler-ext.csv
# Create additional separate sheets for GCC and Clang
python csv_to_xlsx.py compiler-ext.csv --separate-sheets
# Specify a custom output filename
python csv_to_xlsx.py compiler-ext.csv -o risc-v-extensions.xlsx
This script requires:
- pandas
- openpyxl
You can install these with:
pip install pandas openpyxl
The Excel file will have conditional formatting with green highlighting for supported extensions ('Y') and red for unsupported ones ('N').