-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NativeAOT-LLVM, Wasm] Cannot marshal multiple arrays by reference #2233
Comments
Hmm, that's produced by the IL backend (which is now gone). I see we should have packages with the more recent compiler, but they are probably/possibly broken publishing wise. |
I remember having some other issues with net8.0-based packages, not sure what those were though. I can give it a try again again and report back here. |
Where is this from btw / how do I find the latest version? Packages like |
Thanks. Another question: if IL backend is gone, do I still need |
Tried commenting that one out, and it seems to compile even without it. Going to try those marshalling examples now. |
Looks like this marshalling indeed works correctly in latest 8.0.0-*, thanks. |
Ah no wait, need more testing. I remember what the issue was now - looks like Did something change in how it's supposed to be passed? |
FWIW this is what updated csproj section looks like (variation of #2196 (comment) just with new version):
|
It may need |
Yeah already using it - needed it for 7.0.0-* anyway. |
FWIW this is what my sample csproj looks like - I started off working template by @kant2002 and hardcoded some more options to avoid passing them on command line: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<NativeLib>Shared</NativeLib>
<!-- <OutputType>Exe</OutputType> -->
<TargetArchitecture>wasm</TargetArchitecture>
<PlatformTarget>AnyCPU</PlatformTarget>
<MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<!-- <Nullable>enable</Nullable> -->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EmitLegacyAssetsFileItems>true</EmitLegacyAssetsFileItems>
<EmccExtraArgs>--no-entry -s STANDALONE_WASM -s WASM_ASYNC_COMPILATION=0 -s EXPORTED_FUNCTIONS=["_NativeAOT_StaticInitialization","(...my functions...)"] -g2</EmccExtraArgs>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<!-- size opts -->
<InvariantGlobalization>true</InvariantGlobalization>
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
<IlcDisableReflection>true</IlcDisableReflection>
</PropertyGroup>
<!-- PropertyGroup only for Release mode -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<NativeDebugSymbols>false</NativeDebugSymbols>
</PropertyGroup>
<ItemGroup>
<!-- Works with these versions:
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler" TargetFramework="net7.0" ILCompilerPackNamePattern="runtime.**RID**.Microsoft.DotNet.ILCompiler.LLVM" ILCompilerPackVersion="7.0.0-preview.5.23113.1" ILCompilerRuntimeIdentifiers="browser-wasm;linux-musl-x64;linux-x64;win-x64;linux-arm;linux-arm64;linux-musl-arm;linux-musl-arm64;osx-arm64;osx-x64;win-arm;win-arm64;win-x86" />
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="7.0.0-preview.5.23113.1" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="7.0.0-preview.5.23113.1" />
-->
<!-- Doesn't work with these versions: -->
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler" TargetFramework="net7.0" ILCompilerPackNamePattern="runtime.**RID**.Microsoft.DotNet.ILCompiler.LLVM" ILCompilerPackVersion="8.0.0-alpha.1.23170.1" ILCompilerRuntimeIdentifiers="browser-wasm;linux-musl-x64;linux-x64;win-x64;linux-arm;linux-arm64;linux-musl-arm;linux-musl-arm64;osx-arm64;osx-x64;win-arm;win-arm64;win-x86" />
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-alpha.1.23170.1" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-alpha.1.23170.1" />
</ItemGroup>
</Project> Let me know if anything looks off. |
I don't need to update the |
In theory, 7.0 SDK should work. If you have a binlog ( |
Just pushed a minimal sample including binlog for the failing update to https://github.com/RReverser/minisample |
@RReverser Try following steps
|
That one (at least in isolation) still doesn't work:
Not sure if I can apply it locally, assuming you mean e.g. src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.SingleEntry.targets -> .packages\microsoft.dotnet.ilcompiler.llvm\8.0.0-alpha.1.23170.1\build\Microsoft.DotNet.ILCompiler.SingleEntry.targets, as the contents look pretty different, I assume the latter is prebuilt with some transformations. Wouldn't that patch be included in latest version - 8.0.0-alpha.1.23170.1 - anyway?
Sorry, not sure what you mean by pin here (aside from having my TargetFramework set to |
diff --git a/minisample.csproj b/minisample.csproj
index b1090de..d872a5c 100644
--- a/minisample.csproj
+++ b/minisample.csproj
@@ -11,6 +11,7 @@
<EmccExtraArgs>--no-entry -s EXPORTED_FUNCTIONS=[_NativeAOT_StaticInitialization,_hello]</EmccExtraArgs>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
+ <PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
@@ -23,7 +24,7 @@
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler" TargetFramework="net7.0" ILCompilerPackNamePattern="runtime.**RID**.Microsoft.DotNet.ILCompiler.LLVM" ILCompilerPackVersion="8.0.0-alpha.1.23170.1" ILCompilerRuntimeIdentifiers="browser-wasm;linux-musl-x64;linux-x64;win-x64;linux-arm;linux-arm64;linux-musl-arm;linux-musl-arm64;osx-arm64;osx-x64;win-arm;win-arm64;win-x86" />
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-alpha.1.23170.1" />
- <PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-alpha.1.23170.1" />
</ItemGroup>
{
"sdk": {
"version": "7.0.300-preview.23122.5"
}
} |
Just to be clear, did you mean here just from the first PR or from the second one as well? I applied the first one + other described steps, but that doesn't seem to be enough, and I can't apply changes from the 2nd one because local content looks quite different, as mentioned before. Either way, even if I can get it to work with manual patching, it doesn't seem like a very sustainable solution as it would be destroyed & hard to share with others unless I commit I think I'm going to stay on the latest |
Yes. Only first one is needed.
Sure. I do not think this is as sustainable solution. I just do not 100% that this solves your issues. Anyway you can try https://github.com/kant2002/minisample and run
NativeAOT LLVM is closer and closer to how .NET SDK consume ILC. That's changes substantially from early NativeAOT days and we are in transition period. I think I need @SingleAccretion seal of approval on my PR. Also can you post your |
Thanks, had to fix up the build script & global.json for my local environment, but it does generate Wasm! I wonder what I missed in the previous instruction - the only thing I can think of is that I manually edited that one line in Microsoft.DotNet.ILCompiler.SingleEntry.targets instead of copying the entire new file, but they should be the same? FWIW there are some missing symbols though:
Sure, I think it's just the latest 7.0, but here's the full list:
Now that I tried without it, looks like the global.json pinning is not necessary for me after all. |
FWIW, working on fixing the publishing right now...
(#2226) |
@RReverser I think you missing clearing bin,obj after copy files. https://github.com/kant2002/minisample/blob/e2efef31026307a2d158507c44045397e41b2ac6/build.ps1#L5-L6 That's because
Yes, you did everything right. I should go with automatable instructions in first place. |
I see, thanks! |
Closing this issue as I just rechecked the original code and it indeed works on 8.0.0 previews and I'm guessing there is no interest in backporting / continuing on the old version. |
Minimal repro:
When built with
7.0.0-preview.5.23113.1
for the Wasm target, this results in broken LLVM IR:If I remove one of the params, or even just the
in
specifier from one of the params, it compiles fine.The text was updated successfully, but these errors were encountered: