|
@@ -6787,27 +6787,37 @@ begin
|
|
|
if APackage.NeedLibC or
|
|
|
(Defaults.OS=linux) then
|
|
|
begin
|
|
|
- if FCachedlibcPath='' then
|
|
|
- begin
|
|
|
- s:=GetDefaultLibGCCDir(Defaults.CPU, Defaults.OS,ErrS);
|
|
|
- if s='' then
|
|
|
- Log(vlWarning, SWarngcclibpath +' '+ErrS)
|
|
|
- else
|
|
|
+ if FCachedlibcPath='' then
|
|
|
begin
|
|
|
+ s:=GetDefaultLibGCCDir(Defaults.CPU, Defaults.OS,ErrS);
|
|
|
+ if s='' then
|
|
|
+ Log(vlWarning, SWarngcclibpath +' '+ErrS)
|
|
|
+ else
|
|
|
+ begin
|
|
|
{$ifndef NO_THREADING}
|
|
|
- EnterCriticalsection(FGeneralCriticalSection);
|
|
|
- try
|
|
|
+ EnterCriticalsection(FGeneralCriticalSection);
|
|
|
+ { prevent FCachedlibcPath getting freed by thread 2 while thread 1 is
|
|
|
+ concatenating it to -Fl below }
|
|
|
+ try
|
|
|
+ if volatile(FCachedlibcPath)='' then
|
|
|
+ begin
|
|
|
{$endif NO_THREADING}
|
|
|
- FCachedlibcPath:=s;
|
|
|
+ FCachedlibcPath:=s;
|
|
|
{$ifndef NO_THREADING}
|
|
|
- finally
|
|
|
- LeaveCriticalsection(FGeneralCriticalSection);
|
|
|
- end;
|
|
|
+ end;
|
|
|
+ finally
|
|
|
+ LeaveCriticalsection(FGeneralCriticalSection);
|
|
|
+ end;
|
|
|
{$endif NO_THREADING}
|
|
|
- end;
|
|
|
- end;
|
|
|
+ end;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ { make sure we don't access the contents of the string before they've been
|
|
|
+ synchronised from the thread that wrote them; the critical section there
|
|
|
+ acts as a read/write barrier }
|
|
|
+ ReadBarrier;
|
|
|
|
|
|
- Args.Add('-Fl'+FCachedlibcPath);
|
|
|
+ Args.Add('-Fl'+volatile(FCachedlibcPath));
|
|
|
end;
|
|
|
|
|
|
// Custom options which are added by dependencies
|
|
@@ -7085,7 +7095,7 @@ begin
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
- S:=GetCompilerCommand(APackage,ATarget,Env);
|
|
|
+ S:=GetCompilerCommand(APackage,ATarget,nil);
|
|
|
ExecuteCommand(GetCompiler,S,nil);
|
|
|
end;
|
|
|
If Assigned(ATarget.AfterCompile) then
|