dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.96k stars 4.65k forks source link

WasiConsole -- publish warnings when trimming is disabled #94984

Open richlander opened 10 months ago

richlander commented 10 months ago

I am seeing a bunch of warnings if I set trimming to false for a wasi project. This is the wasiconsole template. There are no warnings when trimming is enabled.

Project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
    <OutputType>Exe</OutputType>
    <PublishTrimmed>false</PublishTrimmed>
    <WasmSingleFileBundle>true</WasmSingleFileBundle>
  </PropertyGroup>
</Project>

Results

root@dce487274468:/wasi# dotnet publish
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored /wasi/wasi.csproj (in 193 ms).
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll
  Optimizing assemblies for size. This process might take a while.
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/
  MicrosoftNetCoreAppRuntimePackRidNativeDir: /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.wasi-wasm/8.0.0/runtimes/wasi-wasm/native/
  Performing WASI SDK build: "/root/wasi-sdk/wasi-sdk-20.0/bin/clang" "@/wasi/obj/Release/net8.0/wasi-wasm/wasm/for-publish/clang-compile.rsp"
root@dce487274468:/wasi# vim wasi.csproj 
root@dce487274468:/wasi# dotnet publish
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored /wasi/wasi.csproj (in 129 ms).
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll
  wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/
  MicrosoftNetCoreAppRuntimePackRidNativeDir: /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.wasi-wasm/8.0.0/runtimes/wasi-wasm/native/
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::DeflateInit2_' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::Deflate' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::DeflateEnd' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::InflateInit2_' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::Inflate' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::InflateEnd' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+Sys::ConvertErrorPlatformToPal' because 'Could not find type 'System.Runtime.InteropServices.SuppressGCTransitionAttribute' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+Sys::ConvertErrorPalToPlatform' because 'Could not find type 'System.Runtime.InteropServices.SuppressGCTransitionAttribute' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+Sys::ConvertErrorPlatformToPal' because 'Could not find type 'System.Runtime.InteropServices.SuppressGCTransitionAttribute' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj]
ghost commented 10 months ago

Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.

Issue Details
I am seeing a bunch of warnings if I set trimming to false for a wasi project. This is the `wasiconsole` template. There are no warnings when trimming is enabled. Project: ```xml net8.0 wasi-wasm Exe false true ``` Results ```bash root@dce487274468:/wasi# dotnet publish MSBuild version 17.8.3+195e7f5a3 for .NET Determining projects to restore... Restored /wasi/wasi.csproj (in 193 ms). wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll Optimizing assemblies for size. This process might take a while. wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/ wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/ MicrosoftNetCoreAppRuntimePackRidNativeDir: /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.wasi-wasm/8.0.0/runtimes/wasi-wasm/native/ Performing WASI SDK build: "/root/wasi-sdk/wasi-sdk-20.0/bin/clang" "@/wasi/obj/Release/net8.0/wasi-wasm/wasm/for-publish/clang-compile.rsp" root@dce487274468:/wasi# vim wasi.csproj root@dce487274468:/wasi# dotnet publish MSBuild version 17.8.3+195e7f5a3 for .NET Determining projects to restore... Restored /wasi/wasi.csproj (in 129 ms). wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/ wasi -> /wasi/bin/Release/net8.0/wasi-wasm/wasi.dll wasi -> /wasi/bin/Release/net8.0/wasi-wasm/publish/ MicrosoftNetCoreAppRuntimePackRidNativeDir: /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.wasi-wasm/8.0.0/runtimes/wasi-wasm/native/ /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::DeflateInit2_' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::Deflate' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::DeflateEnd' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::InflateInit2_' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::Inflate' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+ZLib::InflateEnd' because 'Could not find type 'System.Enum' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+Sys::ConvertErrorPlatformToPal' because 'Could not find type 'System.Runtime.InteropServices.SuppressGCTransitionAttribute' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+Sys::ConvertErrorPalToPlatform' because 'Could not find type 'System.Runtime.InteropServices.SuppressGCTransitionAttribute' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0/Sdk/WasiApp.Native.targets(255,5): warning WASM0001: Could not get pinvoke, or callbacks for method 'Interop+Sys::ConvertErrorPlatformToPal' because 'Could not find type 'System.Runtime.InteropServices.SuppressGCTransitionAttribute' in assembly '/wasi/bin/Release/net8.0/wasi-wasm/publish/System.Runtime.dll'.' [/wasi/wasi.csproj] ```
Author: richlander
Assignees: -
Labels: `arch-wasm`, `os-wasi`
Milestone: -
lewing commented 9 months ago

These warnings look both wrong and impossible to act upon. @kg we definitely shouldn't warn for things the use cannot possible fix