Browse Source

* 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 13 năm trước cách đây
mục cha
commit
0841ee6e4f

+ 3 - 2
compiler/cfileutl.pas

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

+ 17 - 1
compiler/script.pas

@@ -90,6 +90,8 @@ type
 
   TLinkRes = Class (TScript)
     section: string[30];
+    fRealResponseFile: Boolean;
+    constructor Create(const ScriptName : TCmdStr; RealResponseFile: Boolean);
     procedure Add(const s:TCmdStr);
     procedure AddFileName(const s:TCmdStr);
     procedure EndSection(const s:TCmdStr);
@@ -489,6 +491,12 @@ function GenerateScript(const st: TCmdStr): TAsmScript;
                                   Link Response
 ****************************************************************************}
 
+constructor TLinkRes.Create(const ScriptName: TCmdStr; RealResponseFile: Boolean);
+begin
+  inherited Create(ScriptName);
+  fRealResponseFile:=RealResponseFile;
+end;
+
 procedure TLinkRes.Add(const s:TCmdStr);
 begin
   if s<>'' then
@@ -504,7 +512,15 @@ begin
    end;
   if s<>'' then
    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
         if cs_link_on_target in current_settings.globalswitches then
           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(source_info.system in systems_aix) ;
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not assumebinutils);
   with linkres do
     begin
       { Write path to search libraries }

+ 1 - 1
compiler/systems/t_amiga.pas

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

+ 1 - 1
compiler/systems/t_beos.pas

@@ -240,7 +240,7 @@ begin
    prtobj:=cprtobj;
 
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,false);
   {
   if not isdll then
    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);
 
   { 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
      (sysrootpath<>'') then

+ 1 - 1
compiler/systems/t_embed.pas

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

+ 1 - 1
compiler/systems/t_emx.pas

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

+ 1 - 1
compiler/systems/t_gba.pas

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

+ 2 - 2
compiler/systems/t_go32v2.pas

@@ -102,7 +102,7 @@ begin
   WriteResponseFile:=False;
 
   { 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:
     DOS command line is limited to 126 characters! }
@@ -169,7 +169,7 @@ begin
   WriteScript:=False;
 
   { 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('ENTRY(start)');
 

+ 1 - 1
compiler/systems/t_haiku.pas

@@ -241,7 +241,7 @@ begin
    prtobj:=cprtobj;
 
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,false);
   {
   if not isdll then
    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;
 
   { Open link.res file }
-  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
   with linkres do
     begin
       { Write path to search libraries }

+ 1 - 1
compiler/systems/t_macos.pas

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

+ 1 - 1
compiler/systems/t_morph.pas

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

+ 1 - 1
compiler/systems/t_nds.pas

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

+ 2 - 2
compiler/systems/t_nwl.pas

@@ -288,8 +288,8 @@ begin
   NlmNam := ProgNam + target_info.exeext;
 
   { 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);
   while (p > 0) do

+ 2 - 2
compiler/systems/t_nwm.pas

@@ -290,8 +290,8 @@ begin
   NlmNam := ProgNam + target_info.exeext;
 
   { 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);
   while (p > 0) do

+ 1 - 1
compiler/systems/t_os2.pas

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

+ 1 - 1
compiler/systems/t_palmos.pas

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

+ 3 - 3
compiler/systems/t_sunos.pas

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

+ 1 - 1
compiler/systems/t_watcom.pas

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

+ 1 - 1
compiler/systems/t_wii.pas

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

+ 1 - 1
compiler/systems/t_win.pas

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