View Issue Details

IDProjectCategoryView StatusLast Update
0038054FPCCompilerpublic2020-11-08 23:46
Reporterhapr41 Assigned ToJonas Maebe  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSsuse linux sles 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0038054: 64 bit ability incomplete
Descriptionhw: x86_64 4GiBy ram + 3GiBy swap
os: suse linux sles-15.1 kern 4.12.14 x86_64
fpc: 3.0.4 AND 3.2.0 x86_64

the fpc-versions mentioned above can not handle a program if....
(a) total size of static vars (main prog.) >= 2 GiBy
or
(b) there is one (or more) dynamic var (heap) >= 2 GiBy

example
for(a):
      st1.pas 1 static var 2000|2100 MiBy = 1.95|2.05 GiBy
      st3.pas 3 static vars 2000|2100 MiBy = 1.95|2.05 GiBy total
for(b):
      dn.pas 1 dynamic var 2000|2100 MiBy = 1.95|2.05 GiBy

if the size is 1.95 GiBy, the program compiles,links,runs well.
if the size is 2.05 GiBy, compiling or linking shows errors:
look at file st.txt for(a), dn.txt for(b).

(a 'c' program with 5 GiBy static or dynamic var runs well, in the same system.)

what is wrong?
TagsNo tags attached.
Fixed in Revision47355
FPCOldBugId
FPCTarget-
Attached Files

Activities

hapr41

2020-11-08 23:18

reporter  

dn.pas (208 bytes)   
const
   l = 1024*1024 * 2100 ;	//   2000  <-->  2100
type
   t = array[ 1..l ]of int8;	//   1.95  <-->  2.05  GiBy
var
   p: ^t;
begin
   new(p);
   writeln( sizeof(p^) );
   p^[l]:=0;  writeln(p^[l])
end .
dn.pas (208 bytes)   
dn.txt (1,220 bytes)   
-------------------------------------------------------------------------------
				dn.pas    2100 MiBy = 2.05 GiBy    3.0.4
Target OS: Linux for x86-64
Compiling dn.pas
dn.pas(8,9) Error: range check error while evaluating constants (2306867200 must be between -2147483648 and 2147483647)
dn.pas(8,9) Error: range check error while evaluating constants (-1988100096 must be between 0 and 18446744073709551615)
dn.pas(12) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
Error: /opt/fpc/fpc-3-0-4-64/bin/ppcx64 returned an error exitcode
-------------------------------------------------------------------------------
				dn.pas    2100 MiBy = 2.05 GiBy    3.2.0
Target OS: Linux for x86-64
Compiling dn.pas
dn.pas(8,9) Error: range check error while evaluating constants (2306867200 must be between -2147483648 and 2147483647)
dn.pas(8,9) Error: range check error while evaluating constants (-1988100096 must be between 0 and 18446744073709551615)
dn.pas(12) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
Error: /opt/fpc/fpc-3-2-0-64/bin/ppcx64 returned an error exitcode
-------------------------------------------------------------------------------
dn.txt (1,220 bytes)   
st.txt (2,767 bytes)   
-------------------------------------------------------------------------------
				st1.pas   1*2100 MiBy = 2.05 GiBy   3.0.4
