Răsfoiți Sursa

* the 'main' procedure for darwin is now placed in the main program instead
of in the system unit
+ ability to rename this 'main' symbol (-XM<x>, e.g. -XMSDL_main for SDL), for
all OS'es
+ mention the -Xm parameter in the help

git-svn-id: trunk@503 -

Jonas Maebe 20 ani în urmă
părinte
comite
9d9fd923d9
4 a modificat fișierele cu 31 adăugiri și 15 ștergeri
  1. 4 0
      compiler/globals.pas
  2. 7 0
      compiler/options.pas
  3. 13 15
      compiler/pmodules.pas
  4. 7 0
      rtl/bsd/system.pp

+ 4 - 0
compiler/globals.pas

@@ -288,6 +288,10 @@ interface
        syscall_convention : string = 'LEGACY';
 {$endif powerpc}
 
+       { default name of the C-style "main" procedure of the library/program }
+       { (this will be prefixed with the target_info.cprefix)                }
+       mainaliasname : string = 'main';
+
     procedure abstract;
 
     function bstoslash(const s : string) : string;

+ 7 - 0
compiler/options.pas

@@ -1223,6 +1223,11 @@ begin
                         exclude(initglobalswitches,cs_link_shared);
                         LinkTypeSetExplicitly:=true;
                       end;
+                    'M' :
+                      begin
+                        mainaliasname:=Copy(more,2,length(More)-1);
+                        More:='';
+                      end;
                     '-' :
                       begin
                         exclude(initglobalswitches,cs_link_staticflag);
@@ -1784,6 +1789,8 @@ begin
   def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
 
 { Temporary defines, until things settle down }
+  { "main" symbol is generated in the main program, and left out of the system unit }
+  def_system_macro('FPC_DARWIN_PASCALMAIN');
   if pocall_default = pocall_register then
     def_system_macro('REGCALL');
 

+ 13 - 15
compiler/pmodules.pas

@@ -1447,26 +1447,24 @@ implementation
 
          { The program intialization needs an alias, so it can be called
            from the bootstrap code.}
-         if islibrary or
-            (target_info.system in [system_powerpc_macos,system_powerpc_darwin]) then
+         
+         if islibrary then
           begin
-            pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'main'),potype_proginit,st);
+            pd:=create_main_proc(make_mangledname('',current_module.localsymtable,mainaliasname),potype_proginit,st);
             { Win32 startup code needs a single name }
 //            if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
             pd.aliasnames.insert('PASCALMAIN');
           end
-         else
-          begin
-            if (target_info.system = system_i386_netware) or
-               (target_info.system = system_i386_netwlibc) then
-            begin
-              pd:=create_main_proc('PASCALMAIN',potype_proginit,st); { main is need by the netware rtl }
-            end else
-            begin
-              pd:=create_main_proc('main',potype_proginit,st);
-              pd.aliasnames.insert('PASCALMAIN');
-            end;
-          end;
+         else if (target_info.system = system_i386_netware) or
+                 (target_info.system = system_i386_netwlibc) then
+           begin
+             pd:=create_main_proc('PASCALMAIN',potype_proginit,st); { main is need by the netware rtl }
+           end
+         else 
+           begin
+             pd:=create_main_proc(mainaliasname,potype_proginit,st);
+             pd.aliasnames.insert('PASCALMAIN');
+           end;
          tcgprocinfo(current_procinfo).parse_body;
          tcgprocinfo(current_procinfo).generate_code;
          tcgprocinfo(current_procinfo).resetprocdef;

+ 7 - 0
rtl/bsd/system.pp

@@ -216,16 +216,23 @@ end;
 { can also be used with other BSD's if they use the system's crtX instead of prtX }
 
 {$ifdef Darwin}
+
+{$ifndef FPC_DARWIN_PASCALMAIN}
 procedure pascalmain; external name 'PASCALMAIN';
 
 { Main entry point in C style, needed to capture program parameters. }
 procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
+{$else FPC_DARWIN_PASCALMAIN}
+procedure FPC_SYSTEMMAIN(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
+{$endif FPC_DARWIN_PASCALMAIN}
 
 begin
   argc:= argcparam;
   argv:= argvparam;
   envp:= envpparam;
+{$ifndef FPC_DARWIN_PASCALMAIN}
   pascalmain;  {run the pascal main program}
+{$endif FPC_DARWIN_PASCALMAIN}
 end;
 {$endif Darwin}
 {$endif FPC_USE_LIBC}