Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5f569e3
Refactor to allow fast-path
radical Sep 11, 2021
5b3b91f
MonoAOTCompiler: check for nothing-changed case
radical Sep 11, 2021
28fdcba
[wasm] Change optimization flag defaults for Debug config
radical Sep 17, 2021
6e52172
[wasm] EmccCompile: Fix incremental build, in case of only partial
radical Sep 21, 2021
08ae443
MonoAOTCompiler: Skip unmanaged assemblies, and emit a warning
radical Sep 22, 2021
7fe0e69
Apply suggestions from code review
radical Sep 22, 2021
1c0a340
MonoAOTCompiler: write the cache even when some files fail to compile
radical Sep 22, 2021
7230cd3
Don't set optimization defaults for Debug config, when publishing
radical Sep 22, 2021
c71f9c2
Wasm.Build.Tests: Disable net5.0 because they can't be tested right now
radical Sep 23, 2021
110ed85
[wasm] Error for undefined symbols only when publishing
radical Sep 24, 2021
d17bc64
[wasm] PInvokeTableGenerator: Add support for variadic functions
radical Sep 24, 2021
8ecfd1c
[wasm] Handle pinvokes with function pointers
radical Sep 24, 2021
f4cb745
[wasm] PInvokeTableGenerator: handle pinvokes with function pointers
radical Sep 25, 2021
aac1537
add missing variadic.{c,o}
radical Sep 25, 2021
f48d6b2
[wasm] Add test for issue dotnet#59255
radical Sep 25, 2021
9dd1976
Bump sdk for workload testing to 6.0.100-rc.2.21474.31
radical Sep 22, 2021
46ddc76
Merge remote-tracking branch 'origin/main' into wasm-improvements
radical Sep 27, 2021
712dbb3
MonoAOTCompiler: Check the hash for the file also, for "all up-to-dat…
radical Sep 27, 2021
b23e11e
Merge remote-tracking branch 'origin/main' into wasm-improvements
radical Sep 27, 2021
dc09bf6
Revert "MonoAOTCompiler: Check the hash for the file also, for "all u…
radical Sep 27, 2021
41c7476
PInvokeTableGenerator: don't generate any decl for variadic functions
radical Sep 27, 2021
dcbcc35
Add missing `using` for disposable objects.
radical Sep 29, 2021
1f57975
cleanup
radical Sep 29, 2021
4519646
Merge remote-tracking branch 'origin/main' into rf-wasm-improvements
radical Sep 29, 2021
20a67a1
address feedback from @lewing
radical Sep 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MonoAOTCompiler: Skip unmanaged assemblies, and emit a warning
  • Loading branch information
radical committed Sep 25, 2021
commit 08ae443d68da7e4138c0e3841339b137b3ffaa7b
63 changes: 39 additions & 24 deletions src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ private bool ProcessAndValidateArguments()
throw new LogAsErrorException($"'{nameof(OutputType)}=Library' can not be used with '{nameof(UseStaticLinking)}=true'.");
}

foreach (var asmItem in Assemblies)
{
string? fullPath = asmItem.GetMetadata("FullPath");
if (!File.Exists(fullPath))
throw new LogAsErrorException($"Could not find {fullPath} to AOT");
}

return !Log.HasLoggedErrors;
}

Expand All @@ -347,6 +354,7 @@ private bool ExecuteInternal()
return false;

_assembliesToCompile = EnsureAndGetAssembliesInTheSameDir(Assemblies);
_assembliesToCompile = FilterAssemblies(_assembliesToCompile);

if (!string.IsNullOrEmpty(AotModulesTablePath) && !GenerateAotModulesTable(_assembliesToCompile, Profilers, AotModulesTablePath))
return false;
Expand Down Expand Up @@ -428,60 +436,67 @@ static bool IsNewerThanOutput(string inFile, string outFile)
(File.GetLastWriteTimeUtc(inFile) > File.GetLastWriteTimeUtc(outFile));
}

private IList<ITaskItem> EnsureAndGetAssembliesInTheSameDir(ITaskItem[] originalAssemblies)
private IList<ITaskItem> FilterAssemblies(IEnumerable<ITaskItem> assemblies)
{
List<ITaskItem> filteredAssemblies = new();
string firstAsmDir = Path.GetDirectoryName(originalAssemblies[0].GetMetadata("FullPath")) ?? string.Empty;
bool allInSameDir = true;

foreach (var origAsm in originalAssemblies)
foreach (var asmItem in assemblies)
{
if (allInSameDir && Path.GetDirectoryName(origAsm.GetMetadata("FullPath")) != firstAsmDir)
allInSameDir = false;

if (ShouldSkip(origAsm))
if (ShouldSkip(asmItem))
{
if (parsedAotMode == MonoAotMode.LLVMOnly)
throw new LogAsErrorException($"Building in AOTMode=LLVMonly is not compatible with excluding any assemblies for AOT. Excluded assembly: {origAsm.ItemSpec}");
throw new LogAsErrorException($"Building in AOTMode=LLVMonly is not compatible with excluding any assemblies for AOT. Excluded assembly: {asmItem.ItemSpec}");

Log.LogMessage(MessageImportance.Low, $"Skipping {origAsm.ItemSpec} because it has %(AOT_InternalForceToInterpret)=true");
Log.LogMessage(MessageImportance.Low, $"Skipping {asmItem.ItemSpec} because it has %(AOT_InternalForceToInterpret)=true");
continue;
}

filteredAssemblies.Add(origAsm);
string assemblyPath = asmItem.GetMetadata("FullPath");
PEReader reader = new(File.OpenRead(assemblyPath), PEStreamOptions.Default);
if (!reader.HasMetadata)
{
Log.LogWarning($"Skipping unmanaged {assemblyPath} for AOT");
continue;
}

filteredAssemblies.Add(asmItem);
}

return filteredAssemblies;

static bool ShouldSkip(ITaskItem asmItem)
=> bool.TryParse(asmItem.GetMetadata("AOT_InternalForceToInterpret"), out bool skip) && skip;
}

private IList<ITaskItem> EnsureAndGetAssembliesInTheSameDir(IList<ITaskItem> assemblies)
{
string firstAsmDir = Path.GetDirectoryName(assemblies.First().GetMetadata("FullPath")) ?? string.Empty;
bool allInSameDir = assemblies.All(asm => Path.GetDirectoryName(asm.GetMetadata("FullPath")) == firstAsmDir);
if (allInSameDir)
return filteredAssemblies;
return assemblies;

// Copy to aot-in

string aotInPath = Path.Combine(IntermediateOutputPath, "aot-in");
Directory.CreateDirectory(aotInPath);

List<ITaskItem> newAssemblies = new();
foreach (var origAsm in originalAssemblies)
foreach (var asmItem in assemblies)
{
string asmPath = origAsm.GetMetadata("FullPath");
string asmPath = asmItem.GetMetadata("FullPath");
string newPath = Path.Combine(aotInPath, Path.GetFileName(asmPath));

// FIXME: delete files not in originalAssemblies though
// FIXME: or .. just delete the whole dir?
if (Utils.CopyIfDifferent(asmPath, newPath, useHash: true))
Log.LogMessage(MessageImportance.Low, $"Copying {asmPath} to {newPath}");
_fileWrites.Add(newPath);

if (!ShouldSkip(origAsm))
{
ITaskItem newAsm = new TaskItem(newPath);
origAsm.CopyMetadataTo(newAsm);
newAssemblies.Add(newAsm);
}
ITaskItem newAsm = new TaskItem(newPath);
asmItem.CopyMetadataTo(newAsm);
newAssemblies.Add(newAsm);
}

return newAssemblies;

static bool ShouldSkip(ITaskItem asmItem)
=> bool.TryParse(asmItem.GetMetadata("AOT_InternalForceToInterpret"), out bool skip) && skip;
}

private PrecompileArguments GetPrecompileArgumentsFor(ITaskItem assemblyItem, string? monoPaths)
Expand Down