mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 22:49:17 +02:00
* use separate input and output files when invoking wlib to create a static
library. This resolves a problem with parallel building of a i8086 cross compiler, due to a race condition in wlib, when running several instances of wlib in the same directory. The problem is in the way wlib creates a temp file in the current directory using non-atomic operations and with a high probability of a name collision. Using separate input and output files avoids this temp file creation by wlib. git-svn-id: trunk@30277 -
This commit is contained in:
parent
fa5bd1c513
commit
069fa51445
@ -771,12 +771,14 @@ Implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
binstr, scriptfile : TCmdStr;
|
binstr, firstbinstr, scriptfile : TCmdStr;
|
||||||
cmdstr, nextcmd, smartpath : TCmdStr;
|
cmdstr, firstcmd, nextcmd, smartpath : TCmdStr;
|
||||||
current : TCmdStrListItem;
|
current : TCmdStrListItem;
|
||||||
script: Text;
|
script: Text;
|
||||||
scripted_ar : boolean;
|
scripted_ar : boolean;
|
||||||
|
ar_creates_different_output_file : boolean;
|
||||||
success : boolean;
|
success : boolean;
|
||||||
|
first : boolean;
|
||||||
begin
|
begin
|
||||||
MakeStaticLibrary:=false;
|
MakeStaticLibrary:=false;
|
||||||
{ remove the library, to be sure that it is rewritten }
|
{ remove the library, to be sure that it is rewritten }
|
||||||
@ -785,6 +787,16 @@ Implementation
|
|||||||
smartpath:=FixPath(ChangeFileExt(current_module.asmfilename,target_info.smartext),false);
|
smartpath:=FixPath(ChangeFileExt(current_module.asmfilename,target_info.smartext),false);
|
||||||
SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
|
SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
|
||||||
binstr := FindUtil(utilsprefix + binstr);
|
binstr := FindUtil(utilsprefix + binstr);
|
||||||
|
if target_ar.arfirstcmd<>'' then
|
||||||
|
begin
|
||||||
|
SplitBinCmd(target_ar.arfirstcmd,firstbinstr,firstcmd);
|
||||||
|
firstbinstr := FindUtil(utilsprefix + firstbinstr);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
firstbinstr:=binstr;
|
||||||
|
firstcmd:=cmdstr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
scripted_ar:=(target_ar.id=ar_gnu_ar_scripted) or
|
scripted_ar:=(target_ar.id=ar_gnu_ar_scripted) or
|
||||||
@ -823,14 +835,33 @@ Implementation
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
ar_creates_different_output_file:=(Pos('$OUTPUTLIB',cmdstr)>0) or (Pos('$OUTPUTLIB',firstcmd)>0);
|
||||||
Replace(cmdstr,'$LIB',maybequoted(current_module.staticlibfilename));
|
Replace(cmdstr,'$LIB',maybequoted(current_module.staticlibfilename));
|
||||||
|
Replace(firstcmd,'$LIB',maybequoted(current_module.staticlibfilename));
|
||||||
|
Replace(cmdstr,'$OUTPUTLIB',maybequoted(current_module.staticlibfilename+'.tmp'));
|
||||||
|
Replace(firstcmd,'$OUTPUTLIB',maybequoted(current_module.staticlibfilename+'.tmp'));
|
||||||
{ create AR commands }
|
{ create AR commands }
|
||||||
success := true;
|
success := true;
|
||||||
current := TCmdStrListItem(SmartLinkOFiles.First);
|
current := TCmdStrListItem(SmartLinkOFiles.First);
|
||||||
|
first := true;
|
||||||
repeat
|
repeat
|
||||||
nextcmd := cmdstr;
|
if first then
|
||||||
|
nextcmd := firstcmd
|
||||||
|
else
|
||||||
|
nextcmd := cmdstr;
|
||||||
Replace(nextcmd,'$FILES',GetNextFiles(2047, current));
|
Replace(nextcmd,'$FILES',GetNextFiles(2047, current));
|
||||||
success:=DoExec(binstr,nextcmd,false,true);
|
if first then
|
||||||
|
success:=DoExec(firstbinstr,nextcmd,false,true)
|
||||||
|
else
|
||||||
|
success:=DoExec(binstr,nextcmd,false,true);
|
||||||
|
if ar_creates_different_output_file then
|
||||||
|
begin
|
||||||
|
if FileExists(current_module.staticlibfilename,false) then
|
||||||
|
DeleteFile(current_module.staticlibfilename);
|
||||||
|
if FileExists(current_module.staticlibfilename+'.tmp',false) then
|
||||||
|
RenameFile(current_module.staticlibfilename+'.tmp',current_module.staticlibfilename);
|
||||||
|
end;
|
||||||
|
first := false;
|
||||||
until (not assigned(current)) or (not success);
|
until (not assigned(current)) or (not success);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1573,6 +1604,7 @@ Implementation
|
|||||||
ar_gnu_ar_info : tarinfo =
|
ar_gnu_ar_info : tarinfo =
|
||||||
(
|
(
|
||||||
id : ar_gnu_ar;
|
id : ar_gnu_ar;
|
||||||
|
arfirstcmd : '';
|
||||||
arcmd : 'ar qS $LIB $FILES';
|
arcmd : 'ar qS $LIB $FILES';
|
||||||
arfinishcmd : 'ar s $LIB'
|
arfinishcmd : 'ar s $LIB'
|
||||||
);
|
);
|
||||||
@ -1580,25 +1612,29 @@ Implementation
|
|||||||
ar_gnu_ar_scripted_info : tarinfo =
|
ar_gnu_ar_scripted_info : tarinfo =
|
||||||
(
|
(
|
||||||
id : ar_gnu_ar_scripted;
|
id : ar_gnu_ar_scripted;
|
||||||
|
arfirstcmd : '';
|
||||||
arcmd : 'ar -M < $SCRIPT';
|
arcmd : 'ar -M < $SCRIPT';
|
||||||
arfinishcmd : ''
|
arfinishcmd : ''
|
||||||
);
|
);
|
||||||
|
|
||||||
ar_gnu_gar_info : tarinfo =
|
ar_gnu_gar_info : tarinfo =
|
||||||
( id : ar_gnu_gar;
|
( id : ar_gnu_gar;
|
||||||
|
arfirstcmd : '';
|
||||||
arcmd : 'gar qS $LIB $FILES';
|
arcmd : 'gar qS $LIB $FILES';
|
||||||
arfinishcmd : 'gar s $LIB'
|
arfinishcmd : 'gar s $LIB'
|
||||||
);
|
);
|
||||||
|
|
||||||
ar_watcom_wlib_omf_info : tarinfo =
|
ar_watcom_wlib_omf_info : tarinfo =
|
||||||
( id : ar_watcom_wlib_omf;
|
( id : ar_watcom_wlib_omf;
|
||||||
arcmd : 'wlib -q -fo -c -b $LIB $FILES';
|
arfirstcmd : 'wlib -q -fo -c -b -o $OUTPUTLIB $FILES';
|
||||||
|
arcmd : 'wlib -q -fo -c -b -o $OUTPUTLIB $LIB $FILES';
|
||||||
arfinishcmd : ''
|
arfinishcmd : ''
|
||||||
);
|
);
|
||||||
|
|
||||||
ar_watcom_wlib_omf_scripted_info : tarinfo =
|
ar_watcom_wlib_omf_scripted_info : tarinfo =
|
||||||
(
|
(
|
||||||
id : ar_watcom_wlib_omf_scripted;
|
id : ar_watcom_wlib_omf_scripted;
|
||||||
|
arfirstcmd : '';
|
||||||
arcmd : 'wlib @$SCRIPT';
|
arcmd : 'wlib @$SCRIPT';
|
||||||
arfinishcmd : ''
|
arfinishcmd : ''
|
||||||
);
|
);
|
||||||
|
@ -83,6 +83,7 @@ interface
|
|||||||
parinfo = ^tarinfo;
|
parinfo = ^tarinfo;
|
||||||
tarinfo = record
|
tarinfo = record
|
||||||
id : tar;
|
id : tar;
|
||||||
|
arfirstcmd : string[50];
|
||||||
arcmd : string[50];
|
arcmd : string[50];
|
||||||
arfinishcmd : string[10];
|
arfinishcmd : string[10];
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user