View Issue Details

IDProjectCategoryView StatusLast Update
0011312FPCCompilerpublic2008-09-01 23:14
ReporterAbou Al MontacirAssigned ToFlorian 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version2.2.0Product Build 
Target Version2.2.2Fixed in Version2.2.2 
Summary0011312: FPC doesn't generate far (32 bit) calls for sparc
DescriptionLazarus bigide is not able to build on sparc machines (cf http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477743 for more information).

The issue is caused by FPC generating near call (22 bits) on SPARC machines instead of long calls (32 bits). This prevent huge applications like Lazarus to link.
Additional InformationThis issue was already discussed in core :

>>>> R_SPARC_WDISP22 against symbol `CLASSES_TCOMPONENT_$___RELEASE$$LONGINT'
>>>> defined in .text section
>>>> in /usr/lib/fpc/2.2.0/units/sparc-linux/rtl/classes.o
>>> Looks like the executbale is too big for sparc32.
>> This applies to sparc64 too.
>
> This was seen on a sparc64 machine

but with an FPC for 32 bit ...

>
>>> Can't help you with that. Never got such a
>> The interface helper simply need to do an indirect jump i.e. first load
>> the address to a register and then jump to this register.
>
> But how to decide if we need a far or a near jump?

Inter procedure: "far", there are only a few places where branches are
generated to do inter procedure jumps, calls are not limited to +/- 8 MB
Intra procedure: "near", this limits a procedure to a size of 8 MB of
code but this should no problem :)
TagsNo tags attached.
Fixed in Revision11000
FPCOldBugId0
FPCTarget-
Attached Files
  • test.pp (550 bytes)
    {$mode objfpc}
    type
      ii = interface
        procedure p;
      end;
    
      to1 = class(tinterfacedobject,ii)
        procedure p;virtual;
      end;
    
    var
      i : longint;
    
    procedure to1.p;
      begin
        inc(i);
      end;
    
    var
      a,b,c,d,e,f,g,h : longint;
      i1 : ii;
    begin
      i:=0;
      i1:=to1.create;
      for a:=1 to 1 do
        for b:=1 to a do
          for c:=1 to b do
           for d:=1 to c do
             for e:=1 to d do
               for f:=1 to e do
                 for g:=1 to f do
                   i1.p;
      if i<>1 then
        halt(1);
      writeln('ok');
    end.
    
    test.pp (550 bytes)

Activities

Abou Al Montacir

2008-05-17 11:50

manager   ~0019463

Last edited: 2008-05-17 12:13

A patch was already proposed but seems to break make cycle

> Finally I've applyed this one,
> but not yet tested as takes 3h for
> generating all packages on my old sparc station :(

Index: compiler/sparc/cgcpu.pas
===================================================================
--- compiler/sparc/cgcpu.pas (révision 10980)
+++ compiler/sparc/cgcpu.pas (copie de travail)
@@ -1350,7 +1350,14 @@
             list.concat(taicpu.op_reg(A_JMP,NR_L1));
           end
         else
- list.concat(taicpu.op_sym(A_BA,current_asmdata.RefAsmSymbol(procdef.mangledname)));
+ begin
+ reference_reset_symbol(href,current_asmdata.RefAsmSymbol(procdef.mangledname),0);
+ href.refaddr := addr_hi;
+ list.concat(taicpu.op_ref_reg(A_SETHI,href,NR_L1));
+ href.refaddr := addr_lo;
+ list.concat(taicpu.op_reg_ref_reg(A_OR,NR_G0,href,NR_L1));
+ list.concat(taicpu.op_reg(A_JMP,NR_L1));
+ end;
         { Delay slot }
         list.Concat(TAiCpu.Op_none(A_NOP));

Florian

2008-05-17 12:26

administrator   ~0019464

Can you try if the following helps? Only NR_L1 is replaced by NR_G1

Index: fpcsrc/compiler/sparc/cgcpu.pas
===================================================================
--- fpcsrc/compiler/sparc/cgcpu.pas (revision 9266)
+++ fpcsrc/compiler/sparc/cgcpu.pas (working copy)
@@ -1347,7 +1347,14 @@
list.concat(taicpu.op_reg(A_JMP,NR_L1));
end
else
- list.concat(taicpu.op_sym(A_BA,current_asmdata.RefAsmSymbol(procdef.mangledname)));
+ begin
+ reference_reset_symbol(href,current_asmdata.RefAsmSymbol(procdef.mangledname),0);
+ href.refaddr := addr_hi;
+ list.concat(taicpu.op_ref_reg(A_SETHI,href,NR_G1));
+ href.refaddr:=addr_lo;
+ list.concat(taicpu.op_reg_ref_reg(A_OR,NR_G0,href,NR_G1));
+ list.concat(taicpu.op_reg(A_JMP,NR_G1));
+ end;
{ Delay slot }
list.Concat(TAiCpu.Op_none(A_NOP));

Abou Al Montacir

2008-05-17 21:32

manager   ~0019467

Last edited: 2008-05-17 21:34

1st Patch applyed in r10988 on 2.3.1. The make cycle is OK. Will wait for test suite results before merging to 2.2.1.

Florian

2008-05-17 21:39

administrator   ~0019468

I think the 1st patch is not good. L1 shouldn't be destroyed by the wrapper because it is stored only afterwards.

2008-05-17 21:47

 

test.pp (550 bytes)
{$mode objfpc}
type
  ii = interface
    procedure p;
  end;

  to1 = class(tinterfacedobject,ii)
    procedure p;virtual;
  end;

var
  i : longint;

procedure to1.p;
  begin
    inc(i);
  end;

var
  a,b,c,d,e,f,g,h : longint;
  i1 : ii;
begin
  i:=0;
  i1:=to1.create;
  for a:=1 to 1 do
    for b:=1 to a do
      for c:=1 to b do
       for d:=1 to c do
         for e:=1 to d do
           for f:=1 to e do
             for g:=1 to f do
               i1.p;
  if i<>1 then
    halt(1);
  writeln('ok');
end.
test.pp (550 bytes)

Florian

2008-05-17 21:48

administrator   ~0019469

Can you please test, if test.pp writes 'ok'?

Issue History

Date Modified Username Field Change
2008-05-17 11:43 Abou Al Montacir New Issue
2008-05-17 11:50 Abou Al Montacir Note Added: 0019463
2008-05-17 12:13 Abou Al Montacir Note Edited: 0019463
2008-05-17 12:26 Florian Note Added: 0019464
2008-05-17 21:32 Abou Al Montacir Note Added: 0019467
2008-05-17 21:34 Abou Al Montacir Note Edited: 0019467
2008-05-17 21:34 Abou Al Montacir Note Edited: 0019467
2008-05-17 21:39 Florian Note Added: 0019468
2008-05-17 21:47 Florian File Added: test.pp
2008-05-17 21:48 Florian Note Added: 0019469
2008-05-18 14:41 Florian Fixed in Revision => 11000
2008-05-18 14:41 Florian Status new => resolved
2008-05-18 14:41 Florian Fixed in Version => 2.2.1
2008-05-18 14:41 Florian Resolution open => fixed
2008-05-18 14:41 Florian Assigned To => Florian
2008-05-18 15:29 Florian FPCOldBugId => 0
2008-05-18 15:29 Florian FPCTarget => -
2008-05-18 15:29 Florian Target Version => 2.2.1
2008-05-18 15:30 Florian Target Version 2.2.1 => 2.2.0
2008-05-18 15:31 Florian Target Version 2.2.0 => 2.2.2
2008-09-01 23:14 Jonas Maebe Status resolved => closed
2008-09-01 23:14 Jonas Maebe Fixed in Version 2.2.1 => 2.2.2