sipeed / TangNano-9K-example

TangNano-9K-example project
211 stars 66 forks source link

Failed to build the project on a Raspberry Pi 3b+ running Debian 11 aarch64 #4

Open kyonmiriam opened 2 years ago

kyonmiriam commented 2 years ago

When the attached is compiled as follows, it generates an ICE: during GIMPLE pass: pcom isp_flasher.c: In function 'main': isp_flasher.c:125:5: internal compiler error: tree check: expected ssa_name, have integer_cst in ptr_deref_may_alias_decl_p, at tree-ssa-alias.c:241 125 | int main() | ^~~~ 0x7f9f82e217 __libc_start_main ../csu/libc-start.c:308 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See https://github.com/sifive/freedom-tools/issues/ for instructions. make[1]: [Makefile:110: build/isp_flasher.o] Error 1 make[1]: Leaving directory '/home/pi/TangNano-9K-example/picotiny/fw/fw-brom' make: [Makefile:24: brom] Error 2

And here is the information of the gcc: $ riscv-none-embed-gcc -v Using built-in specs. COLLECT_GCC=riscv-none-embed-gcc COLLECT_LTO_WRAPPER=/home/pi/.local/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/10.2.0-1.2.1/bin/../libexec/gcc/riscv-none-embed/10.2.0/lto-wrapper Target: riscv-none-embed Configured with: /Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/sources/riscv-gcc-10.2.0-1.1/configure --prefix=/Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/install/riscv-none-embed-gcc --infodir=/Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/install/riscv-none-embed-gcc/share/doc/info --mandir=/Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/install/riscv-none-embed-gcc/share/doc/man --htmldir=/Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/install/riscv-none-embed-gcc/share/doc/html --pdfdir=/Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/install/riscv-none-embed-gcc/share/doc/pdf --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu --target=riscv-none-embed --with-pkgversion='xPack GNU RISC-V Embedded GCC aarch64' --with-bugurl=https://github.com/sifive/freedom-tools/issues/ --enable-languages=c,c++ --disable-mingw-wildcard --enable-plugins --enable-lto --enable-checking=yes --disable-tls --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-threads --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-riscv-none-embed --with-sysroot=/Host/home/ilg/Work/riscv-none-embed-gcc-10.2.0-1.2/linux-arm64/install/riscv-none-embed-gcc/riscv-none-embed --with-native-system-header-dir=/include --with-abi=ilp32 --with-arch=rv32imac --disable-build-format-warnings --with-system-zlib Thread model: single Supported LTO compression algorithms: zlib gcc version 10.2.0 (xPack GNU RISC-V Embedded GCC aarch64)

The attached code compiles OK with a x86_64 linux host with the gcc has the same version number.

nekomona commented 2 years ago

Still unsure about how the host platform affected this problem, but the same issue could be observed in riscv64-unknown-elf gcc 10.2.0 in a x86_64 linux host.

It seems that the blind goto function pointer inside switch-case would trigger some label detection mechanism inside gcc. Replacing goto with direct calls to the function pointers in 66c9ef67b9134ff2b4a7a088361c94fac228eebe have solved this issue and should also work for rpi gcc XD