Skip to content

[wasm][aot] build tries to cross compile unrelated dlls from the publish folder #46856

Closed

Description

@mdh1418

In effort to run library tests with AOT compilation on CI #46633, there are a number of failures arising from #46651.

Test suite System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj fails on MonoAOTCompiler task with

/Users/mdhwang/runtime_wasm_clean/src/mono/wasm/build/WasmApp.targets(43,5): error : Can not open image /Users/mdhwang/runtime_wasm_clean/artifacts/bin/System.Diagnostics.FileVersionInfo.Tests/net6.0-Browser-Release/browser-wasm/publish/NativeLibrary.dll [/Users/mdhwang/runtime_wasm_clean/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj]
/Users/mdhwang/runtime_wasm_clean/src/mono/wasm/build/WasmApp.targets(43,5): error : Precompiling failed for /Users/mdhwang/runtime_wasm_clean/artifacts/bin/System.Diagnostics.FileVersionInfo.Tests/net6.0-Browser-Release/browser-wasm/publish/NativeLibrary.dll: Error: Can not open image /Users/mdhwang/runtime_wasm_clean/artifacts/bin/System.Diagnostics.FileVersionInfo.Tests/net6.0-Browser-Release/browser-wasm/publish/NativeLibrary.dll [/Users/mdhwang/runtime_wasm_clean/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj]
/Users/mdhwang/runtime_wasm_clean/src/mono/wasm/build/WasmApp.targets(43,5): error :  [/Users/mdhwang/runtime_wasm_clean/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj]
/Users/mdhwang/runtime_wasm_clean/src/mono/wasm/build/WasmApp.targets(43,5): error :  [/Users/mdhwang/runtime_wasm_clean/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj]

System_diagnostics_fileversioninfo_fail.txt

Repro

Check out changes in #46651
./build.sh -os Browser -arch wasm -c Release
Remove

<!-- Temporary until https://github.com/mono/linker/issues/1713 is resolved -->
<assembly fullname="Microsoft.DotNet.RemoteExecutor">
<type fullname="Microsoft.DotNet.RemoteExecutor.Program">
<method signature="System.Int32 Main(System.String[])" />
</type>
</assembly>

Modify
catch (Exception e) when (IsIoRelatedException(e) && !disposing)
to be an empty catch

catch
{
}

./dotnet.sh build /t:Test /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release /p:EnableAggressiveTrimming=true /p:RunAOTCompilation=true src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj

Activity

  1. added this to the 6.0.0 milestone on Jan 12, 2021
  2. removed
    untriagedNew issue has not been triaged by the area owner
    on Jan 12, 2021
  3. radical commented on Jan 12, 2021

    @radical
    Member

    This depends on a native library, which is why MonoAOTCompiler fails with it. Are these tests supported, or should be supported on wasm? These were disabled in c72d522 .

    What is the expected behavior?

  4. changed the title [-]wasm AOT library test failure - Can not open image[/-] [+][wasm] AOT: Native libraries with projects don't work[/+] on Jan 12, 2021
  5. lambdageek commented on May 18, 2021

    @lambdageek
    Member

    The problem is that NativeLibrary.dll is a win32 dll, not a .NET assembly. So when we pass it to MonoAOTCompiler, it can't open it and fails.

    We should either:

    1. change the Content line in this test file to include some metadata that will tell the build infrastructure not to pass this assembly to the AOT compiler, or
    2. just skip this test
  6. lambdageek commented on May 18, 2021

    @lambdageek
    Member

    It also affects #52848. And probably ios device testing, too. basically anything that needs the AOT compiler

  7. steveisok commented on May 21, 2021

    @steveisok
    Member

    In #52848 I defined a <NativeLibraries> itemgroup. That ends up being part of the items that are excluded from the aot compiler. If there's a better way, I'm all ears.

    <ItemGroup Condition="'$(RunAOTCompilation)' == 'true'">
    <!-- Identifies native libraries that should be skipped during AOT -->
    <NativeLibraries Include="NativeLibrary.dll" />
    <NativeLibraries Include="SecondNativeLibrary.dll" />
    </ItemGroup>

    <_AotExcludeAssemblies Include="$(PublishDir)System.Runtime.WindowsRuntime.dll" />
    <_AotExcludeAssemblies Include="@(NativeLibraries->'$(PublishDir)%(Identity)')" />
    <AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(PublishDir)*.dll" Exclude="@(_AotExcludeAssemblies)">
    <AotArguments>@(MonoAOTCompilerDefaultAotArguments, ';')</AotArguments>
    <ProcessArguments>@(MonoAOTCompilerDefaultProcessArguments, ';')</ProcessArguments>
    </AotInputAssemblies>

  8. changed the title [-][wasm] AOT: Native libraries with projects don't work[/-] [+][wasm][aot] build tries to cross compile unrelated dlls from the publish folder[/+] on Jul 30, 2021
  9. lewing commented on Jul 31, 2021

    @lewing
    Member

    @radical what is your plan here?

  10. radical commented on Aug 1, 2021

    @radical
    Member

    Currently, we pick up all the files from the publish folder, where this assembly also ends up because it is in @(Content). I expect this to be fixed once we have the wasm targets taking the relevant list of referenced assemblies from earlier targets (eg. ResolveAssemblyReferences).

  11. radical commented on Sep 8, 2021

    @radical
    Member

    This needs some more work (a bit involved) to integrate with Publish at a more granular level.

  12. modified the milestones: 6.0.0, 7.0.0 on Sep 8, 2021
  13. ilonatommy commented on Jun 14, 2022

    @ilonatommy
    Member

    @radical, any progress?

  14. radical commented on Jun 14, 2022

    @radical
    Member

    @radical, any progress?

    No. We should keep this for 7.0 milestone for now, but I'm not sure if we'll actually be able to get to it. This is dependent on better integration with publish.

  15. radical commented on Jul 28, 2022

    @radical
    Member

    The original issue here - that of MonoAOTCompiler task trying to compile unmanaged dlls is fixed, as we skip those now.

    using PEReader reader = new(assemblyFile, PEStreamOptions.Default);
    if (!reader.HasMetadata)
    {
    Log.LogMessage(MessageImportance.Low, $"Skipping unmanaged {assemblyPath} for AOT");
    continue;

    The broader issue of handling publish assets better, is separate from this.

  16. ghost locked as resolved and limited conversation to collaborators on Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions