mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 06:09:22 +02:00
Try to compute correct page size for wlib call
This commit is contained in:
parent
952f4bae17
commit
7887f46700
@ -931,18 +931,50 @@ Implementation
|
|||||||
|
|
||||||
Function TExternalLinker.MakeStaticLibrary:boolean;
|
Function TExternalLinker.MakeStaticLibrary:boolean;
|
||||||
|
|
||||||
|
var
|
||||||
|
total_size, power : longint;
|
||||||
|
|
||||||
function GetNextFiles(const maxCmdLength : Longint; var item : TCmdStrListItem; const addfilecmd : string) : TCmdStr;
|
function GetNextFiles(const maxCmdLength : Longint; var item : TCmdStrListItem; const addfilecmd : string) : TCmdStr;
|
||||||
|
var
|
||||||
|
ItemExists : boolean;
|
||||||
|
ItemSize : longint;
|
||||||
|
fs : file;
|
||||||
begin
|
begin
|
||||||
result := '';
|
result := '';
|
||||||
while (assigned(item) and ((length(result) + length(item.str) + 1) < maxCmdLength)) do begin
|
while (assigned(item) and ((length(result) + length(item.str) + 1) < maxCmdLength)) do begin
|
||||||
|
ItemExists:=FileExists(FixFilename(item.str),true);
|
||||||
|
ItemSize:=0;
|
||||||
|
if ItemExists then
|
||||||
|
begin
|
||||||
|
system.assign(fs,item.str);
|
||||||
|
system.reset(fs);
|
||||||
|
ItemSize:=FileSize(fs);
|
||||||
|
system.close(fs);
|
||||||
|
system.inc(total_size,align(ItemSize,16));
|
||||||
|
end;
|
||||||
|
if (cs_link_nolink in current_settings.globalswitches) or
|
||||||
|
(ItemExists and (ItemSize>0)) then
|
||||||
result := result + ' ' + addfilecmd + item.str;
|
result := result + ' ' + addfilecmd + item.str;
|
||||||
item := TCmdStrListItem(item.next);
|
item := TCmdStrListItem(item.next);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function get_wlib_record_size: integer;
|
function get_wlib_record_size: integer;
|
||||||
|
var
|
||||||
|
nb_pages,page_size : longint;
|
||||||
begin
|
begin
|
||||||
result:=align(align(SmartLinkOFiles.Count,128) div 128,16);
|
{ Set wlib page size to a sensible value }
|
||||||
|
if total_size>0 then
|
||||||
|
begin
|
||||||
|
page_size:=16 div 2;
|
||||||
|
repeat
|
||||||
|
page_size:=page_size*2;
|
||||||
|
nb_pages:=(total_size + (page_size-1)*SmartLinkOFiles.count) div page_size;
|
||||||
|
until nb_pages <= high(word);
|
||||||
|
result:=nb_pages;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result:=max(16,nextpowerof2(SmartLinkOFiles.count div 16, power));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -956,6 +988,7 @@ Implementation
|
|||||||
first : boolean;
|
first : boolean;
|
||||||
begin
|
begin
|
||||||
MakeStaticLibrary:=false;
|
MakeStaticLibrary:=false;
|
||||||
|
total_size:=0;
|
||||||
{ remove the library, to be sure that it is rewritten }
|
{ remove the library, to be sure that it is rewritten }
|
||||||
DeleteFile(current_module.staticlibfilename);
|
DeleteFile(current_module.staticlibfilename);
|
||||||
{ Call AR }
|
{ Call AR }
|
||||||
|
Loading…
Reference in New Issue
Block a user