ZCC 4.x User Manual
Terapines compiler ZCC is a high-performance C/C++ compiler for RISC-V based on LLVM. It supports the most recent C and C++ standards, including C17, C99, C11, C++17, C++14 and C++11 etc and brings the following key features.
-
RVV auto-vectorization and other compiler optimizations.
-
Support RISC-V ISAs, including extensions and vendor extensions from XuanTie,Nuclei and Andes.
Download and Installation
ZCC is a high performance RISC-V toolchain that provides consistent experience on Windows and Linux.
System requirements
You can review the system requirements to check if your computer configuration is supported.
-
Windows : Windows 10 and above
-
Linux:
-
Ubuntu 18, Ubuntu 20, Ubuntu 22.04 and Ubuntu 24.04
-
Centos 6, CentOS 7 and Centos8
-
Fedora 42
-
openSUSE Leap 15.5
-
Setup using the Terapines Installer
The Terapines Installer is the recommended tool to setup Terapines products. For users without a graphical interface, please use the Command Line Interface (CLI) installer.
- Windows
- Linux (GUI)
- Linux (TUI)
- Linux (CLI)
-
Select
Windowsfrom pull-down box to download the Installer.exefrom ZCC download page. -
Run the Installer with administrator privileges and select the product that you want to install.
-
ZCC toolchain by default included LibZCC. For additional libraries, choose to install. The installed libraries would be added in toolchain and apply globally.
-
LibDSP: It offers a collection of functions and tools specifically designed for digital signal processing (DSP).
-
LibNN: Specialized library for implementing and running neural network (NN) algorithms.
-
Once installed, you can open the Product Manager to handle multiple versions of your product.
- Community Edition: Use immediately without logging in.
- Commercial Edition: Activate your license by following the instructions in the License Management Manual.


-
Select
Linuxfrom pull-down box to download the Installer executable from ZCC download page. -
Make the ZCC-Installer executable by all users:
chmod a+x ZCC-Installer-<version>-Linux -
Run the executable and select the product that you want to install.
./ZCC-Installer-<version>-Linux //when installed without root privileges
sudo ./ZCC-Installer-<version>-Linux //when installed system-wide (with root privileges) -
ZCC toolchain by default included LibZCC. For additional libraries, choose to install. The installed libraries would be added in toolchain and apply globally.
-
LibDSP: It offers a collection of functions and tools specifically designed for digital signal processing (DSP).
-
LibNN: Specialized library for implementing and running neural network (NN) algorithms.
-
Once installed, you can open the Product Manager to handle multiple versions of your product.
- Community Edition: Use immediately without logging in.
- Commercial Edition: Activate your license by following the instructions in the License Management Manual.


-
Select
Linux (CLI)from pull-down box to download the Installer executable from ZCC download page. -
Make the ZCC-Installer executable by all users:
chmod a+x ZCC-Installer-<version>-Linux-CLI -
Run the executable with administrator privileges, select the product that you want to install and follow the step instruction.
./ZCC-Installer-<version>-Linux-CLI //when installed without root privileges
sudo ./ZCC-Installer-<version>-Linux-CLI //when installed system-wide (with root privileges) -
ZCC toolchain by default included LibZCC. For additional libraries, choose to install.
-
LibDSP: It offers a collection of functions and tools specifically designed for digital signal processing (DSP).
-
LibNN: Specialized library for implementing and running neural network (NN) algorithms.
-
Once installed, you can open the Product Manager to handle multiple versions of your product.
- Community Edition: Use immediately without logging in.
- Commercial Edition: Activate your license by following the instructions in the License Management Manual.
~/Terapines/Product-Manager-CLI //when installed without root privileges
/opt/Terapines/Product-Manager-CLI //when installed system-wide (with root)
-
Select
Linux (CLI)from pull-down box to download the Installer executable from ZCC download page. -
Make the ZCC-Installer executable by all users. You can view all available commands with
--help.chmod a+x ZCC-Installer-<version>-Linux-CLI -
You can start the installation by
--installcommand./ZCC-Installer-4.0.1-Linux-CLI --install ZCC //when installed without root privileges
sudo ./ZCC-Installer-4.0.1-Linux-CLI --install ZCC //when installed system-wide (with root) -
ZCC toolchain by default included LibZCC. For additional libraries, choose to install.
-
LibDSP: It offers a collection of functions and tools specifically designed for digital signal processing (DSP).
./ZCC-Installer-<version>-Linux-CLI --install libdsp -
LibNN: Specialized library for implementing and running neural network (NN) algorithms.
./ZCC-Installer-<version>-Linux-CLI --install libnn
-
Once installed, you can open the Product Manager to handle multiple versions of your product.
- Community Edition: Use immediately without logging in.
- Commercial Edition: Activate your license by following the instructions in the License Management Manual.
~/Terapines/Product-Manager-CLI //when installed without root privileges
/opt/Terapines/Product-Manager-CLI //when installed system-wide (with root)
Update ZCC
You can update ZCC in the Terapines Product Manager whenever a new version is released. Keeping ZCC up to date ensures you always have the latest features and performance improvements.
- Launch Terapines Product Manager, expand Available.
- Locate the most recent ZCC version in the list to install.
Enable email notifications
To stay informed about new ZCC updates:
Click the Settings icon in the top-right corner of Terapines Product Manager. Go to the Profile page and toggle on Email Notifications.


