浏览代码

Merged revisions 503,513,541,1077 via svnmerge from
/trunk

git-svn-id: branches/fixes_2_0@1129 -

peter 20 年之前
父节点
当前提交
00a5bcb0bc
共有 10 个文件被更改,包括 60 次插入23 次删除
  1. 4 0
      compiler/globals.pas
  2. 2 0
      compiler/msg/errore.msg
  3. 1 1
      compiler/msgidx.inc
  4. 8 5
      compiler/msgtxt.inc
  5. 9 1
      compiler/ncgutil.pas
  6. 8 1
      compiler/options.pas
  7. 2 0
      compiler/parser.pas
  8. 13 15
      compiler/pmodules.pas
  9. 7 0
      rtl/bsd/system.pp
  10. 6 0
      rtl/macos/system.pp

+ 4 - 0
compiler/globals.pas

@@ -288,6 +288,10 @@ interface
        syscall_convention : string = 'LEGACY';
        syscall_convention : string = 'LEGACY';
 {$endif powerpc}
 {$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;
     procedure abstract;
 
 
     function bstoslash(const s : string) : string;
     function bstoslash(const s : string) : string;

+ 2 - 0
compiler/msg/errore.msg

@@ -2374,6 +2374,8 @@ P*2WT_Specify tool type application (MPW tool, MacOS only)
 **2Xc_pass --shared to the linker (Unix only)
 **2Xc_pass --shared to the linker (Unix only)
 **2Xd_don't use standard library search path (needed for cross compile)
 **2Xd_don't use standard library search path (needed for cross compile)
 **2XD_try to link units dynamic          (defines FPC_LINK_DYNAMIC)
 **2XD_try to link units dynamic          (defines FPC_LINK_DYNAMIC)
+**2Xm_generate link map
+**2XM<x>_set the name of the 'main' program routine (default is 'main')
 **2XP<x>_prepend the binutils names with the prefix <x>
 **2XP<x>_prepend the binutils names with the prefix <x>
 **2Xr<x>_set library search path to <x> (needed for cross compile)
 **2Xr<x>_set library search path to <x> (needed for cross compile)
 **2Xs_strip all symbols from executable
 **2Xs_strip all symbols from executable

+ 1 - 1
compiler/msgidx.inc

@@ -660,7 +660,7 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 38842;
+  MsgTxtSize = 38938;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
     19,73,215,59,59,47,100,20,135,60,
     19,73,215,59,59,47,100,20,135,60,

+ 8 - 5
compiler/msgtxt.inc

@@ -1,7 +1,7 @@
 {$ifdef Delphi}
 {$ifdef Delphi}
-const msgtxt : array[0..000161] of string[240]=(
+const msgtxt : array[0..000162] of string[240]=(
 {$else Delphi}
 {$else Delphi}
-const msgtxt : array[0..000161,1..240] of char=(
+const msgtxt : array[0..000162,1..240] of char=(
 {$endif Delphi}
 {$endif Delphi}
   '01000_T_Compiler: $1'#000+
   '01000_T_Compiler: $1'#000+
   '01001_D_Compiler OS: $1'#000+
   '01001_D_Compiler OS: $1'#000+
@@ -935,13 +935,16 @@ const msgtxt : array[0..000161,1..240] of char=(
   '**2Xd_don'#039't use standard library search path (needed for cross com'+
   '**2Xd_don'#039't use standard library search path (needed for cross com'+
   'pile)'#010+
   'pile)'#010+
   '**2XD_try to link units dynamic          (defines',' FPC_LINK_DYNAMIC)'#010+
   '**2XD_try to link units dynamic          (defines',' FPC_LINK_DYNAMIC)'#010+
+  '**2Xm_generate link map'#010+
+  '**2XM<x>_set the name of the '#039'main'#039' program routine (default i'+
+  's '#039'main'#039')'#010+
   '**2XP<x>_prepend the binutils names with the prefix <x>'#010+
   '**2XP<x>_prepend the binutils names with the prefix <x>'#010+
   '**2Xr<x>_set library search path to <x> (needed for cross compile)'#010+
   '**2Xr<x>_set library search path to <x> (needed for cross compile)'#010+
-  '**2Xs_strip all symbols from executable'#010+
-  '**2XS_try to link units static (default) (defines FPC_LINK','_STATIC)'#010+
+  '**','2Xs_strip all symbols from executable'#010+
+  '**2XS_try to link units static (default) (defines FPC_LINK_STATIC)'#010+
   '**2Xt_link with static libraries (-static is passed to linker)'#010+
   '**2Xt_link with static libraries (-static is passed to linker)'#010+
   '**2XX_try to link units smart            (defines FPC_LINK_SMART)'#010+
   '**2XX_try to link units smart            (defines FPC_LINK_SMART)'#010+
-  '**1*_'#010+
+  '**1*_'#010,
   '**1?_shows this help'#010+
   '**1?_shows this help'#010+
   '**1h_shows this help without waiting'#000
   '**1h_shows this help without waiting'#000
 );
 );

+ 9 - 1
compiler/ncgutil.pas

@@ -1554,7 +1554,8 @@ implementation
       var
       var
         href : treference;
         href : treference;
         paraloc1,
         paraloc1,
-        paraloc2 : tcgpara;
+        paraloc2,
+        paraloc3 : tcgpara;
         hp   : tused_unit;
         hp   : tused_unit;
       begin
       begin
         paraloc1.init;
         paraloc1.init;
@@ -1580,6 +1581,13 @@ implementation
         { call startup helpers from main program }
         { call startup helpers from main program }
         if (current_procinfo.procdef.proctypeoption=potype_proginit) then
         if (current_procinfo.procdef.proctypeoption=potype_proginit) then
          begin
          begin
+           if (target_info.system = system_powerpc_darwin) or
+              (target_info.system = system_powerpc_macos) then
+             begin
+              { the parameters are already in the right registers }
+              cg.a_call_name(list,target_info.cprefix+'FPC_SYSTEMMAIN');
+             end;
+           
            { initialize units }
            { initialize units }
            cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
            cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
            cg.a_call_name(list,'FPC_INITIALIZEUNITS');
            cg.a_call_name(list,'FPC_INITIALIZEUNITS');

+ 8 - 1
compiler/options.pas

@@ -606,7 +606,7 @@ begin
                begin
                begin
                  l:=Pos(':=',more);
                  l:=Pos(':=',more);
                  if l>0 then
                  if l>0 then
-                   set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255))                  
+                   set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255))
                  else
                  else
                    def_system_macro(more);
                    def_system_macro(more);
                end;
                end;
