Explorar o código

* GNU ld only supports double quotes in its response file -> requote there
as well under Unix (mantis #21928, caused by r21069)

git-svn-id: trunk@21208 -

Jonas Maebe %!s(int64=13) %!d(string=hai) anos
pai
achega
0841ee6e4f

+ 3 - 2
compiler/cfileutl.pas

@@ -128,6 +128,7 @@ interface
     procedure InitFileUtils;
     procedure InitFileUtils;
     procedure DoneFileUtils;
     procedure DoneFileUtils;
 
 
+    function UnixRequoteWithDoubleQuotes(const QuotedStr: TCmdStr): TCmdStr;
     function RequotedExecuteProcess(const Path: AnsiString; const ComLine: AnsiString; Flags: TExecuteFlags = []): Longint;
     function RequotedExecuteProcess(const Path: AnsiString; const ComLine: AnsiString; Flags: TExecuteFlags = []): Longint;
     function RequotedExecuteProcess(const Path: AnsiString; const ComLine: array of AnsiString; Flags: TExecuteFlags = []): Longint;
     function RequotedExecuteProcess(const Path: AnsiString; const ComLine: array of AnsiString; Flags: TExecuteFlags = []): Longint;
     function Shell(const command:ansistring): longint;
     function Shell(const command:ansistring): longint;
@@ -1450,7 +1451,7 @@ end;
       because it only supports Windows-style quoting; this routine assumes that
       because it only supports Windows-style quoting; this routine assumes that
       everything that has to be quoted for Windows, was also quoted (but
       everything that has to be quoted for Windows, was also quoted (but
       differently for Unix) -- which is the case }
       differently for Unix) -- which is the case }
-    function UnixRequoteForExecuteProcess(const QuotedStr: TCmdStr): TCmdStr;
+    function UnixRequoteWithDoubleQuotes(const QuotedStr: TCmdStr): TCmdStr;
       var
       var
         i: longint;
         i: longint;
         temp: TCmdStr;
         temp: TCmdStr;
@@ -1511,7 +1512,7 @@ end;
         else
         else
           quote_script:=source_info.script;
           quote_script:=source_info.script;
         if quote_script=script_unix then
         if quote_script=script_unix then
-          result:=sysutils.ExecuteProcess(Path,UnixRequoteForExecuteProcess(ComLine),Flags)
+          result:=sysutils.ExecuteProcess(Path,UnixRequoteWithDoubleQuotes(ComLine),Flags)
         else
         else
           result:=sysutils.ExecuteProcess(Path,ComLine,Flags)
           result:=sysutils.ExecuteProcess(Path,ComLine,Flags)
       end;
       end;

+ 17 - 1
compiler/script.pas

@@ -90,6 +90,8 @@ type
 
 
   TLinkRes = Class (TScript)
   TLinkRes = Class (TScript)
     section: string[30];
     section: string[30];
+    fRealResponseFile: Boolean;
+    constructor Create(const ScriptName : TCmdStr; RealResponseFile: Boolean);
     procedure Add(const s:TCmdStr);
     procedure Add(const s:TCmdStr);
     procedure AddFileName(const s:TCmdStr);
     procedure AddFileName(const s:TCmdStr);
     procedure EndSection(const s:TCmdStr);
     procedure EndSection(const s:TCmdStr);
@@ -489,6 +491,12 @@ function GenerateScript(const st: TCmdStr): TAsmScript;
                                   Link Response
                                   Link Response
 ****************************************************************************}
 ****************************************************************************}
 
 
+constructor TLinkRes.Create(const ScriptName: TCmdStr; RealResponseFile: Boolean);
+begin
+  inherited Create(ScriptName);
+  fRealResponseFile:=RealResponseFile;
+end;
+
 procedure TLinkRes.Add(const s:TCmdStr);
 procedure TLinkRes.Add(const s:TCmdStr);
 begin
 begin
   if s<>'' then
   if s<>'' then
@@ -504,7 +512,15 @@ begin
    end;
    end;
   if s<>'' then
   if s<>'' then
    begin
    begin