You will now receive automatic alerts whenever a new version of ZCC becomes available. To update ZCC, please go to Terapines Product Manager.
Language standards
-
-x <language>Treat subsequent input files as having type
<language>. The optional<language>is C or C++. -
-std=<standard>Select the language standard to compile for. Supported values are listed in the table below. The supported language standards maintain with the specifications and details provided by the upstream source. Please refer to C++ Support in Clang and C Support in Clang.
-
-ansiSame as "-std=c89".
| Standards | Versions |
|---|---|
| C Standard | c18; c17; c11; c99; c90; c89 |
| C++ Standard | c++17; c++14; c++11; c++03; c++98 |
| GNU C | gnu18; gnu17; gnu11; gnu89; gnu++17; gnu++14; gnu++11; gnu++98 |
| ISO C | iso9899:2018; iso9899:2017; iso9899:2011; iso9899:1999; iso9899:199409; iso9899:1990 |
- C17 & C18: Since it was under development in 2017, and officially published in 2018, C17 is sometimes referred to as C18.
- C89 & C90: C90 is the same standard as C89 was ratified by ISO/IEC as ISO/IEC 9899:1990, with only formatting changes. Therefore, the terms "C89" and "C90" refer to essentially the same language.
RISC-V target support
Use -print-supported-extensions to print the list of all extensions that are supported in ZCC.
Base ISAs
Currently, ZCC fully supports three base instruction sets: RV32I, RV32E and RV64I.
To specify the target triple:
riscv32RISC-V with XLEN=32 (i.e. RV32I or RV32E)riscv64RISC-V with XLEN=64 (i.e. RV64I)
To select an E variant ISA (e.g. RV32E instead of RV32I), use the base architecture string (e.g. riscv32) with the extension e.
Extensions
The table below provides the extensions in ZCC that ensure compatibility, including standard extensions as well as some experimental extensions from older versions.
The Zp052b extension is version 0.52 of the P extension, which is an older experimental version. ZCC has extracted and designated it as a standard extension named Zp052b. When using this extension, there is no need to specify a version number—simply use zp052b.
zcc -march=rv32imaczp052b -c hello.c
zcc -march=rv32imafdc -c hello.c
| Extension | Version | Feature | Description |
|---|---|---|---|
| I | 2.1 | i | Base Integer Instruction Set |
| E | 2.0 | e | Implements RV64E (provides 16 rather than 32 GPRs) |
| M | 2.0 | m | Integer Multiplication and Division |
| A | 2.1 | a | Atomic Instructions |
| F | 2.2 | f | Single-Precision Floating-Point |
| D | 2.2 | d | Double-Precision Floating-Point |
| C | 2.0 | c | Compressed Instructions |
| B | 1.0 | b | The collection of the Zba, Zbb, Zbs extensions |
| V | 1.0 | v | Vector Extension for Application Processors |
| H | 1.0 | h | Hypervisor |
| Zic64b | 1.0 | zic64b | Cache Block Size Is 64 Bytes |
| Zicbom | 1.0 | zicbom | Cache-Block Management Instructions |
| Zicbop | 1.0 | zicbop | Cache-Block Prefetch Instructions |
| Zicboz | 1.0 | zicboz | Cache-Block Zero Instructions |
| Ziccamoa | 1.0 | ziccamoa | Main Memory Supports All Atomics in A |
| Ziccif | 1.0 | ziccif | Main Memory Supports Instruction Fetch with Atomicity Requirement |
| Zicclsm | 1.0 | zicclsm | Main Memory Supports Misaligned Loads/Stores |
| Ziccrse | 1.0 | ziccrse | Main Memory Supports Forward Progress on LR/SC Sequences |
| Zicntr | 2.0 | zicntr | Base Counters and Timers |
| Zicond | 1.0 | zicond | Integer Conditional Operations |
| Zicsr | 2.0 | zicsr | Control and Status Register (CSR) Instructions |
| Zifencei | 2.0 | zifencei | fence.i |
| Zihintntl | 1.0 | zihintntl | Non-Temporal Locality Hints |
| Zihintpause | 2.0 | zihintpause | Pause Hint |
| Zihpm | 2.0 | zihpm | Hardware Performance Counters |
| Zilsd | 1.0 | zilsd | Load/Store Pair Instructions |
| Zimop | 1.0 | zimop | May-Be-Operations |
| Zmmul | 1.0 | zmmul | Integer Multiplication |
| Za128rs | 1.0 | za128rs | Reservation Set Size of at Most 128 Bytes |
| Za64rs | 1.0 | za64rs | Reservation Set Size of at Most 64 Bytes |
| Zaamo | 1.0 | zaamo | Atomic Memory Operations |
| Zabha | 1.0 | zabha | Byte and Halfword Atomic Memory Operations |
| Zacas | 1.0 | zacas | Atomic Compare-And-Swap Instructions |
| Zalrsc | 1.0 | zalrsc | Load-Reserved/Store-Conditional |
| Zama16b | 1.0 | zama16b | Atomic 16-byte misaligned loads, stores and AMOs |
| Zawrs | 1.0 | zawrs | Wait on Reservation Set |
| Zfa | 1.0 | zfa | Additional Floating-Point |
| Zfbfmin | 1.0 | zfbfmin | Scalar BF16 Converts |
| Zfh | 1.0 | zfh | Half-Precision Floating-Point |
| Zfhmin | 1.0 | zfhmin | Half-Precision Floating-Point Minimal |
| Zfinx | 1.0 | zfinx | Float in Integer |
| Zdinx | 1.0 | zdinx | Double in Integer |
| Zca | 1.0 | zca | Part of the C extension, excluding compressed floating point loads/stores |
| Zcb | 1.0 | zcb | Compressed basic bit manipulation instructions |
| Zcd | 1.0 | zcd | Compressed Double-Precision Floating-Point Instructions |
| Zce | 1.0 | zce | Compressed extensions for microcontrollers |
| Zcf | 1.0 | zcf | Compressed Single-Precision Floating-Point Instructions |
| Zclsd | 1.0 | zclsd | Compressed Load/Store Pair Instructions |
| Zcmop | 1.0 | zcmop | Compressed May-Be-Operations |
| Zcmp | 1.0 | zcmp | Sequenced instructions for code-size reduction |
| Zcmt | 1.0 | zcmt | Table jump instructions for code-size reduction |
| Zba | 1.0 | zba | Address Generation Instructions |
| Zbb | 1.0 | zbb | Basic Bit-Manipulation |
| Zbc | 1.0 | zbc | Carry-Less Multiplication |
| Zbkb | 1.0 | zbkb | Bitmanip instructions for Cryptography |
| Zbkc | 1.0 | zbkc | Carry-less multiply instructions for Cryptography |
| Zbkx | 1.0 | zbkx | Crossbar permutation instructions |
| Zbs | 1.0 | zbs | Single-Bit Instructions |
| Zk | 1.0 | zk | Standard scalar cryptography extension |
| Zkn | 1.0 | zkn | NIST Algorithm Suite |
| Zknd | 1.0 | zknd | NIST Suite: AES Decryption |
| Zkne | 1.0 | zkne | NIST Suite: AES Encryption |
| Zknh | 1.0 | zknh | NIST Suite: Hash Function Instructions |
| Zkr | 1.0 | zkr | Entropy Source Extension |
| Zks | 1.0 | zks | ShangMi Algorithm Suite |
| Zksed | 1.0 | zksed | ShangMi Suite: SM4 Block Cipher Instructions |
| Zksh | 1.0 | zksh | ShangMi Suite: SM3 Hash Function Instructions |
| Zkt | 1.0 | zkt | Data Independent Execution Latency |
| Ztso | 1.0 | ztso | Memory Model - Total Store Order |
| Zp052b | 0.5 | zp052b | Packed-SIMD Instructions |
| Zp053b | 0.5 | zp053b | Packed-SIMD Instructions |
| Zp054b | 0.5 | zp054b | Packed-SIMD Instructions |
| Zp095b | 1.0 | zp095b | RV32 only 'P' Instructions |
| Zp64054b | 0.5 | zp64054b | Packed-SIMD Instructions |
| Zpn095b | 1.0 | zpn095b | Normal 'P' Instructions |
| Zprvsfextra095b | 1.0 | zprvsfextra095b | RV64 only 'P' Instructions |
| Zpsfoperand095b | 1.0 | zpsfoperand095b | Paired-register operand 'P' Instructions |
| Zvbb | 1.0 | zvbb | Vector basic bit-manipulation instructions |
| Zvbc | 1.0 | zvbc | Vector Carryless Multiplication |
| Zve32f | 1.0 | zve32f | Vector Extensions for Embedded Processors with maximal 32 EEW and F ex |
| Zve32x | 1.0 | zve32x | Vector Extensions for Embedded Processors with maximal 32 EEW |
| Zve64d | 1.0 | zve64d | Vector Extensions for Embedded Processors with maximal 64 EEW, F and D |
| Zve64f | 1.0 | zve64f | Vector Extensions for Embedded Processors with maximal 64 EEW and F ex |
| Zve64x | 1.0 | zve64x | Vector Extensions for Embedded Processors with maximal 64 EEW |
| Zvbfmin | 1.0 | zvfbfmin | Vector BF16 Converts |
| Zvfbfwma | 1.0 | zvfbfwma | Vector BF16 widening mul-add |
| Zvfh | 1.0 | zvfh | Vector Half-Precision Floating-Point |
| Zvfhmin | 1.0 | zvfhmin | Vector Half-Precision Floating-Point Minimal |
| Zvkb | 1.0 | zvkb | Vector Bit-manipulation used in Cryptography |
| Zvkg | 1.0 | zvkg | Vector GCM instructions for Cryptography |
| Zvkn | 1.0 | zvkn | Shorthand for 'Zvkned', 'Zvknhb', 'Zvkb', and 'Zvkt' |
| Zvknc | 1.0 | zvknc | Shorthand for 'Zvknc' and 'Zvbc' |
| Zvkned | 1.0 | zvkned | Vector AES Encryption & Decryption (Single Round) |
| Zvkng | 1.0 | zvkng | Shorthand for 'Zvkn' and 'Zvkg' |
| Zvknha | 1.0 | zvknha | Vector SHA-2 (SHA-256 only) |
| Zvknhb | 1.0 | zvknhb | Vector SHA-2 (SHA-256 and SHA-512) |
| Zvks | 1.0 | zvks | Shorthand for 'Zvksed', 'Zvksh', 'Zvkb', and 'Zvkt' |
| Zvksc | 1.0 | zvksc | Shorthand for 'Zvks' and 'Zvbc' |
| Zvksed | 1.0 | zvksed | SM4 Block Cipher Instructions |
| Zvksg | 1.0 | zvksg | Shorthand for 'Zvks' and 'Zvkg' |
| Zvksh | 1.0 | zvksh | SM3 Hash Function Instructions |
| Zvkt | 1.0 | zvkt | Vector Data-Independent Execution Latency |
| Zvl | 1.0 | zvl1024b | Zvl (Minimum Vector Length) 1024 |
| Zvl | 1.0 | zvl128b | Zvl (Minimum Vector Length) 128 |
| Zvl | 1.0 | zvl16384b | Zvl (Minimum Vector Length) 16384 |
| Zvl | 1.0 | zvl2048b | Zvl (Minimum Vector Length) 2048 |
| Zvl | 1.0 | zvl256b | Zvl (Minimum Vector Length) 256 |
| Zvl | 1.0 | zvl32768b | Zvl (Minimum Vector Length) 32768 |
| Zvl | 1.0 | zvl32b | Zvl (Minimum Vector Length) 32 |
| Zvl | 1.0 | zvl4096b | Zvl (Minimum Vector Length) 4096 |
| Zvl | 1.0 | zvl512b | Zvl (Minimum Vector Length) 512 |
| Zvl | 1.0 | zvl64b | Zvl (Minimum Vector Length) 64 |
| Zvl | 1.0 | zvl65536b | Zvl (Minimum Vector Length) 65536 |
| Zvl | 1.0 | zvl8192b | Zvl (Minimum Vector Length) 8192 |
| Zhinx | 1.0 | zhinx | Zhinx (Half Float in Integer) |
| Zhinxmin | 1.0 | zhinxmin | Zhinxmin (Half Float in Integer Minimal) |
| Shcounterenw | 1.0 | shcounterenw | Support writeable hcounteren enable bit for any hpmcounter that is not read-only zero |
| Sgatpa | 1.0 | shgatpa | SvNNx4 mode supported for all modes supported by satp, as well as Bare |
| Shtvala | 1.0 | shtvala | htval provides all needed values |
| Svsatpa | 1.0 | shvsatpa | vsatp supports all modes supported by satp |
| Shvstvala | 1.0 | shvstvala | vstval provides all needed values |
| Shvstvecd | 1.0 | shvstvecd | vstvec supports Direct mode |
| Smaia | 1.0 | smaia | Advanced Interrupt Architecture Machine Level |
| Smcdeleg | 1.0 | smcdeleg | Counter Delegation Machine Level |
| Smcsrind | 1.0 | smcsrind | Indirect CSR Access Machine Level |
| Smepmp | 1.0 | smepmp | Enhanced Physical Memory Protection |
| Smrnmi | 1.0 | smrnmi | Resumable Non-Maskable Interrupts |
| Smstateen | 1.0 | smstateen | Machine-mode view of the state-enable extension |
| Ssaia | 1.0 | ssaia | Advanced Interrupt Architecture Supervisor Level |
| Ssccfg | 1.0 | ssccfg | Counter Configuration Supervisor Level |
| Ssccptr | 1.0 | ssccptr | Main memory supports page table reads |
| Sscofpmf | 1.0 | sscofpmf | Count Overflow and Mode-Based Filtering |
| Sscounterenw | 1.0 | sscounterenw | Support writeable scounteren enable bit for any hpmcounter that is not read-only zero |
| Sscsrind | 1.0 | sscsrind | Indirect CSR Access Supervisor Level |
| Ssqosid | 1.0 | ssqosid | Quality-of-Service (QoS) Identifiers |
| Ssstateen | 1.0 | ssstateen | Supervisor-mode view of the state-enable extension |
| Ssstrict | 1.0 | ssstrict | No non-conforming extensions are present |
| Sstc | 1.0 | sstc | Supervisor-mode timer interrupts |
| Sstvala | 1.0 | sstvala | stval provides all needed values |
| Sstvecd | 1.0 | sstvecd | stvec supports Direct mode |
| Ssu64xl | 1.0 | ssu64xl | UXLEN=64 supported |
| Svade | 1.0 | svade | Raise exceptions on improper A/D bits |
| Svadu | 1.0 | svadu | Hardware A/D updates |
| Svbare | 1.0 | svbare | $(satp mode Bare supported) |
| Svinval | 1.0 | svinval | Fine-Grained Address-Translation Cache Invalidation |
| Svnapot | 1.0 | svnapot | NAPOT Translation Contiguity |
| Svpbmt | 1.0 | svpbmt | Page-Based Memory Types |
| Svvptc | 1.0 | svvptc | Obviating Memory-Management Instructions after Marking PTEs Valid |
Experimental Extensions
Experimental extensions are expected to either transition to ratified status, or the old version. The compatibility of extensions between toolchain versions is not guaranteed. When using these extensions, version numbers must be added.
For example, when using the Zalasr extension, you need to add the version number, that is, use zalasr0p1 instead of zalasr.
zcc -march=rv32imaczalasr0p1 -c hello.c
zcc -march=rv32imaczicfiss1p0 -c hello.c
| Extension | Version | Feature | Description |
|---|---|---|---|
| Zicfiss | 1.0 | zicfiss | Shadow stack |
| Zalasr | 0.1 | zalasr | Load-Acquire and Store-Release Instructions |
| Smmpm | 1.0 | smmpm | Machine-level Pointer Masking for M-mode |
| Smnpm | 1.0 | smnpm | Machine-level Pointer Masking for next lower privilege mode |
| Ssnpm | 1.0 | ssnpm | Supervisor-level Pointer Masking for next lower privilege mode |
| Sspm | 1.0 | sspm | Indicates Supervisor-mode Pointer Masking |
Vendor Extensions
Vendor extensions are extensions which are defined by a hardware vendor.
| Extension | Version | Feature | Description |
|---|---|---|---|
| Xandes | 5.0 | xandes | AndeStar V5 Extension Specification |
| XCValu | 1.0 | xcvalu | CORE-V ALU Operations |
| XCVbi | 1.0 | xcvbi | CORE-V Immediate Branching |
| XCVbitmanip | 1.0 | xcvbitmanip | CORE-V Bit Manipulation |
| XCVelw | 1.0 | xcvelw | CORE-V Event Load Word |
| XCVmac | 1.0 | xcvmac | CORE-V Multiply-Accumulate |
| XCVmem | 1.0 | xcvmem | CORE-V Post-incrementing Load & Store |
| XCVsimd | 1.0 | xcvsimd | CORE-V SIMD ALU |
| Xp | 4.0 | xgap8dsp | GAP8 DSP extension |
| Xm | 4.0 | xgap8m | GAP8 Integer Multiplication |
| Xv | 4.0 | xgap8v | GAP8 Vector extension |
| XSfcease | 1.0 | xsfcease | SiFive sf.cease Instruction |
| XSfvcp | 1.0 | xsfvcp | SiFive Custom Vector Coprocessor Interface Instructions |
| XSfvfnrclipxfqf | 1.0 | xsfvfnrclipxfqf | SiFive FP32-to-int8 Ranged Clip Instructions |
| XSfvfwmaccqqq | 1.0 | xsfvfwmaccqqq | SiFive Matrix Multiply Accumulate Instruction and 4-by-4 |
| XSfvqmaccdod | 1.0 | xsfvqmaccdod | SiFive Int8 Matrix Multiplication Instructions 2-by-8 and 8-by-2 |
| XSfvqmaccqoq | 1.0 | xsfvqmaccqoq | SiFive Int8 Matrix Multiplication Instructions 4-by-8 and 8-by-4 |
| XSiFivecdiscarddlone | 1.0 | xsifivecdiscarddlone | SiFive sf.cdiscard.d.l1 Instruction |
| XSiFivecflushdlone | 1.0 | xsifivecflushdlone | SiFive sf.cflush.d.l1 Instruction |
| XTHeadBa | 1.0 | xtheadba | T-Head address calculation instructions |
| XTHeadBb | 1.0 | xtheadbb | T-Head basic bit-manipulation instructions |
| XTHeadBs | 1.0 | xtheadbs | T-Head single-bit instructions |
| XTHeadC | 2.0 | xtheadc | T-Head C series performance-enhanced instruction set |
| XTHeadCBI | 1.0 | xtheadcbi | Xuantie coprocessor basic integer intruction |
| XTHeadCEI | 1.0 | xtheadcei | Xuantie coprocessor enhanced integer intruction |
| XTHeadCF | 1.0 | xtheadcf | Xuantie coprocessor float intruction |
| XTHeadCmo | 1.0 | xtheadcmo | T-Head cache management instructions |
| XTHeadCondMov | 1.0 | xtheadcondmov | T-Head conditional move instructions |
| XTHeadCV | 1.0 | xtheadcv | Xuantie coprocessor vector intruction |
| XTHeadE | 2.0 | xtheade | T-Head E series performance-enhanced instruction set |
| XTHeadFMemIdx | 1.0 | xtheadfmemidx | T-Head FP Indexed Memory Operations |
| XTHeadFMv | 1.0 | xtheadfmv | T-Head FP Move Instructions |
| XTHeadInt | 1.0 | xtheadint | T-Head Acceleration Interruption Instructions |
| XTHeadLPW | 1.0 | xtheadlpw | T-Head Low Power Wait Instructions |
| XTHeadMac | 1.0 | xtheadmac | T-Head Multiply-Accumulate Instructions |
| XTHeadMemIdx | 1.0 | xtheadmemidx | T-Head Indexed Memory Operations |
| XTHeadMemPair | 1.0 | xtheadmempair | T-Head two-GPR Memory Operations |
| XTHeadSE | 2.0 | xtheadse | T-Head Small E series performance-enhanced instruction set |
| XTHeadSync | 1.0 | xtheadsync | T-Head multicore synchronization instructions |
| XTHeadVdot | 1.0 | xtheadvdot | T-Head Vector Extensions for Dot |
| XVentanaCondOps | 1.0 | xventanacondops | Ventana Conditional Ops |
| Xwchc | 2.2 | xwchc | WCH/QingKe additional compressed opcodes |
| Xxlcz | 1.0 | xxlcz | Nuclei Additional Xlcz Instruction for Codesize |
| Xxldsp | 1.0 | xxldsp | Nuclei customized DSP instructions for both RV32 and RV64 |
| Xxldspn1x | 1.0 | xxldspn1x | Nuclei customized DSP N1 instructions only for RV32 |
| Xxldspn2x | 1.0 | xxldspn2x | Nuclei customized DSP N2 instructions only for RV32 |
| Xxldspn3x | 1.0 | xxldspn3x | Nuclei customized DSP N3 instructions only for RV32 |
| Xxlvqmacc | 1.0 | xxlvqmacc | Nuclei Int8 Matrix Multiplication Instructions |
Profiles
Supported RISC-V profile names can be passed using -march instead of a standard ISA naming string. Currently supported profiles:
| Supported Profiles | Experimental Profiles |
|---|---|
| rva20s64 | rva23s64 |
| rva20u64 | rva23u64 |
| rva22s64 | rvb23s64 |
| rva22u64 | rvb23u64 |
| rvi20u32 | rvm23u32 |
| rvi20u64 |
Note that you can also append additional extension names to be enabled, e.g. rva20u64_zicond will enable the zicond extension in addition to those in the rva20u64 profile.
Compilation Options
Since ZCC 4.x is based on LLVM 19.1.6, most of the LLVM compiler options are applicable to ZCC.
-target option
Specify the -target <architecture> to build for. Arguments that can be used are listed below:
- riscv64-unknown-elf
- riscv32-unknown-elf
- riscv64-unknown-linux-gnu
-march option
specify -march=<architecture> to generate code for a specific processor architectures.
For the detection rules of march, the format follows -march=rv[32|64][i|e][extensions]. The order of components is not strictly enforced when using it, and the final linking will generate instructions according to the specified march. For example: when using -march=rv32imafc, ZCC will look for libraries with rv32ifa and also generate instructions for the M extension.
Multilib
ZCC will select compatible zcc libraries to add to the application based on the arch/abi combination specified by the user. For example:
| Specified arch/abi combination | Applied zcc library |
|---|---|
-march=rv32imafc -mabi=ilp32f | rv32ifa/ilp32f |
-march=rv32imafc_zba_zbb_zbc_zbs_zp052b -mabi=ilp32f | rv32iafzp/ilp32f |
For applications using Arch extensions that do not exist in the library, such as M and C extensions, their optimizations will be performed during the IR to assembly translation stage, so no optimizations will be missing. For certain Arch extensions, such as P and V extensions, since their optimizations are performed during C source code to IR translation, separate libraries must be created for them.
-mtune option
When specify -mtune=, ZCC will perform optimization on the target CPU. Arguments that can be used by -mtune= are listed below:
- THead
- thead-c908-series
- Andes
- andes-kavalan
- andes-vicuna
- andes-23-series
- andes-25-series
- andes-45-series
- andes-d25-series
- andes-d45-series
- Tenstorrent
- ascalon
- Nuclei
- nuclei-100-series
- nuclei-200-series
- nuclei-300-series
- nuclei-310-series
- nuclei-600-series
- nuclei-900-series
- nuclei-1000-series
- Rocket
- rocket
- Imagination
- rtxm2200
- Sifive
- sifive-7-series
- Syntacore
- syntacore-scr1-series
Optimization options
-
-O0, -O1, -O2, -O3, -OsSpecify which optimization level to use:
-
O0: Means “no optimization”: this level compiles the fastest and generates the most debuggable code.
-
O1: Somewhere between -O0 and -O2.
-
O2: Moderate level of optimization which enables most optimizations.
-
O3: Like -O2, except that it enables optimizations that take longer to perform or that may generate larger code (in an attempt to make the program run faster).
-
Os: Like -O2 with extra optimizations to reduce code size.
-
Troubleshooting
Link options incompatible with GCC
Specify compilation option files
-
GCC supports loading complex compilation option files through multiple
--specsoptions to override the default compilation behavior. Taking mculib as an example, commonly used specs files includenano.cfg,nosys.cfg,small.cfgandsemihost.specs, etc., which can be flexibly combined. -
ZCC uses the
--configoption to load a single combined configuration (*.cfg) file to specify compilation options. Since ZCC does not support using multiple--configoptions simultaneously, it provides single .cfg files containing combined configurations for newlib, such asnano-nosys.cfg,nano.cfg,nosys.cfg,sim.cfg, andsemihost.cfg, to meet the usage needs under different runtime environments.
Multi target
ZCC supports multi-target architectures, multi-instruction sets (multi-arch), and multiple ABIs (multi-abi). By default, it generates rv64imafdc/lp64d target code. To generate other types of target code, both -march= and -mabi= must be specified; otherwise, linking may fail.
Code model
ZCC supports the medany and medlow options, which are equivalent to the medium and small options in the GCC compiler for the RISC-V architecture, as shown in the table below.
| Code Model | ZCC | GCC | text/data/rodata |
|---|---|---|---|
| RISC-V architecture | medlow | small | Full 32-bit addressing space & The highest 2 GiB and the lowest 2 GiB in 64-bit addressing space |
| RISC-V architecture | medany | medium | Full 32-bit addressing space & PC ± 2 GiB in 64-bit addressing space |
linker script
-
The linker does not support the
DEFINEDmacro in the link script. For linker scripts that useDEFINED, modifications as below example need to be made:- __stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
+ __stack_size = 2K; -
The GNU
ldsupport for theMEMORYcommand in linker scripts can be referenced in the official documentation. Currently, ZCC supports most attributes of the MEMORYcommand, but does not yet support theI(initialization) attribute. Therefore, for linker scripts that use theIattribute, the following types of modifications are required to ensure compatibility:MEMORY
{
- ilm (rxai!w) : ORIGIN = 0x80000000, LENGTH = 64K
- ram (wxa!ri) : ORIGIN = 0x90000000, LENGTH = 64K
+ ilm (rxa!w) : ORIGIN = 0x80000000, LENGTH = 64K
+ ram (wxa!r) : ORIGIN = 0x90000000, LENGTH = 64K
} -
The linker scripts do not support the cumulative assignment syntax based on the current location (
.) used in GNUldoutput sections. Therefore, if you need to set an offset based on the current location within an output section, you must explicitly use absolute address expressions. For example, make adjustments as follows:.stack ORIGIN(ram) + LENGTH(ram) - __stack_size :
{
PROVIDE( _heap_end = . );
- . = __stack_size;
+ . += __stack_size;
PROVIDE( _sp = . );
} >ram AT>ram -
ZCC will compile the non-built-in sections in ldscripts into the
.datasection by default. If you need to put these sections into.bss, you can use the NOLOAD attribute. For example, thegcc_demosoc_ilm.ldcompilation script innuclei_sdkcan do the following for the.stackpart. Modify as below:- .stack ORIGIN(ram) + LENGTH(ram) - __stack_size :
+ .stack ORIGIN(ram) + LENGTH(ram) - __stack_size (NOLOAD) :
{
PROVIDE( _heap_end = . );
- . = __stack_size;
+ . += __stack_size;
PROVIDE( _sp = . );
} >ram AT>ram
} -
When an initialization function pointer is explicitly placed in a specific section via
__attribute__((section(".sec_abc"))), the compiler may treat the object as unused and remove it during optimization if it is not explicitly referenced in the C/C++ source. To prevent it from being optimized out, also add the used attribute to force the compiler to retain the object, e.g.,__attribute__((section(".sec_abc"), used)). -
When negative constants are used, GNU
as(GNU assembler) automatically sign-extends the immediate value based on the target architecture’s bit-width (32-bit or 64-bit). For example:
-
On RV32,
0xFFFFF800is interpreted as-2048. -
On RV64, GNU
asreports an error because the immediate value is out of range.
In contrast, the assembler in ZCC behaves differently: regardless of whether the target is RV32 or RV64, 0xFFFFF800 is always treated as a positive number, without automatic sign extension.
and a0, a0, 0xFFFFF800
Therefore, when writing assembly code with ZCC, negative immediates must be expressed explicitly with a - prefix. This usage also aligns with the description in the GNU Assembler User Guide
and a0, a0, -0x800
-
When using the
lldlinker, it does not support theALIGN_WITH_INPUTattribute at the output section level. If you need to control the alignment of an output section, you have to explicitly useALIGN(x)to specify it. For example- .data : ALIGN_WITH_INPUT
+ .data : ALIGN(8)
{
. = ALIGN(8)
...
} -
Behavioral differences when using linker options
-Mand-Maptogether.
-
With GCC, the behavior depends on the last option specified in the command line. For example:
-Wl,-M,-Map:-Maptakes effect.-Wl,-Map,-M:-Mtakes effect.
-
The behavior of ZCC is consistent with Clang: when both
-Mand-Mapare specified,-Mtakes precedence.
-
The libunwind library used by ZCCdepends on the addresses of the symbols
__eh_frame_start,__eh_frame_end,__eh_frame_hdr_start, and__eh_frame_hdr_end. When using a custom linker script, these symbols must be explicitly defined and initialized in the script to ensure proper runtime exception handling.eh_frame :
{
__eh_frame_start = .;
KEEP(*(.eh_frame))
__eh_frame_end = .;
}
.eh_frame_hdr :
{
KEEP(*(.eh_frame_hdr))
}
__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0;
__eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0;
Behavior different from GCC
Uninitialized local variables
Using uninitialized local variables in C/C++ results in undefined behavior because the value of uninitialized local variables may be 0, random memory values, or arbitrary values. If the source code makes use of uninitialized local variables, the assignment from different compilers might legitimately be different.
For example, in the code below, a is an uninitialized local variable. GCC initializes a to 0, while ZCC initializes a to 0xFFFFFFFF.
#include <stdio.h>
#include <stdlib.h>
void main()
{
unsigned int a, b;
b = 1;
a |= b;
printf("a %d, b %d\n", a, b);
}
Additionally, it's important to note that compilers' treatment of uninitialized local variables is not consistent. Therefore, you should not rely on compiler-specific behavior for variable initialization. For instance, in the example below, ZCC initializes a to 0.
#include <stdio.h>
#include <stdlib.h>
void main()
{
unsigned int a, b;
b = 1;
a &= b;
printf("a %d, b %d\n", a, b);
}
To avoid undefined behavior, you can use the -Wuninitialized flag during compilation. This enables warnings for the use of uninitialized local variables, allowing the compiler to notify you about potential issues.
Inline Behavior
By default, ZCC does not inline functions residing in different sections, even when they meet the inlining criteria. This restriction prevents potential runtime errors caused by address changes resulting from cross-section inlining, though it may impact performance.
If cross-section inlining is required, compile with the -mllvm --inline-func-from-different-sections flag. When this option is enabled, ZCC will inline eligible functions regardless of their section placement.
Get help
If you need help or have a question with any aspect of ZCC, feel free to discuss on 1nfinite developer forum. Our team is here to provide responses and enhance your user experience.
ZCC (Commercial)
We open issue tracking system for ZCC (Commercial) users. Please report bugs on ticket page of Terapines Support.

鄂公网安备 42018502007513