VF2编译Godot遇到问题,疑似编译器问题

使用GCC和Clang都会出现如下错误

openkylin@openkylin:~/godot$ scons use_llvm=yes -j3
scons: Reading SConscript files ...
Automatically detected platform: linuxbsd
Building for platform "linuxbsd", architecture "rv64", target "editor".
Checking for C header file mntent.h... yes
scons: done reading SConscript files.
scons: Building targets ...
[ 96%] Linking Program bin/godot.linuxbsd.editor.rv64.llvm ...
[100%] progress_finish(["progress_finish"], [])
[100%] drivers/libdrivers.linuxbsd.editor.rv64.llvm.a(rendering_device_vulkan.linuxbsd.editor.rv64.llvm.o): in function `.LBB173_7':
rendering_device_vulkan.cpp:(.text+0x3d39e): relocation truncated to fit: R_RISCV_BRANCH against `.LBB177_194'
servers/libservers.linuxbsd.editor.rv64.llvm.a(render_forward_mobile.linuxbsd.editor.rv64.llvm.o): in function `.LBB6_20':
render_forward_mobile.cpp:(.text+0xa16): relocation truncated to fit: R_RISCV_BRANCH against `.LBB6_339'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [bin/godot.linuxbsd.editor.rv64.llvm] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:11:06.292]

openkylin@openkylin:~/godot$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-linux-gnu/13/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Openkylin 13.2.0-4ok3.3' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=8
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Openkylin 13.2.0-4ok3.3) 

openkylin@openkylin:~/godot$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-linux-gnu/13/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Openkylin 13.2.0-4ok3.3' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=8
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Openkylin 13.2.0-4ok3.3) 

openkylin@openkylin:~/godot$ clang -v
Openkylin clang version 15.0.7
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/12
Found candidate GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/13
Found candidate GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/13

1 Like
  1. This is English forum, speak English pls.
  2. Try add -mcmodel=medany and/or -mno-relax to CFLAGS
  3. Try update clang to newset version. and binutils/lld too (depend on which you use) .
  4. Try add -Os -g0 to CFLAGS.

This is a RISC-V Design issue… :face_exhaling:

1 Like

Could you elaborate a bit on why that is a RISC-V design issue? I’m just curious :wink:

TOO SMALL.

A 64bit system with a lot of shortest address length.
I remember R_RISCV_BRANCH is 13bit only.

1 Like

If that leads to problems, it’s most probably a compiler issue. 13 bits means +/- 4096 bytes jump length, that should be sufficient.

1 Like

Sv32 have 4G size. 8k is realy enough?

1 Like

It is, because memory nowadays is virtually managed bei a MMU, you don’t see the 4GB as a whole in flat memory layout. Compiler nowadays are optimizing jumps anyways. Now, RISC-V code is still not that fine graned optimized as e.g. x86 is. And system calls are handled via the ecall instruction and not calls or far jumps.

Does RISC-V support far jumps?
I remember on x86, some tables are up to 4G size. mips is small, but support multi-page tables.

All apps have their own Sv32 space with virtual address.
And… There have Sv39/Sv47/Sv57. VF2 have 8G mem, SV32 is not enough. With Sv39 , there have 512G mem size.

For those occasions, setjmp/longjmp kind of implementation are used, if really needed.
Have a look here: setjmp/longjmp

1 Like

But RISC-V ABI is not use this. TOO_SMALL is still a design issue.
If ABI use this , apps will got big perfomance loss.
Now, riscv is still have 4G code memory limitation.
:face_exhaling:

PS: With mcmany , code can jump ±2G mem. But it can not jump to data mem block. This means the code mems must be put to together. the PIC/PIE will not work with this.

no, it doesn’t…and remember, there are 32,64 and 128 bit versions of the ISAs!
e.g a jump to a 64bit address:

la t0, some_function_addr
ld t0, 0(t0)
jalr t0

And since this is a 64 bit register in 64bit version of the ISA, you can jump 64bits wide.
No restriction at all.

The limitation is riscv64 is still use 20+12bit to record funcitons address. :face_exhaling:
Do not forget R_RISCV_BRANCH is only 13bit.

I remember there is only 2 instructions space in the fuctions call table.

They are talking about new code model to reslove this issue:

If GL is softpipe anyway why bother with Godot?

Or did glxinfo / glxgears actually start using the GPU in May release?