https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113469
Bug ID: 113469 Summary: RISC-V: Illegal Insn for test case 920501-8.c when make linux for rv32 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pan2.li at intel dot com Target Milestone: --- The test case will have illegal instruction when `make linux` build of the repo riscv-gnu-toolchain for rv32. 1. Build. ../__RISC-V_INSTALL___RV32/bin/riscv32-unknown-linux-gnu-gcc gcc/testsuite/gcc.c-torture/execute/920501-8.c -march=rv32gcv -mabi=ilp32d -mtune=rocket -mcmodel=medlow -fdiagnostics-plain-output -O2 -w -lm -o ./920501-8.elf -static 2. Run with qemu ../build-qemu/qemu-riscv32 -cpu rv32,vlen=512,v=true,vext_spec=v1.0 920501-8.elf Illegal instruction (core dumped) 3. When enter function __printf_buffer (comes from libc.a), it will go to insn like below for the first insn __printf_buffer: auipc a5,0x5f => directly jump to the vmv insn and then illegal insn met. ... vmv.v.i.v1,0 4. After some investigation, the function __printf_buffer should be the function Xprintf_buffer in glibc/stdio-common/vfprintf-internal.c. You can use the below command to compile it. cd glibc/stdio-common/ ../../__RISC-V_INSTALL___RV32/bin/riscv32-unknown-linux-gnu-gcc vfprintf-internal.c \ -c -std=gnu11 -fgnu89-inline -mcmodel=medlow -O2 -Wall -Wwrite-strings -Wundef \ -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wstrict-prototypes -Wold-style-definition \ -fmath-errno -fPIE -ftls-model=initial-exec -I../include \ -I/home/pli/gcc/444/riscv-gnu-toolchain/build-glibc-linux-rv32gcv-ilp32d/stdio-common \ -I/home/pli/gcc/444/riscv-gnu-toolchain/build-glibc-linux-rv32gcv-ilp32d -I../sysdeps/unix/sysv/linux/riscv/rv32 \ -I../sysdeps/unix/sysv/linux/riscv -I../sysdeps/riscv/nptl -I../sysdeps/unix/sysv/linux/generic/wordsize-32 \ -I../sysdeps/unix/sysv/linux/generic -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux \ -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv \ -I../sysdeps/unix -I../sysdeps/posix \ -I../sysdeps/riscv/rv32/rvd -I../sysdeps/riscv/rv32/rvf -I../sysdeps/riscv/rvf \ -I../sysdeps/riscv/rvd -I../sysdeps/riscv/rv32 -I../sysdeps/riscv \ -I../sysdeps/ieee754/ldbl-128 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 \ -I../sysdeps/wordsize-32 -I../sysdeps/ieee754 -I../sysdeps/generic \ -I.. -I../libio -I. -nostdinc -isystem /home/pli/gcc/444/riscv-gnu-toolchain/__RISC-V_INSTALL___RV32/lib/gcc/riscv32-unknown-linux-gnu/14.0.1/include \ -isystem /home/pli/gcc/444/riscv-gnu-toolchain/__RISC-V_INSTALL___RV32/lib/gcc/riscv32-unknown-linux-gnu/14.0.1/include-fixed \ -isystem /home/pli/gcc/444/riscv-gnu-toolchain/linux-headers/include \ -D_LIBC_REENTRANT -include /home/pli/gcc/444/riscv-gnu-toolchain/build-glibc-linux-rv32gcv-ilp32d/libc-modules.h \ -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC \ -DTOP_NAMESPACE=glibc -D_IO_MTSAFE_IO -o test.o