Skip to content
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

Rust built WASM library in Blazor project fails on wasm-opt when being published #96394

Closed
1 task done
shakenov-chinga opened this issue Dec 27, 2023 · 20 comments
Closed
1 task done
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono

Comments

@shakenov-chinga
Copy link

shakenov-chinga commented Dec 27, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi guys,
I've been trying to publish my project with this error. I've searched a lot and tried a bunch of stuff, but none of them worked. Then I stumbled upon the issue where BlazeOrbit was recommended to verified the issue. The same error occurs on that project too.

image
I get this error:
error.log

Expected Behavior

It should have published the project

Steps To Reproduce

My steps are:

  1. Run command in PowerShell BlazeOrbital\rustqr> cargo build --target wasm32-unknown-emscripten
  2. In BlazeOrbital\rustqr\Cargo.toml change from crate-type = ["staticlib"] to crate-type = ["dylib"] (I need dll for BlazeOrbital.Accounting)
  3. Run command BlazeOrbital\rustqr> cargo build --target x86_64-pc-windows-msvc
  4. Build solution in Visual Studio 2022
  5. Press "Publish" on BlazeOrbital.ManufacturingHub project
  6. Select folder profile with default values
  7. Press "Publish"

Exceptions (if any)

No response

.NET Version

6.0

Anything else?

No response

@shakenov-chinga
Copy link
Author

Is there any other info I should send?

>cargo --version
cargo 1.74.1 (ecb9851af 2023-10-18)
>rustc --version
rustc 1.74.1 (a28077b28 2023-12-04)

Also installed wasm-opt cargo, it shows different error. Can it be that the error is caused by either Rust wasm compiler or wasm-opt itself?

@shakenov-chinga
Copy link
Author

Hey guys.
Happy holidays!

Let me know, please, if I forgot to mention something important. I hoped to tinker with the blazor wasm + rust wasm while i'm of the work )

@javiercn javiercn transferred this issue from dotnet/aspnetcore Jan 2, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 2, 2024
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 2, 2024
@radical radical added the arch-wasm WebAssembly architecture label Jan 2, 2024
@ghost
Copy link

ghost commented Jan 2, 2024

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

Issue Details

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi guys,
I've been trying to publish my project with this error. I've searched a lot and tried a bunch of stuff, but none of them worked. Then I stumbled upon the issue where BlazeOrbit was recommended to verified the issue. The same error occurs on that project too.

image
I get this error:
error.log

Expected Behavior

It should have published the project

Steps To Reproduce

My steps are:

  1. Run command in PowerShell BlazeOrbital\rustqr> cargo build --target wasm32-unknown-emscripten
  2. In BlazeOrbital\rustqr\Cargo.toml change from crate-type = ["staticlib"] to crate-type = ["dylib"] (I need dll for BlazeOrbital.Accounting)
  3. Run command BlazeOrbital\rustqr> cargo build --target x86_64-pc-windows-msvc
  4. Build solution in Visual Studio 2022
  5. Press "Publish" on BlazeOrbital.ManufacturingHub project
  6. Select folder profile with default values
  7. Press "Publish"

Exceptions (if any)

No response

.NET Version

6.0

Anything else?

No response

Author: shakenov-chinga
Assignees: -
Labels:

arch-wasm, untriaged, needs-area-label

Milestone: -

@MihaZupan MihaZupan removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 2, 2024
@shakenov-chinga
Copy link
Author

Hi guys! How is it going? Writing to let you know that I still need the thing, and I'm afraid that this problem will be automatically closed.

Thanks in advance! 👍

@maraf
Copy link
Member

maraf commented Jan 23, 2024

No worries, the issue won't get closed without resolution. Sorry I didn't get to it earlier. I'm going to investigate it now.
Does the same problem manifest when targeting .NET 8?

@shakenov-chinga
Copy link
Author

I had problems with .NET 8 before I found and reproduced it on BlazeOrbit. I haven't tried BlazeOrbit using .NET 8.

@maraf
Copy link
Member

maraf commented Jan 23, 2024

Publishing BlazeOrbit from VS worked on my machine. Can you please publish it using command line dotnet publish -c Release -bl and share the binlogu?

@shakenov-chinga
Copy link
Author

Binlog file: msbuild.binlog.zip.
The actual error in cmd:

C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\6.0.25\Sdk\WasmApp.Native.targets(386,5): error MSB3073: The command "wasm-opt.exe --strip-dwarf "C:\Users\user_0\source\repos\BlazeOrbital\ManufacturingHub\obj\Release\net6.0\wasm\for-publish\dotnet.wasm" -o "C:\Users\user_0\source\repos\BlazeOrbital\ManufacturingHub\obj\Release\net6.0\wasm\for-publish\dotnet.wasm"" exited with code 1. [C:\Users\user_0\source\repos\BlazeOrbital\ManufacturingHub\BlazeOrbital.ManufacturingHub.csproj]

