* 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 -
This commit is contained in:
Jonas Maebe 2012-05-03 12:41:16 +00:00
parent 923e939170
commit 0841ee6e4f
23 changed files with 46 additions and 29 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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 }

View File

@ -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);

View File

@ -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 \')

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)');

View File

@ -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 \')

View File

@ -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 }

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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)));

View File

@ -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);

View File

@ -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 }