2
0
Эх сурвалжийг харах

+ -Xg support for darwin with dwarf

git-svn-id: trunk@9798 -
Jonas Maebe 17 жил өмнө
parent
commit
5fbc947ae8

+ 41 - 4
compiler/systems/t_bsd.pas

@@ -556,7 +556,9 @@ end;
 function TLinkerBSD.MakeExecutable:boolean;
 function TLinkerBSD.MakeExecutable:boolean;
 var
 var
   binstr,
   binstr,
-  cmdstr  : TCmdStr;
+  cmdstr,
+  extdbgbinstr,
+  extdbgcmdstr: TCmdStr;
   linkscript: TAsmScript;
   linkscript: TAsmScript;
   DynLinkStr : string[60];
   DynLinkStr : string[60];
   GCSectionsStr,
   GCSectionsStr,
@@ -592,7 +594,6 @@ begin
     if not(target_info.system in systems_darwin) then
     if not(target_info.system in systems_darwin) then
       GCSectionsStr:='--gc-sections'
       GCSectionsStr:='--gc-sections'
     else
     else
-      // warning: this option only exists for 32 bit under Mac OS X, maybe the default for 64 bit?
       GCSectionsStr:='-dead_strip';
       GCSectionsStr:='-dead_strip';
 
 
    if(not(target_info.system in systems_darwin) and
    if(not(target_info.system in systems_darwin) and
@@ -621,12 +622,25 @@ begin
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   BinStr:=FindUtil(utilsprefix+BinStr);
   BinStr:=FindUtil(utilsprefix+BinStr);
 
 
+  { create dsym file? }
+  extdbgbinstr:='';
+  extdbgcmdstr:='';
+  if (target_info.system in systems_darwin) and
+     (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
+     (cs_link_separate_dbg_file in current_settings.globalswitches) then
+    begin
+      extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
+      extdbgcmdstr:=maybequoted(current_module.exefilename^);
+    end;
+
   if (LdSupportsNoResponseFile) and
   if (LdSupportsNoResponseFile) and
      not(cs_link_nolink in current_settings.globalswitches) then
      not(cs_link_nolink in current_settings.globalswitches) then
     begin
     begin
       { we have to use a script to use the IFS hack }
       { we have to use a script to use the IFS hack }
       linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
       linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
       linkscript.AddLinkCommand(BinStr,CmdStr,'');
       linkscript.AddLinkCommand(BinStr,CmdStr,'');
+      if (extdbgcmdstr<>'') then
+        linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
       linkscript.WriteToDisk;
       linkscript.WriteToDisk;
       BinStr:=linkscript.fn;
       BinStr:=linkscript.fn;
       if not path_absolute(BinStr) then
       if not path_absolute(BinStr) then
@@ -635,6 +649,10 @@ begin
     end;
     end;
 
 
   success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile);
   success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile);
+  if (success and
+      (extdbgbinstr<>'') and
+      (cs_link_nolink in current_settings.globalswitches)) then
+    success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
 
 
 { Remove ReponseFile }
 { Remove ReponseFile }
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
@@ -658,7 +676,9 @@ var
   SoNameStr : string[80];
   SoNameStr : string[80];
   linkscript: TAsmScript;
   linkscript: TAsmScript;
   binstr,
   binstr,
-  cmdstr  : TCmdStr;
+  cmdstr,
+  extdbgbinstr,
+  extdbgcmdstr  : TCmdStr;
   success : boolean;
   success : boolean;
 begin
 begin
   MakeSharedLibrary:=false;
   MakeSharedLibrary:=false;
@@ -686,12 +706,25 @@ begin
   Replace(cmdstr,'$SONAME',SoNameStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
   BinStr:=FindUtil(utilsprefix+BinStr);
   BinStr:=FindUtil(utilsprefix+BinStr);
 
 
+  { create dsym file? }
+  extdbgbinstr:='';
+  extdbgcmdstr:='';
+  if (target_info.system in systems_darwin) and
+     (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
+     (cs_link_separate_dbg_file in current_settings.globalswitches) then
+    begin
+      extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
+      extdbgcmdstr:=maybequoted(current_module.sharedlibfilename^);
+    end;
+
   if (LdSupportsNoResponseFile) and
   if (LdSupportsNoResponseFile) and
      not(cs_link_nolink in current_settings.globalswitches) then
      not(cs_link_nolink in current_settings.globalswitches) then
     begin
     begin
       { we have to use a script to use the IFS hack }
       { we have to use a script to use the IFS hack }
       linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
       linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
       linkscript.AddLinkCommand(BinStr,CmdStr,'');
       linkscript.AddLinkCommand(BinStr,CmdStr,'');
+      if (extdbgbinstr<>'') then
+        linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
       linkscript.WriteToDisk;
       linkscript.WriteToDisk;
       BinStr:=linkscript.fn;
       BinStr:=linkscript.fn;
       if not path_absolute(BinStr) then
       if not path_absolute(BinStr) then
@@ -700,13 +733,17 @@ begin
     end;
     end;
 
 
   success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
   success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
+  if (success and
+      (extdbgbinstr<>'') and
+      (cs_link_nolink in current_settings.globalswitches)) then
+    success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
 
 
 { Strip the library ? }
 { Strip the library ? }
   if success and (cs_link_strip in current_settings.globalswitches) then
   if success and (cs_link_strip in current_settings.globalswitches) then
    begin
    begin
      SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
      SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
      Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
      Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
-     success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
+     success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
    end;
    end;
 
 
 { Remove ReponseFile }
 { Remove ReponseFile }