@maraf
Copy link
Member

maraf commented Jan 24, 2024

The .NET 6 demo doesn't work because incompatiblity between cargo and wasm-opt that is shipped in wasm-tools-net6 workload. For more info see

After upgrading the demo to .NET 8 publish passed successfully.

What problems are you facing with .NET 8? Can you share more details or simple repro?

@maraf maraf added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jan 24, 2024
@ghost
Copy link

ghost commented Jan 24, 2024

This issue has been marked needs-author-action and may be missing some important information.

@shakenov-chinga
Copy link
Author

Hi, thank you very much!

Turns out I gave you wrong info about using .NET 8. I used .NET 8 for every project except for blazor project itself, because it gave me weird error like this:
DISABLE_EXCEPTION_THROWING was set (likely due to -fno-exceptions), which means no C++ exception throwing support code is linked in, but exception catching code appears. Either do not set DISABLE_EXCEPTION_THROWING (if you do want exception throwing) or compile all source files with -fno-except (so that no exceptions support code is required); also make sure DISABLE_EXCEPTION_CATCHING is set to the right value - if you want exceptions, it should be off, and vice versa.
The whole build output: build_error.log.

I wasn't able to find any information about this error anywhere, and I wanted to finish testing things on Blazor and WASM on new year's day offs. So, I just switched the Blazor project to .NET 7, which gave the same error in my very first comment.

Could you, please, provide me some info on how deal with this error, if you have any, so that I would be able to confirm that project publishes without any issues on .NET 8.

Also, I wasn't able to look though the links above. I plan to do it on this weekends.

Thanks! )

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Jan 26, 2024
@maraf
Copy link
Member

maraf commented Jan 30, 2024

IIRC disabling WASM EH did the trick <WasmEnableExceptionHandling>false</WasmEnableExceptionHandling>.
A better solution would be to instruct rust to do the opposite, but I'm not familier with the tooling.

@maraf maraf added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jan 30, 2024
@ghost
Copy link

ghost commented Jan 30, 2024

This issue has been marked needs-author-action and may be missing some important information.

@lewing
Copy link
Member

lewing commented Feb 5, 2024

Hi, thank you very much!

Turns out I gave you wrong info about using .NET 8. I used .NET 8 for every project except for blazor project itself, because it gave me weird error like this: DISABLE_EXCEPTION_THROWING was set (likely due to -fno-exceptions), which means no C++ exception throwing support code is linked in, but exception catching code appears. Either do not set DISABLE_EXCEPTION_THROWING (if you do want exception throwing) or compile all source files with -fno-except (so that no exceptions support code is required); also make sure DISABLE_EXCEPTION_CATCHING is set to the right value - if you want exceptions, it should be off, and vice versa. The whole build output: build_error.log.

I wasn't able to find any information about this error anywhere, and I wanted to finish testing things on Blazor and WASM on new year's day offs. So, I just switched the Blazor project to .NET 7, which gave the same error in my very first comment.

Could you, please, provide me some info on how deal with this error, if you have any, so that I would be able to confirm that project publishes without any issues on .NET 8.

Also, I wasn't able to look though the links above. I plan to do it on this weekends.

Thanks! )

I see the build is using sqlite are you building it yourself or using existing packages?

@shakenov-chinga
Copy link
Author

Hi @maraf,
Thanks you very much. I apologize for the long answer. I was able to compile, publish and run my project on .net8 using <WasmEnableExceptionHandling>false</WasmEnableExceptionHandling> property.

Hi @lewing,
For .net8 I didn't use pre-build e_sqlite3.o, I've found somewhere that I should reference <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" /> instead.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 8, 2024
@lewing
Copy link
Member

lewing commented Feb 9, 2024

It appears at first glance that the problem you were seeing is because of a c++ native library that was built with different ABI settings than the runtime. Are you referencing any other native libraries?

@shakenov-chinga
Copy link
Author

@lewing, except for rustqr? No. I didn't make any changes in BlazeOrbital sqlite package reference and nuget packages update.

@lewing
Copy link
Member

lewing commented Feb 9, 2024

@SteveSandersonMS you are up ;)

@SteveSandersonMS
Copy link
Member

@lewing Can you clarify - are you asking me a question? From reading the thread above it seems like @maraf was able to debug what's going on and tracked it down to some version incompatibilities.

@maraf
Copy link
Member

maraf commented Mar 20, 2024

I'm going to close this issue now as I believe the problem lies with rust tooling configuration. In my previous comment there are hints I was about to found, but I'm not expert there. Whether to maintain BlazorOrbital sample up to date with every .NET release is more of a question for that repo.

Feel free to reopen the issue if you see problem on .NET runtime side.

@maraf maraf closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Mar 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Projects
None yet
Development

No branches or pull requests

7 participants