-     if not(s[1] in ['a'..'z','A'..'Z','/','\','.','"']) then
+     { GNU ld only supports double quotes in the response file. }
+     if fRealResponseFile and
+        (s[1]='''') and
+        (((cs_link_on_target in current_settings.globalswitches) and
+          (target_info.script=script_unix)) or
+         (not(cs_link_on_target in current_settings.globalswitches) and
+          (source_info.script=script_unix))) then
+       inherited add(UnixRequoteWithDoubleQuotes(s))
+     else if not(s[1] in ['a'..'z','A'..'Z','/','\','.','"']) then
       begin
       begin
         if cs_link_on_target in current_settings.globalswitches then
         if cs_link_on_target in current_settings.globalswitches then
           inherited Add('.'+target_info.DirSep+s)
           inherited Add('.'+target_info.DirSep+s)

+ 1 - 1
compiler/systems/t_aix.pas

@@ -155,7 +155,7 @@ begin
     not(cs_link_on_target in current_settings.globalswitches) and
     not(cs_link_on_target in current_settings.globalswitches) and
     not(source_info.system in systems_aix) ;
     not(source_info.system in systems_aix) ;
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not assumebinutils);
   with linkres do
   with linkres do
     begin
     begin
       { Write path to search libraries }
       { Write path to search libraries }

+ 1 - 1
compiler/systems/t_amiga.pas

@@ -101,7 +101,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 1 - 1
compiler/systems/t_beos.pas

@@ -240,7 +240,7 @@ begin
    prtobj:=cprtobj;
    prtobj:=cprtobj;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,false);
   {
   {
   if not isdll then
   if not isdll then
    LinkRes.Add('ld -o $1 $2 $3 $4 $5 $6 $7 $8 $9 \')
    LinkRes.Add('ld -o $1 $2 $3 $4 $5 $6 $7 $8 $9 \')

+ 1 - 1
compiler/systems/t_bsd.pas

@@ -379,7 +379,7 @@ begin
      ExpandAndApplyOrder(SharedLibFiles);
      ExpandAndApplyOrder(SharedLibFiles);
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not LdSupportsNoResponseFile);
 
 
   if (target_info.system in systems_darwin) and
   if (target_info.system in systems_darwin) and
      (sysrootpath<>'') then
      (sysrootpath<>'') then

+ 1 - 1
compiler/systems/t_embed.pas

@@ -96,7 +96,7 @@ begin
     prtobj:=cprtobj;
     prtobj:=cprtobj;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 1 - 1
compiler/systems/t_emx.pas

@@ -398,7 +398,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 1 - 1
compiler/systems/t_gba.pas

@@ -90,7 +90,7 @@ begin
     prtobj:=cprtobj;
     prtobj:=cprtobj;
 
 
 	{ Open link.res file }
 	{ Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 2 - 2
compiler/systems/t_go32v2.pas

@@ -102,7 +102,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Add all options to link.res instead of passing them via command line:
   { Add all options to link.res instead of passing them via command line:
     DOS command line is limited to 126 characters! }
     DOS command line is limited to 126 characters! }
@@ -169,7 +169,7 @@ begin
   WriteScript:=False;
   WriteScript:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  ScriptRes:=TLinkRes.Create(outputexedir+Info.ScriptName);
+  ScriptRes:=TLinkRes.Create(outputexedir+Info.ScriptName,true);
   ScriptRes.Add('OUTPUT_FORMAT("coff-go32-exe")');
   ScriptRes.Add('OUTPUT_FORMAT("coff-go32-exe")');
   ScriptRes.Add('ENTRY(start)');
   ScriptRes.Add('ENTRY(start)');
 
 

+ 1 - 1
compiler/systems/t_haiku.pas

@@ -241,7 +241,7 @@ begin
    prtobj:=cprtobj;
    prtobj:=cprtobj;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,false);
   {
   {
   if not isdll then
   if not isdll then
    LinkRes.Add('ld -o $1 $2 $3 $4 $5 $6 $7 $8 $9 \')
    LinkRes.Add('ld -o $1 $2 $3 $4 $5 $6 $7 $8 $9 \')

+ 1 - 1
compiler/systems/t_linux.pas

@@ -346,7 +346,7 @@ begin
    end;
    end;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
   with linkres do
   with linkres do
     begin
     begin
       { Write path to search libraries }
       { Write path to search libraries }

+ 1 - 1
compiler/systems/t_macos.pas

@@ -98,7 +98,7 @@ Var
 begin
 begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
   { Open link.res file }
   { Open link.res file }
-  linkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  linkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   with linkRes do
   with linkRes do
     begin
     begin

+ 1 - 1
compiler/systems/t_morph.pas

@@ -87,7 +87,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 1 - 1
compiler/systems/t_nds.pas

@@ -105,7 +105,7 @@ begin
     prtobj:=cprtobj;
     prtobj:=cprtobj;
 
 
 	{ Open link.res file }
 	{ Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 2 - 2
compiler/systems/t_nwl.pas

@@ -288,8 +288,8 @@ begin
   NlmNam := ProgNam + target_info.exeext;
   NlmNam := ProgNam + target_info.exeext;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);             {for ld}
-  NLMConvLinkFile:=TLinkRes.Create(outputexedir+'n'+Info.ResName); {for nlmconv, written in CreateExeFile}
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);             {for ld}
+  NLMConvLinkFile:=TLinkRes.Create(outputexedir+'n'+Info.ResName,true); {for nlmconv, written in CreateExeFile}
 
 
   p := Pos ('"', Description);
   p := Pos ('"', Description);
   while (p > 0) do
   while (p > 0) do

+ 2 - 2
compiler/systems/t_nwm.pas

@@ -290,8 +290,8 @@ begin
   NlmNam := ProgNam + target_info.exeext;
   NlmNam := ProgNam + target_info.exeext;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);             {for ld}
-  NLMConvLinkFile:=TLinkRes.Create(outputexedir+'n'+Info.ResName); {for nlmconv, written in CreateExeFile}
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);             {for ld}
+  NLMConvLinkFile:=TLinkRes.Create(outputexedir+'n'+Info.ResName,true); {for nlmconv, written in CreateExeFile}
 
 
   p := Pos ('"', Description);
   p := Pos ('"', Description);
   while (p > 0) do
   while (p > 0) do

+ 1 - 1
compiler/systems/t_os2.pas

@@ -413,7 +413,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 1 - 1
compiler/systems/t_palmos.pas

@@ -82,7 +82,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 3 - 3
compiler/systems/t_sunos.pas

@@ -218,7 +218,7 @@ begin
   if use_gnu_ld then
   if use_gnu_ld then
     begin
     begin
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
@@ -344,7 +344,7 @@ begin
   else { not use_gnu_ld }
   else { not use_gnu_ld }
     begin
     begin
    { Open TlinkRes, will not be written to disk }
    { Open TlinkRes, will not be written to disk }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName+'2');
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName+'2',false);
 
 
  { Write path to search libraries }
  { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
@@ -366,7 +366,7 @@ begin
   { to the main program                                    }
   { to the main program                                    }
   if (isdll) then
   if (isdll) then
     begin
     begin
-      LinkRes2:=TLinkRes.Create(outputexedir+Info.ResName);
+      LinkRes2:=TLinkRes.Create(outputexedir+Info.ResName,true);
       // LinkRes2.add('VERSION'); not needed for now
       // LinkRes2.add('VERSION'); not needed for now
       LinkRes2.add('  {');
       LinkRes2.add('  {');
       if not texportlibunix(exportlib).exportedsymnames.empty then
       if not texportlibunix(exportlib).exportedsymnames.empty then

+ 1 - 1
compiler/systems/t_watcom.pas

@@ -76,7 +76,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write object files, start with prt0 }
   { Write object files, start with prt0 }
   LinkRes.Add('file '+GetShortName(FindObjectFile('prt0','',false)));
   LinkRes.Add('file '+GetShortName(FindObjectFile('prt0','',false)));

+ 1 - 1
compiler/systems/t_wii.pas

@@ -82,7 +82,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
   linklibc:=(SharedLibFiles.Find('c')<>nil);
   linklibc:=(SharedLibFiles.Find('c')<>nil);
   linklibgcc:=(SharedLibFiles.Find('gcc')<>nil);
   linklibgcc:=(SharedLibFiles.Find('gcc')<>nil);
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
   HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);

+ 1 - 1
compiler/systems/t_win.pas

@@ -1193,7 +1193,7 @@ implementation
           end;
           end;
 
 
         { Open link.res file }
         { Open link.res file }
-        LinkRes:=TLinkres.Create(outputexedir+Info.ResName);
+        LinkRes:=TLinkres.Create(outputexedir+Info.ResName,true);
         with linkres do
         with linkres do
           begin
           begin
             { Write path to search libraries }
             { Write path to search libraries }