cgccembeddedriscvriscv32

GNU RISC-V Embedded GCC throws "x ISA extension `xw' must be set with the versions" error


I can build the c-files from my WCH CH32V003F4P6 microcontroller project with the GNU RISC-V Embedded GCC v8.2.0 toolchain shipped with the Eclipse IDE from WCH (MounRiver Studio). However, if I try to build the same c-files with a similar toolchain downloaded here (see https://xpack.github.io/dev-tools/riscv-none-elf-gcc/releases/), then I get incomprehensible errors like:

Error: x ISA extension 'xw' must be set with the versions

or

cc1.exe: error: -march=rv32ecxw: unsupported ISA substring 'xw'

Reproduce the problem

To reproduce the problem, you should:

Let's now compile the main.c file from the GPIO_Toggle project, like this:

> "C:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc"
    -march=rv32ecxw
    -mabi=ilp32e
    -msmall-data-limit=0
    -msave-restore
    -fsigned-char
    -fno-common
    -Wunused
    -Wuninitialized
    -Og
    -g3
    -fmessage-length=0
    -ffunction-sections
    -fdata-sections
    -Wno-comment
    -Wno-unused-function
    -std=gnu99
    -Werror-implicit-function-declaration
    -I"C:/CH32V003EVT/EVT/EXAM/SRC/Core"
    -I"C:/CH32V003EVT/EVT/EXAM/SRC/Debug"
    -I"C:/CH32V003EVT/EVT/EXAM/SRC/Peripheral/inc"
    -I"C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/User"
    "C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/User/main.c"
    -o "C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/build/main.o"
    -c

This should work.

Let's try with a few other toolchains. Download some GNU RISC-V Embedded GCC toolchains from here: https://xpack.github.io/dev-tools/riscv-none-elf-gcc/releases/

Unzip them to your C:/ drive:

enter image description here

Now invoke the same compilation command with each of these toolchains:

> "C:/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32/bin/riscv-none-embed-gcc"
    -march=rv32ecxw
    -mabi=ilp32e
    -...
> "C:/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x64/bin/riscv-none-embed-gcc"
    -march=rv32ecxw
    -mabi=ilp32e
    -...
> "C:/xpack-riscv-none-elf-gcc-12.2.0-3-win32-x64/bin/riscv-none-elf-gcc"
    -march=rv32ecxw
    -mabi=ilp32e
    -...

I got these obscure errors:

I can't wrap my head around them.

Compare the toolchains

As a first reaction, I compare the toolchains. The one from MounRiver Studio outputs the following for --version:

> "C:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc" --version
riscv-none-embed-gcc (xPack GNU RISC-V Embedded GCC, 32-bit) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I get the exact same output from one of the other toolchains:

> "C:/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32/bin/riscv-none-embed-gcc" --version
riscv-none-embed-gcc (xPack GNU RISC-V Embedded GCC, 32-bit) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So they must be identical, no? How then is it possible that the one from MounRiver works and the other one doesn't?


Solution

  • The xPack GNU RISC-V Embedded GCC supports only the standard RISC-V extensions. The 'xw' extension is custom one, added by WCH for their own designs, and is supported only by their custom toolchain.