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

[WASM] OpenCvSharp4.runtime.wasm fails to publish in .NET 9 when trimming and/or linking is enabled #1731

Open
Riccorbypro opened this issue Dec 13, 2024 · 0 comments

Comments

@Riccorbypro
Copy link

Riccorbypro commented Dec 13, 2024

Summary of your issue

When migrating from .NET 8 to .NET 9 in Blazor WebAssembly, the WASM runtime package for OpenCvSharp4 causes compile issues.

Environment

Blazor WebAssembly

What did you do when you faced the problem?

I was upgrading a project that uses OpenCvSharp to .NET 9 and encountered this issue. I have provided a minimal reproduction repository here: Riccorbypro/ReproRepo.OpenCvSharp.Blazor.Net9.Compile

Example code:

Note: No actual usage of the library is required, simply including the runtime package is enough to cause the error.

<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108"/>
<PackageReference Include="OpenCvSharp4.runtime.wasm" Version="4.10.0.20241108"/>

Output:

When publishing, the wasm compiler produces the following:

wasm-ld : error : Z:\Nuget\Packages\opencvsharp4.runtime.wasm\4.10.0.20241108\build\net6.0\..\..\runtimes\browser-wasm\2.0.23\OpenCvSharpExtern.a(libopencv.o): undefined symbol: std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>::__grow_by(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
emcc : error : '"C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.56.Sdk.win-x64\9.0.0\tools\bin\wasm-ld.exe" -o Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\dotnet.native.wasm Z:\Nuget\Packages\opencvsharp4.runtime.wasm\4.10.0.20241108\build\net6.0\..\..\runtimes\browser-wasm\2.0.23\OpenCvSharpExtern.a Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\pinvoke.o Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\driver.o Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\corebindings.o Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\runtime.o "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libicudata.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libicui18n.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libicuuc.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-component-debugger-stub-static.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-component-diagnostics_tracing-stub-static.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-component-hot_reload-stub-static.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-component-marshal-ilgen-static.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-ee-interp.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-icall-table.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-profiler-aot.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-profiler-browser.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-profiler-log.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-wasm-eh-wasm.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmono-wasm-simd.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libmonosgen-2.0.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libSystem.Globalization.Native.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libSystem.IO.Compression.Native.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libSystem.Native.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\libz.a" "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\wasm-bundled-timezones.a" "-LC:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.56.Cache.win-x64\9.0.0\tools\emscripten\cache\sysroot\lib\wasm32-emscripten" -lGL-getprocaddr -lal -lhtml5 -lbulkmemory -lstubs -lc -ldlmalloc -lcompiler_rt-wasm-sjlj -lc++-except -lc++abi-except -lunwind-except -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -mllvm -wasm-enable-eh -mllvm -exception-model=wasm C:\Users\ricco\AppData\Local\Temp\tmpihqoaynelibemscripten_js_symbols.so --export=free --export=htons --export=malloc --export=sbrk --export=memalign --export=memset --export=ntohs --export=stackAlloc --export=stackRestore --export=stackSave --export=fmod --export=atan2 --export=fma --export=pow --export=fmodf --export=atan2f --export=fmaf --export=powf --export=asin --export=asinh --export=acos --export=acosh --export=atan --export=atanh --export=cbrt --export=cos --export=cosh --export=exp --export=log --export=log2 --export=log10 --export=sin --export=sinh --export=tan --export=tanh --export=asinf --export=asinhf --export=acosf --export=acoshf --export=atanf --export=atanhf --export=cbrtf --export=cosf --export=coshf --export=expf --export=logf --export=log2f --export=log10f --export=sinf --export=sinhf --export=tanf --export=tanhf --export=stackAlloc --export=__funcs_on_exit --export=__trap --export=__cpp_exception --export=__wasm_call_ctors --export=__get_exception_message --export=free --export=stackSave --export=stackRestore --export=__thrown_object_from_unwind_exception --export=__cxa_increment_exception_refcount --export=__cxa_decrement_exception_refcount --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=fflush --export-table --growable-table -z stack-size=5242880 --max-memory=2147483648 --initial-memory=33554432 --no-entry --table-base=1 --global-base=1024' failed (returned 1)
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\9.0.0\Sdk\BrowserWasmApp.targets(494,5): error MSB3073: The command "emcc "@C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\src\emcc-default.rsp" -msimd128 "@C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\9.0.0\runtimes\browser-wasm\native\src\emcc-link.rsp" "@Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\emcc-link.rsp"" exited with code 1.
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\9.0.0\Sdk\BrowserWasmApp.targets(511,5): error : Use '-p:WasmAllowUndefinedSymbols=true' to allow undefined symbols

Following the advice to enable WasmAllowUndefinedSymbols does allow the build to complete in Debug mode, but attempting to compile in Release instead causes the following error:

EXEC : warning : undefined symbol: _ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm (referenced by root reference (e.g. compiled C/C++ code))
emcc : warning : warnings in JS library compilation [-Wjs-compiler]
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\9.0.0\Sdk\WasmApp.Common.targets(934,5): error MSB3073: The command "wasm-opt.exe --enable-simd --enable-exception-handling --enable-bulk-memory --enable-simd --strip-dwarf "Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\dotnet.native.wasm" -o "Z:\RiderProjects\OpenCvBlazorIssue\OpenCvBlazorIssue.Net9\obj\Release\net9.0\wasm\for-publish\dotnet.native.wasm"" exited with code 1.

What did you intend to be?

The project should compile and publish successfully under .NET9, as is currently the case in .NET8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant