I am using SDCC through Z88DK ZSDCC compiler. I have opened an issue for Z88DK as well: https://github.com/z88dk/z88dk/issues/1780
After the recent latest update of ZSDCC in Z88DK, when I try to compile my game Cross Snake
(https://github.com/Fabrizio-Caruso/CROSS-LIB), the compilation fails with:
games/snake/main.c:1237: warning 126: unreachable code
games/snake/main.c:1237: error 9: FATAL Compiler Internal Error in file 'gen.c'
line number '7196' : code generator internal error
Contact Author with source code
make: *** [Makefile.snake:1653: vz200_24k] Error 1
This can be reproduced by cloning my repo https://github.com/Fabrizio-Caruso/CROSS-LIB and running:
make vz200 -f Makefile.snake
I do not get this problem on the other games in the repository and I am not able, yet, to reproduce it with a smaller example. I know this problem is recent and most probably caused by the recent update.
To add some context:
Line 1237 is
return EXIT_SUCCESS;inint main(void).A possible first step towards a smaller example:
With very few exceptions, SDCC does not do inter-procedural optimization. So try to just put the function in which you see the problem into a file, along with all necessary macros and declarations.
It seems to be the main function. I could try to reduce the main function and compile until I get something that can be compiled.
The line that breaks the compilation is:
Hi Fabrizio trying to replicate with below code produces no error.
Does it work for you?
Is there some other trick to replicate the failure?
What I know is that if I remove that line:
https://github.com/Fabrizio-Caruso/CROSS-LIB/blob/master/src/games/snake/main.c#L932
I manage to compile my game with
make vz200_zsdcc -f Makefile.snake
I am not able to reproduce it with a smaller example but I know the single line that breaks it.
The same source code works fine with 15 other cross-compilers and native compilers (e.g., GCC) including SCCZ80.
Could you give us the function where compilation fails, in its own C source file (i.e. not depending on any includes other than the standard library that comes with sdcc)? I guess from there we could narrow it down.
What does "error 9" mean?
I am still getting this error on multiple Z80 targets in Z88DK.
I have spotted the single line that causes it but I don't know how to reproduce it because it problem won't show up with just that line.
error 9 means "FATAL Compiler Internal Error".
I.e. an error where the compiler is to blame, not your code.
P.S.: Also "FATAL", i.e. compilation aborts. SDCC also has non-fatal internal errors (warning 217), where correct code is still generated, but some optimizations might get disabled.
Last edit: Philipp Klaus Krause 2021-06-07
The issue is still present. I can reproduce it with zsdcc (contained in Z88DK) by:
(0) having
pythonand GNUmakeinstalled(1)
git clone https://github.com/Fabrizio-Caruso/CROSS-LIB(2) entering the
srcdirectory(3) running
xl snake vz200_zsdccor equivalentlymake zsdcc -f games/snake/Makefile.snakeIf I remove the line:
level_bonus = (uint16_t) (((uint16_t) snake_length)<<1)+(((uint16_t) energy)<<3) +(((uint16_t) coin_count)<<5) + (((uint16_t) level)<<2);the problem disappears but I cannot isolate it :-(
So it must also depend on something else that breaks.
Last edit: FabrizioCaruso 2022-02-13