mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 03:49:04 +02:00
Omit FPC_INIT_FUNC_TABLE generation if no unit initialization is registered for current project.
This commit is contained in:
parent
677fd4fb00
commit
fc76d9fac2
@ -715,6 +715,7 @@ implementation
|
||||
nbas,ncon,nld,nmem,
|
||||
ncgrtti,pass_2,
|
||||
cgobj,cutils,procinfo,
|
||||
ngenutil,
|
||||
{$ifdef x86}
|
||||
cgx86,
|
||||
{$endif x86}
|
||||
@ -4949,7 +4950,11 @@ implementation
|
||||
if not(current_module.islibrary) then
|
||||
begin
|
||||
if tf_init_final_units_by_calls in target_info.flags then
|
||||
cg.a_call_name(list,'FPC_INIT_FUNC_TABLE',false)
|
||||
begin
|
||||
{ Only insert call if there are init functions }
|
||||
if cnodeutils.has_init_list then
|
||||
cg.a_call_name(list,'FPC_INIT_FUNC_TABLE',false);
|
||||
end
|
||||
else
|
||||
g_call_system_proc(list,'fpc_initializeunits',[],nil).resetiftemp;
|
||||
end
|
||||
|
@ -134,6 +134,9 @@ interface
|
||||
|
||||
class procedure InsertMemorySizes; virtual;
|
||||
|
||||
{ Call this to check if init code is required }
|
||||
class function has_init_list: boolean;
|
||||
|
||||
{ called right before an object is assembled, can be used to insert
|
||||
global information into the assembler list (used by LLVM to insert type
|
||||
info) }
|
||||
@ -1228,6 +1231,24 @@ implementation
|
||||
unitinits.free;
|
||||
end;
|
||||
|
||||
class function tnodeutils.has_init_list: boolean;
|
||||
var
|
||||
hp : tused_unit;
|
||||
begin
|
||||
Result:=false;
|
||||
{ Check used units }
|
||||
hp:=tused_unit(usedunits.first);
|
||||
while assigned(hp) and (Result=false) do
|
||||
begin
|
||||
if mf_init in hp.u.moduleflags then
|
||||
Result:=true;
|
||||
hp:=tused_unit(hp.next);
|
||||
end;
|
||||
|
||||
{ Check current module }
|
||||
Result:=Result or (mf_init in current_module.moduleflags);
|
||||
end;
|
||||
|
||||
|
||||
class procedure tnodeutils.InsertThreadvarTablesTable;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user