Use compiler optimization for c68kexec.c #444
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In riscv64,
gcc
generates unlinkable ELF forc68kexec.c
, causing yabause fails to build.This is a GCC bug. For long branches over 1MiB, RISC-V requires an indirect branch sequence (
auipc
+jalr
) instead a direct branch (j
). But GCC can only generate aj
with an overflowed operand now. The jumpif (!C68k_Initialised) goto C68k_Init;
crosses almost the entire function body, which is over 1MiB in riscv64, so we will encounter this bug.yabause/yabause/src/c68k/c68kexec.c
Line 207 in 7e38821
yabause/yabause/src/c68k/c68kexec.c
Lines 323 to 332 in 7e38821
Enabling compiler optimization (specifically
-freorder-blocks
) allows GCC to reorder theC68k_Init
block to the front of the function, so there won't be a long branch, and yabause will build successfully.I noticed compiler optimization is disabled for
c68kexec.c
on purpose. Does any code depend on disabling compiler optimizations? Maybe there is something I can help with?