Target OS: Linux for x86-64
Compiling st1.pas
Linking st1
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
st1.pas(8,1) Error: Error while linking
st1.pas(8,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /opt/fpc/fpc-3-0-4-64/bin/ppcx64 returned an error exitcode

-------------------------------------------------------------------------------
				st1.pas   1*2100 MiBy = 2.05 GiBy   3.2.0
Target OS: Linux for x86-64
Compiling st1.pas
Linking st1
/opt/fpc/fpc-3-2-0-64/lib/fpc/3.2.0/units/x86_64-linux/rtl/system.o: in function `SYSTEM_$$_SETUPENTRYINFORMATION$TENTRYINFORMATION':
system.pp:(.text.n_system_$$_setupentryinformation$tentryinformation+0xb): relocation truncated to fit: R_X86_64_PC32 against `.bss.n_u_$system_$$_entryinformation'
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
st1.pas(8,1) Error: Error while linking
st1.pas(8,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /opt/fpc/fpc-3-2-0-64/bin/ppcx64 returned an error exitcode

-------------------------------------------------------------------------------
				st3.pas   3*700 MiBy = 2.05 GiBy   3.0.4
Target OS: Linux for x86-64
Compiling st3.pas
Linking st3
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
st3.pas(10,1) Error: Error while linking
st3.pas(10,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /opt/fpc/fpc-3-0-4-64/bin/ppcx64 returned an error exitcode

-------------------------------------------------------------------------------
				st3.pas   3*700 MiBy = 2.05 GiBy   3.2.0
Target OS: Linux for x86-64
Compiling st3.pas
Linking st3
st3.o: in function `main':
st3.pas:(.text.n_main+0xb6): relocation truncated to fit: R_X86_64_32S against `.bss.n_u_$p$program_$$_ar3'
st3.pas:(.text.n_main+0xc8): relocation truncated to fit: R_X86_64_32S against `.bss.n_u_$p$program_$$_ar3'
/opt/fpc/fpc-3-2-0-64/lib/fpc/3.2.0/units/x86_64-linux/rtl/system.o: in function `SYSTEM_$$_SETUPENTRYINFORMATION$TENTRYINFORMATION':
system.pp:(.text.n_system_$$_setupentryinformation$tentryinformation+0xb): relocation truncated to fit: R_X86_64_PC32 against `.bss.n_u_$system_$$_entryinformation'
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
st3.pas(10,1) Error: Error while linking
st3.pas(10,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /opt/fpc/fpc-3-2-0-64/bin/ppcx64 returned an error exitcode

-------------------------------------------------------------------------------
st.txt (2,767 bytes)   
st1.pas (184 bytes)   
const
   l = 1024*1024 * 2100 ;	//   2000  <-->  2100
var
   ar: array[ 1..l ]of int8;	//   1.95  <-->  2.05  GiBy
begin
   writeln( sizeof(ar) );
   ar[l]:=0;  writeln( ar[l] )
end .
st1.pas (184 bytes)   
st3.pas (288 bytes)   
const
   l = 1024*1024 * 700 ;	//   667 = 2000/3   <-->   700 = 2100/3 
var
   ar1,ar2,ar3: array[ 1..l ]of int8;	//   1.95  <-->  2.05 GiBy  total
begin
   writeln( sizeof(ar1) );
   ar1[l]:=0;  writeln( ar1[l] );
   ar2[l]:=0;  writeln( ar2[l] );
   ar3[l]:=0;  writeln( ar3[l] )
end .
st3.pas (288 bytes)   

Jonas Maebe

2020-11-08 23:46

manager   ~0126806

I have fixed the dn.pas issue. You can work around it by calling getmem() directly instead of using "new".

st1 (static data with a single element that is > 2GB) is indeed not supported in FPC:
1) not all 64 bit operating systems support this
2) the ones that do support it require special, slower code to be generated when you want to use this

In real world programs, you will almost never want to declare such large static data elements. And when you do, it is trivial to use a dynamically allocated one instead. Since it is additionally not portable and slower, we have opted not to support this.

Issue History

Date Modified Username Field Change
2020-11-08 23:18 hapr41 New Issue
2020-11-08 23:18 hapr41 File Added: dn.pas
2020-11-08 23:18 hapr41 File Added: dn.txt
2020-11-08 23:18 hapr41 File Added: st.txt
2020-11-08 23:18 hapr41 File Added: st1.pas
2020-11-08 23:18 hapr41 File Added: st3.pas
2020-11-08 23:46 Jonas Maebe Assigned To => Jonas Maebe
2020-11-08 23:46 Jonas Maebe Status new => resolved
2020-11-08 23:46 Jonas Maebe Resolution open => fixed
2020-11-08 23:46 Jonas Maebe Fixed in Version => 3.3.1
2020-11-08 23:46 Jonas Maebe Fixed in Revision => 47355
2020-11-08 23:46 Jonas Maebe FPCTarget => -
2020-11-08 23:46 Jonas Maebe Note Added: 0126806