View Issue Details

IDProjectCategoryView StatusLast Update
0036236FPCCompilerpublic2019-11-01 09:53
ReporterDimitrios Chr. IoannidisAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOS10 OS Version1903
Product VersionProduct Build 
Target VersionFixed in Version3.3.1 
Summary0036236: AVR - Internal Error 20039041 with fpc trunk.
DescriptionCan't build FPC trunk for AVR.

IMHO, the 43319 rev. commit broke the AVR build somehow.
Steps To ReproduceTried to build a ppcrossavr with :

  "make.exe clean crossall crossinstall CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr5 INSTALL_PREFIX=G:\Programming\dimitris\tools\fpc-trunk CROSSBINDIR=G:\Programming\dimitris\tools\avr8-gnu-toolchain\bin CROSSOPT="-g -gw2 -O1 -dDEBUG" BINUTILSPREFIX=avr-"

and got :

"G:/Programming/dimitris/tools/svn/fpc/trunk/compiler/ppcrossavr.exe -Cpavr5 -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FDG:\Programming\dimitris\tools\avr8-gnu-toolchain\bin -FE. -FUG:/Programming/dimitris/tools/svn/fpc/trunk/rtl/units/avr-embedded -davr -dRELEASE -g -gw2 -O1 -dDEBUG -Us -Sg system.pp @system.cfg
int64.inc(411,7) Fatal: Internal error 200309041
Fatal: Compilation aborted
make.exe[4]: *** [system.ppu] Error 1
make.exe[4]: Leaving directory `G:/Programming/dimitris/tools/svn/fpc/trunk/rtl/embedded'
make.exe[3]: *** [embedded_all] Error 2
make.exe[3]: Leaving directory `G:/Programming/dimitris/tools/svn/fpc/trunk/rtl'
make.exe[2]: *** [rtl_all] Error 2
make.exe[2]: Leaving directory `G:/Programming/dimitris/tools/svn/fpc/trunk'
make.exe[1]: *** [build-stamp.avr-embedded] Error 2
make.exe[1]: Leaving directory `G:/Programming/dimitris/tools/svn/fpc/trunk'
G:\Programming\dimitris\tools\fpc-trunk\bin\x86_64-win64\make.exe: *** [crossall] Error 2"
Additional InformationFPC version used to build trunk

"Free Pascal Compiler version 3.3.1

Compiler date : 2019/07/25
Compiler CPU target: x86_64"
TagsAVR
Fixed in Revision43342
FPCOldBugId
FPCTarget-
Attached Files
  • system_.pas (1,549 bytes)
    unit system_;
    
    interface
    
    // The minimum required type declarations below
    type
      jmp_buf = packed record
      end;
      pjmp_buf = ^jmp_buf;
    
      PExceptAddr = ^TExceptAddr;
      TExceptAddr = record
      end;
    
      PGuid = ^TGuid;
      TGuid = packed record
         case longint of
            1 : (Data1 : longword;
                 Data2 : word;
                 Data3 : word;
                 Data4 : array[0..7] of byte;
                );
            2 : (
                 D1 : longword;
                 D2 : word;
                 D3 : word;
                 D4 : array[0..7] of byte;
                );
            3 : ( { uuid fields according to RFC4122 }
                 time_low : longword;			// The low field of the timestamp
                 time_mid : word;                      // The middle field of the timestamp
                 time_hi_and_version : word;           // The high field of the timestamp multiplexed with the version number
                 clock_seq_hi_and_reserved : byte;     // The high field of the clock sequence multiplexed with the variant
                 clock_seq_low : byte;                 // The low field of the clock sequence
                 node : array[0..5] of byte;           // The spatially unique node identifier
                );
      end;
    
    implementation
    
    function fpc_shl_qword(value: qword; shift: byte): qword; assembler; nostackframe;
    asm
    end;
    
    function fpc_mul_qword(f1,f2 : qword) : qword;
    var
      l : longint;
    begin
      fpc_mul_qword := 0;
    
      for l := 0 to 63 do
      begin
        if f2 <> 0 then
          fpc_mul_qword := fpc_mul_qword + f1;
        f1 := fpc_shl_qword(f1, 1);
      end;
    end;
    
    end.
    
    
    system_.pas (1,549 bytes)

