eclipse-embed-cdt / eclipse-plugins

The Eclipse Embedded CDT plug-ins for Arm & RISC-V C/C++ developers (formerly known as the GNU MCU Eclipse plug-ins). Includes the archive of previous plug-ins versions, as Releases.
http://eclipse-embed-cdt.github.io/
Eclipse Public License 2.0
554 stars 130 forks source link

RISC-V template projects need updating for canonical architecture string changes in toolchain #553

Closed TommyMurphyTM1234 closed 1 year ago

TommyMurphyTM1234 commented 1 year ago

Tools used (on Zorin OS Lite 16.2 - a Ubuntu 20.02 LTS derivative)

  1. Eclipse IDE for Embedded C/C++ Developers (includes Incubating components) Version: 2022-12 (4.26.0) Build id: 20221201-1913
  2. riscv-none-elf-gcc (xPack GNU RISC-V Embedded GCC x86_64) 12.2.0

Issue

  1. Create an example RISC-V project - SiFive HiFive1 blinky

  2. Try to compile

  3. Compilation fails with the errors below.

    ../xpacks/micro-os-plus-riscv-arch/include/riscv-arch/csr-functions-inlines.h: Assembler messages:
    ../xpacks/micro-os-plus-riscv-arch/include/riscv-arch/csr-functions-inlines.h:288: Error: unrecognized opcode `csrr a5,mcycle'
    ../xpacks/micro-os-plus-riscv-arch/include/riscv-arch/csr-functions-inlines.h:288: Error: unrecognized opcode `csrr a5,mcycle'
    ../xpacks/micro-os-plus-riscv-arch/include/riscv-arch/csr-functions-inlines.h:312: Error: unrecognized opcode `csrr a5,mcycleh'
    make: *** [xpacks/micro-os-plus-riscv-arch/src/subdir.mk:33: xpacks/micro-os-plus-riscv-arch/src/arch-functions.o] Error 1
    "make all" terminated with exit code 2. Build might be incomplete.
    19:26:02 Build Failed. 4 errors, 0 warnings. (took 2s.226ms)

    Workaround

  4. Add _zicsr to the Other extensions settings (Project > Properties > C/C++ Build > Settings > Tool Settings > Target Processor > Other extensions). To be completely correct _zicsr_zidfencei should be added but the zifencei extensions is not relevant for this specific project.

Explanation

  1. As some time in the recent past the RISC-V tools moved from one standard for RISC-V architecture strings to another, a canonical one. This means that what used to simply be specified as, say, rv32gc is now properly specified as rv32gd_zicsr or maybe rv32gc_zicsr_zifencei.
  2. I spoke to @ilg-ul about this and he said that some or all RISC-V project templates will need to be updated to add the required Other extensions project settings to match the latest RISC-V toolchain and ensure that the projects compile and link out of the box. Unfortunately this will mean that newer project templates will not work with older toolchains until the relevant Other extensions are removed from the project settings.
ilg-ul commented 1 year ago

Fixed on 2023-04-26.