@@ -1213,6 +1213,11 @@ begin
                         exclude(initglobalswitches,cs_link_shared);
                         exclude(initglobalswitches,cs_link_shared);
                         LinkTypeSetExplicitly:=true;
                         LinkTypeSetExplicitly:=true;
                       end;
                       end;
+                    'M' :
+                      begin
+                        mainaliasname:=Copy(more,2,length(More)-1);
+                        More:='';
+                      end;
                     '-' :
                     '-' :
                       begin
                       begin
                         exclude(initglobalswitches,cs_link_staticflag);
                         exclude(initglobalswitches,cs_link_staticflag);
@@ -1775,6 +1780,8 @@ begin
 
 
 { Temporary defines, until things settle down }
 { Temporary defines, until things settle down }
   def_system_macro('COMPPROCINLINEFIXED');
   def_system_macro('COMPPROCINLINEFIXED');
+  { "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
   if pocall_default = pocall_register then
     def_system_macro('REGCALL');
     def_system_macro('REGCALL');

+ 2 - 0
compiler/parser.pas

@@ -35,7 +35,9 @@ interface
 implementation
 implementation
 
 
     uses
     uses
+{$IFNDEF MACOS_USE_FAKE_SYSUTILS}
       sysutils,
       sysutils,
+{$ENDIF MACOS_USE_FAKE_SYSUTILS}
       cutils,cclasses,
       cutils,cclasses,
       globtype,version,tokens,systems,globals,verbose,
       globtype,version,tokens,systems,globals,verbose,
       symbase,symtable,symsym,
       symbase,symtable,symsym,

+ 13 - 15
compiler/pmodules.pas

@@ -1498,26 +1498,24 @@ implementation
 
 
          { The program intialization needs an alias, so it can be called
          { The program intialization needs an alias, so it can be called
            from the bootstrap code.}
            from the bootstrap code.}
-         if islibrary or
-            (target_info.system in [system_powerpc_macos,system_powerpc_darwin]) then
+         
+         if islibrary then
           begin
           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 }
             { Win32 startup code needs a single name }
 //            if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
 //            if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
             pd.aliasnames.insert('PASCALMAIN');
             pd.aliasnames.insert('PASCALMAIN');
           end
           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).parse_body;
          tcgprocinfo(current_procinfo).generate_code;
          tcgprocinfo(current_procinfo).generate_code;
          tcgprocinfo(current_procinfo).resetprocdef;
          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 }
 { can also be used with other BSD's if they use the system's crtX instead of prtX }
 
 
 {$ifdef Darwin}
 {$ifdef Darwin}
+
+{$ifndef FPC_DARWIN_PASCALMAIN}
 procedure pascalmain; external name 'PASCALMAIN';
 procedure pascalmain; external name 'PASCALMAIN';
 
 
 { Main entry point in C style, needed to capture program parameters. }
 { Main entry point in C style, needed to capture program parameters. }
 procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
 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
 begin
   argc:= argcparam;
   argc:= argcparam;
   argv:= argvparam;
   argv:= argvparam;
   envp:= envpparam;
   envp:= envpparam;
+{$ifndef FPC_DARWIN_PASCALMAIN}
   pascalmain;  {run the pascal main program}
   pascalmain;  {run the pascal main program}
+{$endif FPC_DARWIN_PASCALMAIN}
 end;
 end;
 {$endif Darwin}
 {$endif Darwin}
 {$endif FPC_USE_LIBC}
 {$endif FPC_USE_LIBC}

+ 6 - 0
rtl/macos/system.pp

@@ -213,18 +213,24 @@ end;
                          SystemUnit Initialization
                          SystemUnit Initialization
 *****************************************************************************}
 *****************************************************************************}
 
 
+{$ifndef FPC_DARWIN_PASCALMAIN}
 procedure pascalmain; external name 'PASCALMAIN';
 procedure pascalmain; external name 'PASCALMAIN';
 
 
 {Main entry point in C style, needed to capture program parameters.
 {Main entry point in C style, needed to capture program parameters.
  For this to work, the system unit must be before the main program
  For this to work, the system unit must be before the main program
  in the linking order.}
  in the linking order.}
 procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
 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
 begin
   argc:= argcparam;
   argc:= argcparam;
   argv:= argvparam;
   argv:= argvparam;
   envp:= envpparam;
   envp:= envpparam;
+{$ifndef FPC_DARWIN_PASCALMAIN}
   pascalmain;  {run the pascal main program}
   pascalmain;  {run the pascal main program}
+{$endif FPC_DARWIN_PASCALMAIN}
 end;
 end;
 
 
 procedure setup_arguments;
 procedure setup_arguments;