Activities

Christo Crause

2019-10-31 18:21

reporter   ~0118944

Internal error confirmed for target AVR with r43341 - Linux 64 bit, starting compiler FPC 3.0.4

Christo Crause

2019-10-31 20:20

reporter   ~0118945

Attached a dummy system unit that triggers the internal error when compiled. Compiler command:
ppcrossavr -Cpavr5 -Tembedded -Pavr -XPavr- -O2 -n -Us system_.pas

Note that the internal error (using the dummy system unit) is only generated when optimization is set to -O2 or higher. Compiling with -O, -Os or -O1 does not trigger the internal error.

system_.pas (1,549 bytes)
unit system_;

interface

// The minimum required type declarations below
type
  jmp_buf = packed record
  end;
  pjmp_buf = ^jmp_buf;

  PExceptAddr = ^TExceptAddr;
  TExceptAddr = record
  end;

  PGuid = ^TGuid;
  TGuid = packed record
     case longint of
        1 : (Data1 : longword;
             Data2 : word;
             Data3 : word;
             Data4 : array[0..7] of byte;
            );
        2 : (
             D1 : longword;
             D2 : word;
             D3 : word;
             D4 : array[0..7] of byte;
            );
        3 : ( { uuid fields according to RFC4122 }
             time_low : longword;			// The low field of the timestamp
             time_mid : word;                      // The middle field of the timestamp
             time_hi_and_version : word;           // The high field of the timestamp multiplexed with the version number
             clock_seq_hi_and_reserved : byte;     // The high field of the clock sequence multiplexed with the variant
             clock_seq_low : byte;                 // The low field of the clock sequence
             node : array[0..5] of byte;           // The spatially unique node identifier
            );
  end;

implementation

function fpc_shl_qword(value: qword; shift: byte): qword; assembler; nostackframe;
asm
end;

function fpc_mul_qword(f1,f2 : qword) : qword;
var
  l : longint;
begin
  fpc_mul_qword := 0;

  for l := 0 to 63 do
  begin
    if f2 <> 0 then
      fpc_mul_qword := fpc_mul_qword + f1;
    f1 := fpc_shl_qword(f1, 1);
  end;
end;

end.

system_.pas (1,549 bytes)

Florian

2019-10-31 22:04

administrator   ~0118946

Last edited: 2019-11-01 09:53

View 2 revisions

I "fixed" it in r43342 by simplifying the affected function. The problem is that the register allocator does not consider (and it cannot) currently that the registers on avr are not orthogonal. So when heavy spilling happens, the compiler might get into an endless spilling loop as it spills always the same register and this results in the mentioned internalerror.

Dimitrios Chr. Ioannidis

2019-10-31 23:05

reporter   ~0118947

Thx Florian.

Issue History

Date Modified Username Field Change
2019-10-31 12:22 Dimitrios Chr. Ioannidis New Issue
2019-10-31 12:23 Dimitrios Chr. Ioannidis Tag Attached: AVR
2019-10-31 18:21 Christo Crause Note Added: 0118944
2019-10-31 20:20 Christo Crause File Added: system_.pas
2019-10-31 20:20 Christo Crause Note Added: 0118945
2019-10-31 22:04 Florian Assigned To => Florian
2019-10-31 22:04 Florian Status new => resolved
2019-10-31 22:04 Florian Resolution open => fixed
2019-10-31 22:04 Florian Fixed in Version => 3.3.1
2019-10-31 22:04 Florian Fixed in Revision => 43342
2019-10-31 22:04 Florian FPCTarget => -
2019-10-31 22:04 Florian Note Added: 0118946
2019-10-31 23:05 Dimitrios Chr. Ioannidis Status resolved => closed
2019-10-31 23:05 Dimitrios Chr. Ioannidis Note Added: 0118947
2019-11-01 09:53 Florian Note Edited: 0118946 View Revisions