Re: Backend initialization on RISC-V

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 7/10/25 12:41 AM, Simon Richter wrote:
Hi,

I'd like to get GHDL working on riscv64 again, this builds an extra GCC backend, "ghdl1", which works on most architectures, however here it generates a few invalid assembler directives, so the build fails after gcc has been built and installed, during the first invocation of the newly built backend:

for i in std/v87/textio.vhdl std/v87/textio-body.vhdl; do \
  cmd=" /build/ghdl-5.0.1+dfsg/builddir/gcc/build/gcc/ghdl -a --GHDL1=/ build/ghdl-5.0.1+dfsg/builddir/gcc/build/gcc/ghdl1  --std=87 --bootstrap --work=std ../../src/$i"; \
   echo $cmd; eval $cmd || exit 1; \
done
/build/ghdl-5.0.1+dfsg/builddir/gcc/build/gcc/ghdl -a --GHDL1=/build/ ghdl-5.0.1+dfsg/builddir/gcc/build/gcc/ghdl1 --std=87 --bootstrap -- work=std ../../src/std/v87/textio.vhdl
textio.s: Assembler messages:
textio.s:3: Error: the architecture string of -march and elf architecture attributes cannot be empty
/build/ghdl-5.0.1+dfsg/builddir/gcc/build/gcc/ghdl:error: compilation error
make[3]: *** [../../libraries/Makefile.inc:187: lib/ghdl/gcc/vhdl/std/ v87/std-obj87.cf] Error 1
make[3]: Leaving directory '/build/ghdl-5.0.1+dfsg/builddir/gcc'
make[2]: *** [Makefile:334: libs.vhdl.gcc] Error 2
make[2]: Leaving directory '/build/ghdl-5.0.1+dfsg/builddir/gcc'
make[1]: *** [debian/rules:261: /build/ghdl-5.0.1+dfsg/builddir/stamps/ build-gcc] Error 2
make[1]: Leaving directory '/build/ghdl-5.0.1+dfsg'
make: *** [debian/rules:61: binary] Error 2

The generated source file begins with

         .file   "textio.vhdl"
         .option pic
         .attribute arch, ""
         .attribute unaligned_access, 0
         .attribute stack_align, 16
         .text
         .section        .rodata
         .align  2

so it is fairly obvious what is going wrong here: the RISC-V architecture string is not initialized, and the backend defaults to 32 bit with no extensions. Manually specifying "- march=rv64imafdc_zicsr_zifencei -mabi=lp64d" (i.e. the defaults of the native compiler) on the ghdl1 command line causes it to correctly emit

         .file   "textio.vhdl"
         .option pic
        .attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0"
         .attribute unaligned_access, 0
         .attribute stack_align, 16
         .text
         .section        .rodata
         .align  3

Is this a bug in the out-of-tree frontend initializing the backend incorrectly, or should the compiler driver that invokes the frontend always specify arch/abi on RISC-V?
Yes, this sounds like a problem in your ghdl bits. It should always be emitting arch strings. Otherwise the rest of the tools have no way of knowing the exact architecture you're targeting.



Jeff




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux