Menu

#3232 FATAL Compiler Internal Error in file 'gen.c

open
nobody
Z80
5
2022-02-13
2021-05-10
No

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.

Discussion

  • Benedikt Freisen

    To add some context:
    Line 1237 is return EXIT_SUCCESS; in int main(void).

     
  • Philipp Klaus Krause

    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.

     
  • FabrizioCaruso

    FabrizioCaruso - 2021-05-16

    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.

     
  • FabrizioCaruso

    FabrizioCaruso - 2021-05-16

    The line that breaks the compilation is:

    level_bonus = (uint16_t) (((uint16_t) snake_length)<<1)+(((uint16_t) energy)<<3) +(((uint16_t) coin_count)<<5) + (((uint16_t) level)<<2); 
    
     
  • Philipp Klaus Krause

    • Category: other --> Z80
     
  • Phillip Stevens

    Phillip Stevens - 2021-05-19

    Hi Fabrizio trying to replicate with below code produces no error.

    #include <stdint.h>
    
    // > sdcc 3232.c -mz80
    
    int main(void)
    {
        uint16_t level_bonus;
        uint16_t snake_length, energy, coin_count, level;
    
        level_bonus = (uint16_t) (((uint16_t) snake_length)<<1) + (((uint16_t) energy)<<3) + (((uint16_t) coin_count)<<5) + (((uint16_t) level)<<2); 
    
        return level_bonus;
    }
    

    Does it work for you?
    Is there some other trick to replicate the failure?

     
  • FabrizioCaruso

    FabrizioCaruso - 2021-05-19

    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.

     
    • Philipp Klaus Krause

      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.

       
  • FabrizioCaruso

    FabrizioCaruso - 2021-06-04

    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.

     
    • Philipp Klaus Krause

      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
  • FabrizioCaruso

    FabrizioCaruso - 2022-02-13

    The issue is still present. I can reproduce it with zsdcc (contained in Z88DK) by:
    (0) having python and GNU make installed
    (1) git clone https://github.com/Fabrizio-Caruso/CROSS-LIB
    (2) entering the src directory
    (3) running xl snake vz200_zsdcc or equivalently make zsdcc -f games/snake/Makefile.snake

    If 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

Log in to post a comment.

MongoDB Logo MongoDB