Ver Fonte

* fixed handling of paths/files with spaces in their name in link.res
on platforms where the `cat link.res` trick is used. Those must
/not/ be quoted, because otherwise the shell assumes those quotes
are part of the filename, and will escape the quotes themselves.

Instead, write everything out without quotes, but set IFS to
<newline> before doing the cat, so that only a new line is seen
as a separator between items. The shell will then insert the
necessary quotes to escape the spaces. One disadvantage: this
means that other options, such as e.g. "-arch ppc" under Darwin,
must now be written split over two lines to avoid the shell
passing such parameters (which consist of two separate strings)
as one single parameter (with an escaped space) to ld.

git-svn-id: trunk@8166 -

Jonas Maebe há 18 anos atrás
pai
commit
9c69c9dcf8
3 ficheiros alterados com 37 adições e 17 exclusões
  1. 4 0
      compiler/script.pas
  2. 8 5
      compiler/systems/t_beos.pas
  3. 25 12
      compiler/systems/t_bsd.pas

+ 4 - 0
compiler/script.pas

@@ -378,7 +378,11 @@ Procedure TAsmScriptUnix.AddLinkCommand (Const Command, Options, FileName : TCmd
 begin
   if FileName<>'' then
    Add('echo Linking '+ScriptFixFileName(FileName));
+  Add('OFS=$IFS');
+  Add('IFS="');
+  Add('"');
   Add(maybequoted(command)+' '+Options);
+  Add('IFS=$OFS');
   Add('if [ $? != 0 ]; then DoExitLink '+ScriptFixFileName(FileName)+'; fi');
 end;
 

+ 8 - 5
compiler/systems/t_beos.pas

@@ -247,19 +247,22 @@ begin
   else
    LinkRes.Add('ld -o $1 -e 0 $2 $3 $4 $5 $6 $7 $8 $9\');
   }
-  LinkRes.Add('-m elf_i386_be -shared -Bsymbolic');
+  LinkRes.Add('-m');
+  LinkRes.Add('elf_i386_be');
+  LinkRes.Add('-shared');
+  LinkRes.Add('-Bsymbolic');
 
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   while assigned(HPath) do
    begin
-     LinkRes.Add(maybequoted('-L'+HPath.Str));
+     LinkRes.Add('-L'+HPath.Str);
      HPath:=TCmdStrListItem(HPath.Next);
    end;
   HPath:=TCmdStrListItem(LibrarySearchPath.First);
   while assigned(HPath) do
    begin
-     LinkRes.Add(maybequoted('-L'+HPath.Str));
+     LinkRes.Add('-L'+HPath.Str);
      HPath:=TCmdStrListItem(HPath.Next);
    end;
 
@@ -293,7 +296,7 @@ begin
    begin
      s:=ObjectFiles.GetFirst;
      if s<>'' then
-      LinkRes.AddFileName(maybequoted(s));
+      LinkRes.AddFileName(s);
    end;
 
 {  LinkRes.Add('-lroot \');
@@ -306,7 +309,7 @@ begin
      While not StaticLibFiles.Empty do
       begin
         S:=StaticLibFiles.GetFirst;
-        LinkRes.AddFileName(maybequoted(s))
+        LinkRes.AddFileName(s)
       end;
    end;
 

+ 25 - 12
compiler/systems/t_bsd.pas

@@ -366,15 +366,16 @@ begin
 
   if (not isdll) then
     begin
+      LinkRes.Add('-arch');
       case target_info.system of
         system_powerpc_darwin:
-           LinkRes.Add('-arch ppc');
+           LinkRes.Add('ppc');
         system_i386_darwin:
-           LinkRes.Add('-arch i386');
+           LinkRes.Add('i386');
         system_powerpc64_darwin:
-           LinkRes.Add('-arch ppc64');
+           LinkRes.Add('ppc64');
         system_x86_64_darwin:
-           LinkRes.Add('-arch x86_64');
+           LinkRes.Add('x86_64');
       end;
   end;
   { Write path to search libraries }
@@ -382,7 +383,7 @@ begin
   while assigned(HPath) do
    begin
      if LdSupportsNoResponseFile then
-       LinkRes.Add(maybequoted('-L'+HPath.Str))
+       LinkRes.Add('-L'+HPath.Str)
      else
        LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
      HPath:=TCmdStrListItem(HPath.Next);
@@ -391,7 +392,7 @@ begin
   while assigned(HPath) do
    begin
      if LdSupportsNoResponseFile then
-       LinkRes.Add(maybequoted('-L'+HPath.Str))
+       LinkRes.Add('-L'+HPath.Str)
      else
        LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
      HPath:=TCmdStrListItem(HPath.Next);
@@ -402,13 +403,13 @@ begin
       HPath:=TCmdStrListItem(current_module.localframeworksearchpath.First);
       while assigned(HPath) do
        begin
-         LinkRes.Add(maybequoted('-F'+HPath.Str));
+         LinkRes.Add('-F'+HPath.Str);
          HPath:=TCmdStrListItem(HPath.Next);
        end;
       HPath:=TCmdStrListItem(FrameworkSearchPath.First);
       while assigned(HPath) do
        begin
-         LinkRes.Add(maybequoted('-F'+HPath.Str));
+         LinkRes.Add('-F'+HPath.Str);
          HPath:=TCmdStrListItem(HPath.Next);
        end;
     end;
@@ -432,7 +433,10 @@ begin
    begin
      s:=ObjectFiles.GetFirst;
      if s<>'' then
-      LinkRes.AddFileName(maybequoted(s));
+      if LdSupportsNoResponseFile then
+        LinkRes.AddFileName(s)
+      else
+        LinkRes.AddFileName(maybequoted(s));
    end;
   if not LdSupportsNoResponseFile then
    LinkRes.Add(')');
@@ -445,7 +449,10 @@ begin
      While not StaticLibFiles.Empty do
       begin
         S:=StaticLibFiles.GetFirst;
-        LinkRes.AddFileName(maybequoted(s))
+        if LdSupportsNoResponseFile then
+          LinkRes.AddFileName(s)
+        else
+          LinkRes.AddFileName(maybequoted(s))
       end;
      if not LdSupportsNoResponseFile then
        LinkRes.Add(')');
@@ -495,7 +502,10 @@ begin
   { frameworks for Darwin }
   if IsDarwin then
     while not FrameworkFiles.empty do
-      LinkRes.Add('-framework '+FrameworkFiles.GetFirst);
+      begin
+        LinkRes.Add('-framework');
+        LinkRes.Add(FrameworkFiles.GetFirst);
+      end;
      
   { objects which must be at the end }
   if linklibc and
@@ -516,7 +526,10 @@ begin
   { ignore the fact that our relocations are in non-writable sections, }
   { will be fixed once we have pic support                             }
   if isdll and IsDarwin Then
-    LinkRes.Add('-read_only_relocs suppress');
+    begin
+      LinkRes.Add('-read_only_relocs');
+      LinkRes.Add('suppress');
+    end;
 { Write and Close response }
   linkres.writetodisk;
   linkres.Free;