Skip to content

Commit

Permalink
[release/6.0-rc1] MonoAOTCompiler: Check for proxy file's target only…
Browse files Browse the repository at this point in the history
… when the cache is being used. (#57867)

Backport of #57865

Fixes #57800 .
  • Loading branch information
radical authored Aug 24, 2021
1 parent faf0c8f commit 8fde874
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public override bool Execute()
if (!result.IsCompleted)
{
if (!Log.HasLoggedErrors)
Log.LogError("Unknown failed occured while compiling");
Log.LogError("Unknown failure occured while compiling");

return false;
}
Expand Down Expand Up @@ -646,17 +646,14 @@ private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths)
Log.LogError($"Precompiling failed for {assembly}: {ex.Message}");
return false;
}

finally
{
File.Delete(responseFilePath);
}

bool copied = false;
foreach (var proxyFile in proxyFiles)
{
if (!File.Exists(proxyFile.TempFile))
{
Log.LogError($"Precompiling failed for {assembly}. Could not find output file {proxyFile.TempFile}");
return false;
}

copied |= proxyFile.CopyOutputFileIfChanged();
_fileWrites.Add(proxyFile.TargetFile);
}
Expand All @@ -668,7 +665,6 @@ private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths)
Log.LogMessage(MessageImportance.High, $"[{count}/{_totalNumAssemblies}] {Path.GetFileName(assembly)} -> {copiedFiles}");
}

File.Delete(responseFilePath);
compiledAssemblies.GetOrAdd(aotAssembly.ItemSpec, aotAssembly);
return true;
}
Expand All @@ -677,36 +673,44 @@ private bool PrecompileLibrarySerial(ITaskItem assemblyItem, string? monoPaths)
{
try
{
if (!PrecompileLibrary(assemblyItem, monoPaths))
return !Log.HasLoggedErrors;
return true;
if (PrecompileLibrary(assemblyItem, monoPaths))
return true;
}
catch (LogAsErrorException laee)
{
Log.LogError($"Precompile failed for {assemblyItem}: {laee.Message}");
}
catch (Exception ex)
{
if (Log.HasLoggedErrors)
Log.LogMessage(MessageImportance.Low, $"Precompile failed for {assemblyItem}: {ex}");
else
Log.LogError($"Precompile failed for {assemblyItem}: {ex}");

return false;
}

return false;
}

private void PrecompileLibraryParallel(ITaskItem assemblyItem, string? monoPaths, ParallelLoopState state)
{
try
{
if (!PrecompileLibrary(assemblyItem, monoPaths))
state.Break();
if (PrecompileLibrary(assemblyItem, monoPaths))
return;
}
catch (LogAsErrorException laee)
{
Log.LogError($"Precompile failed for {assemblyItem}: {laee.Message}");
}
catch (Exception ex)
{
if (Log.HasLoggedErrors)
Log.LogMessage(MessageImportance.Low, $"Precompile failed for {assemblyItem}: {ex}");
else
Log.LogError($"Precompile failed for {assemblyItem}: {ex}");
state.Break();
}

state.Break();
}

private bool GenerateAotModulesTable(ITaskItem[] assemblies, string[]? profilers, string outputFile)
Expand Down Expand Up @@ -927,6 +931,9 @@ public bool CopyOutputFileIfChanged()
if (!_cache.Enabled)
return true;

if (!File.Exists(TempFile))
throw new LogAsErrorException($"Could not find output file {TempFile}");

if (!_cache.ShouldCopy(this, out string? cause))
{
_cache.Log.LogMessage(MessageImportance.Low, $"Skipping copying over {TargetFile} as the contents are unchanged");
Expand Down

0 comments on commit 8fde874

Please sign in to comment.