Explorar el Código

* fixed handling of directories with spaces for LdSupportsNoResponseFile-
targets (a.o. darwin) in case no ppas.sh is generated (need to generate
a temporary script in that case as well to use the IFS trick)
* fixed exit code checking of ld when using IFS trick (have to check it
before restoring IFS, otherwise we check the "error result" of this
restoration, which will always be 0)

git-svn-id: trunk@9325 -

Jonas Maebe hace 17 años
padre
commit
0ac6e82c1f
Se han modificado 2 ficheros con 45 adiciones y 6 borrados
  1. 1 1
      compiler/script.pas
  2. 44 5
      compiler/systems/t_bsd.pas

+ 1 - 1
compiler/script.pas

@@ -382,8 +382,8 @@ begin
   Add('IFS="');
   Add('IFS="');
   Add('"');
   Add('"');
   Add(maybequoted(command)+' '+Options);
   Add(maybequoted(command)+' '+Options);
-  Add('IFS=$OFS');
   Add('if [ $? != 0 ]; then DoExitLink '+ScriptFixFileName(FileName)+'; fi');
   Add('if [ $? != 0 ]; then DoExitLink '+ScriptFixFileName(FileName)+'; fi');
+  Add('IFS=$OFS');
 end;
 end;
 
 
 
 

+ 44 - 5
compiler/systems/t_bsd.pas

@@ -557,11 +557,12 @@ function TLinkerBSD.MakeExecutable:boolean;
 var
 var
   binstr,
   binstr,
   cmdstr  : TCmdStr;
   cmdstr  : TCmdStr;
-  success : boolean;
+  linkscript: TAsmScript;
   DynLinkStr : string[60];
   DynLinkStr : string[60];
   GCSectionsStr,
   GCSectionsStr,
   StaticStr,
   StaticStr,
   StripStr   : string[40];
   StripStr   : string[40];
+  success : boolean;
 begin
 begin
   if not(cs_link_nolink in current_settings.globalswitches) then
   if not(cs_link_nolink in current_settings.globalswitches) then
    Message1(exec_i_linking,current_module.exefilename^);
    Message1(exec_i_linking,current_module.exefilename^);
@@ -618,11 +619,30 @@ begin
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
-  success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,LdSupportsNoResponseFile);
+  BinStr:=FindUtil(utilsprefix+BinStr);
+
+  if (LdSupportsNoResponseFile) and
+     not(cs_link_nolink in current_settings.globalswitches) then
+    begin
+      { we have to use a script to use the IFS hack }
+      linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
+      linkscript.AddLinkCommand(BinStr,CmdStr,'');
+      linkscript.WriteToDisk;
+      BinStr:=linkscript.fn;
+      if not path_absolute(BinStr) then
+        BinStr:='./'+BinStr;
+      CmdStr:='';
+    end;
+
+  success:=DoExec(BinStr,CmdStr,true,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
-   DeleteFile(outputexedir+Info.ResName);
+   begin
+     DeleteFile(outputexedir+Info.ResName);
+     DeleteFile(linkscript.fn);
+     linkscript.free
+   end;
 
 
   MakeExecutable:=success;   { otherwise a recursive call to link method }
   MakeExecutable:=success;   { otherwise a recursive call to link method }
 end;
 end;
@@ -633,6 +653,7 @@ var
   InitStr,
   InitStr,
   FiniStr,
   FiniStr,
   SoNameStr : string[80];
   SoNameStr : string[80];
+  linkscript: TAsmScript;
   binstr,
   binstr,
   cmdstr  : TCmdStr;
   cmdstr  : TCmdStr;
   success : boolean;
   success : boolean;
@@ -660,8 +681,22 @@ begin
   Replace(cmdstr,'$INIT',InitStr);
   Replace(cmdstr,'$INIT',InitStr);
   Replace(cmdstr,'$FINI',FiniStr);
   Replace(cmdstr,'$FINI',FiniStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
+  BinStr:=FindUtil(utilsprefix+BinStr);
+
+  if (LdSupportsNoResponseFile) and
+     not(cs_link_nolink in current_settings.globalswitches) then
+    begin
+      { we have to use a script to use the IFS hack }
+      linkscript:=TAsmScriptUnix.create(outputexedir+'ppaslink');
+      linkscript.AddLinkCommand(BinStr,CmdStr,'');
+      linkscript.WriteToDisk;
+      BinStr:=linkscript.fn;
+      if not path_absolute(BinStr) then
+        BinStr:='./'+BinStr;
+      CmdStr:='';
+    end;
 
 
-  success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,LdSupportsNoResponseFile);
+  success:=DoExec(BinStr,cmdstr,true,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
@@ -673,7 +708,11 @@ begin
 
 
 { 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
-   DeleteFile(outputexedir+Info.ResName);
+    begin
+      DeleteFile(outputexedir+Info.ResName);
+//      DeleteFile(linkscript.fn);
+      linkscript.free
+    end;     
 
 
   MakeSharedLibrary:=success;   { otherwise a recursive call to link method }
   MakeSharedLibrary:=success;   { otherwise a recursive call to link method }
 end;
 end;