|
@@ -670,7 +670,7 @@ implementation
|
|
|
st.insert(ps);
|
|
|
pd:=tprocdef(cnodeutils.create_main_procdef(target_info.cprefix+name,potype,ps));
|
|
|
{ We don't need a local symtable, change it into the static symtable }
|
|
|
- if not (potype in [potype_mainstub,potype_pkgstub]) then
|
|
|
+ if not (potype in [potype_mainstub,potype_pkgstub,potype_libmainstub]) then
|
|
|
begin
|
|
|
pd.localst.free;
|
|
|
pd.localst:=st;
|
|
@@ -1903,13 +1903,13 @@ type
|
|
|
var
|
|
|
main_file : tinputfile;
|
|
|
hp,hp2 : tmodule;
|
|
|
+ initpd : tprocdef;
|
|
|
finalize_procinfo,
|
|
|
init_procinfo,
|
|
|
main_procinfo : tcgprocinfo;
|
|
|
force_init_final : boolean;
|
|
|
resources_used : boolean;
|
|
|
program_uses_checkpointer : boolean;
|
|
|
- initname,
|
|
|
program_name : ansistring;
|
|
|
consume_semicolon_after_uses : boolean;
|
|
|
ps : tprogramparasym;
|
|
@@ -2129,6 +2129,17 @@ type
|
|
|
from the bootstrap code.}
|
|
|
if islibrary then
|
|
|
begin
|
|
|
+ initpd:=nil;
|
|
|
+ { ToDo: other systems that use indirect entry info, but check back with Windows! }
|
|
|
+ { we need to call FPC_LIBMAIN in sysinit which in turn will call PascalMain -> create dummy stub }
|
|
|
+ if target_info.system in systems_darwin then
|
|
|
+ begin
|
|
|
+ main_procinfo:=create_main_proc(make_mangledname('sysinitcallthrough',current_module.localsymtable,'stub'),potype_libmainstub,current_module.localsymtable);
|
|
|
+ call_through_new_name(main_procinfo.procdef,target_info.cprefix+'FPC_LIBMAIN');
|
|
|
+ initpd:=main_procinfo.procdef;
|
|
|
+ main_procinfo.free;
|
|
|
+ end;
|
|
|
+
|
|
|
main_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,mainaliasname),potype_proginit,current_module.localsymtable);
|
|
|
{ Win32 startup code needs a single name }
|
|
|
if not(target_info.system in (systems_darwin+systems_aix)) then
|
|
@@ -2136,17 +2147,10 @@ type
|
|
|
else
|
|
|
main_procinfo.procdef.aliasnames.concat(target_info.Cprefix+'PASCALMAIN');
|
|
|
|
|
|
- { ToDo: systems that use indirect entry info, but check back with Windows! }
|
|
|
- if target_info.system in systems_darwin then
|
|
|
- { we need to call FPC_LIBMAIN in sysinit which in turn will call PascalMain }
|
|
|
- initname:=target_info.cprefix+'FPC_LIBMAIN'
|
|
|
- else
|
|
|
- initname:=main_procinfo.procdef.mangledname;
|
|
|
- { setinitname may generate a new section -> don't add to the
|
|
|
- current list, because we assume this remains a text section
|
|
|
- -- add to pure assembler section, so in case of special directives
|
|
|
- they are directly added to the assembler output by llvm }
|
|
|
- exportlib.setinitname(current_asmdata.AsmLists[al_pure_assembler],initname);
|
|
|
+ if not(target_info.system in systems_darwin) then
|
|
|
+ initpd:=main_procinfo.procdef;
|
|
|
+
|
|
|
+ cnodeutils.RegisterModuleInitFunction(initpd);
|
|
|
end
|
|
|
else if (target_info.system in ([system_i386_netware,system_i386_netwlibc,system_powerpc_macos]+systems_darwin+systems_aix)) then
|
|
|
begin
|
|
@@ -2225,7 +2229,7 @@ type
|
|
|
{ Place in "pure assembler" list so that the llvm assembler writer
|
|
|
directly emits the generated directives }
|
|
|
if (islibrary) then
|
|
|
- exportlib.setfininame(current_asmdata.asmlists[al_pure_assembler],'FPC_LIB_EXIT');
|
|
|
+ cnodeutils.RegisterModuleFiniFunction(search_system_proc('fpc_lib_exit'));
|
|
|
|
|
|
{ all labels must be defined before generating code }
|
|
|
if Errorcount=0 then
|