dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

`wasm-tools` workload breaks `dotnet publish` in docker #32327

Closed tibuprophen closed 6 months ago

tibuprophen commented 1 year ago

Describe the bug

I am developing a Blazor WASM Application. I want to use the .NET 6 introduced Native Build for Sqlite (A nice package is delivered by this nice guy: https://github.com/JeremyLikness/SqliteWasmHelper).

To activate the Native Build Feature I need to install wasm-tools workload.

Developing on my Host machine works fine, but when I try to dockerize this, it comes to errors, especially setting the configuration as dotnet publish parameter in combination with installing the WASM-Tools: ✅ Not installing WASM Tools is working ✅ Installing WASM Tools without dotnet publish parameters is working 🚫 Installing WASM Tools and using dotnet publish parameters is not working

Please see my examples to reproduce for further details.

To Reproduce

✅ Not installing WASM Tools is working ``` FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine #RUN dotnet workload install wasm-tools WORKDIR /app RUN dotnet new blazorwasm -o BlazorEmpty WORKDIR /app/BlazorEmpty #RUN dotnet publish RUN dotnet publish --configuration Release ```
✅ Installing WASM Tools without dotnet publish parameters is working ``` FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine RUN dotnet workload install wasm-tools WORKDIR /app RUN dotnet new blazorwasm -o BlazorEmpty WORKDIR /app/BlazorEmpty RUN dotnet publish # RUN dotnet publish --configuration Release ```
🚫 Installing WASM Tools and using dotnet publish parameters is not working ``` FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine RUN dotnet workload install wasm-tools WORKDIR /app RUN dotnet new blazorwasm -o BlazorEmpty WORKDIR /app/BlazorEmpty # RUN dotnet publish RUN dotnet publish --configuration Release ```

The last scenario should work imo. I get the following error:

 > [6/6] RUN dotnet publish --configuration Release:                                                                                                                                                                                                                
#0 0.551 MSBuild version 17.5.1+f6fdcf537 for .NET                                                                                                                                                                                                                  
#0 1.972   Determining projects to restore...                                                                                                                                                                                                                       
#0 3.204   All projects are up-to-date for restore.                                                                                                                                                                                                                 
#0 8.343   BlazorEmpty -> /app/BlazorEmpty/bin/Release/net7.0/BlazorEmpty.dll                                                                                                                                                                                       
#0 8.345   BlazorEmpty (Blazor output) -> /app/BlazorEmpty/bin/Release/net7.0/wwwroot
#0 8.526   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
#0 8.531   Optimizing assemblies for size. This process might take a while.
#0 12.77   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
#0 12.80   /bin/sh: /tmp/MSBuildTemproot/tmp2b43989dc6514e5c8ed88e234186b25d.exec.cmd: line 2: /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/7.0.5/Sdk/../tools/mono-aot-cross: not found
#0 12.80 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/7.0.5/Sdk/WasmApp.Native.targets(283,5): error MSB3073: The command ""/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/7.0.5/Sdk/../tools/mono-aot-cross" --print-icall-table > "/app/BlazorEmpty/obj/Release/net7.0/wasm/for-publish/runtime-icall-table.h"" exited with code 127. [/app/BlazorEmpty/BlazorEmpty.csproj]

It tells me mono-aot-cross: not found is not found and docker exited with code 127 (file in container not found), but the file is available.

Further technical details

tibuprophen commented 1 year ago

Update / Workaround

By not using alpine and installing python3 seems to fix the problem. Dockerfile looks like this:

FROM mcr.microsoft.com/dotnet/sdk:7.0

RUN dotnet workload install wasm-tools
WORKDIR /app

RUN dotnet new blazorwasm -o BlazorEmpty
WORKDIR /app/BlazorEmpty

RUN apt-get update
RUN apt-get install -y python3

RUN dotnet publish --configuration Release
baronfel commented 1 year ago

I repro (thanks for the Dockerfiles!) and I think part of the scenario might be failing because linux-x64 runtime packs are being used for browser-wasm here instead of musl-variants. @lewing Is this something you know about?

lewing commented 1 year ago

mono-aot-cross is a native binary in one of the workload packs. It should be there after a workload install, I'm not sure why it would be missing.

baronfel commented 1 year ago

I'll see if I can grab a binlog from the dockerfile and see if anything stands out, then.

baronfel commented 1 year ago

@lewing it does exist on disk, but the thing that's happening is the linux-x64 version of the pack is being downloaded, not the linux-musl-x64 version. As a result, the mono-aot-cross binary doesn't launch and we get the 'not found' message (which is really a 'couldn't launch' message).

image

lewing commented 1 year ago

ok, if that is the case we have a different problem, there is no linux-musl-x64 pack for mono-aot-cross and if we were to produce one does the workload resolver know the difference? What is the error when it fails to run?

lewing commented 1 year ago

cc @directhex

directhex commented 1 year ago

We aren't building cross compilers for musl. I'll throw up a PR to try enabling it.

directhex commented 1 year ago

https://github.com/dotnet/runtime/pull/87841

boukenka commented 11 months ago

Hello. I am facing the same issue. I am using 7.0.403-alpine3.18 and 7.0.13-alpine3.18 :

/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/7.0.13/Sdk/WasmApp.Native.targets(283,5): error MSB3073: The command ""/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/7.0.13/Sdk/../tools/mono-aot-cross" --print-icall-table > "/src/Client/obj/Release/net7.0/wasm/for-build/runtime-icall-table.h"" exited with code 127. [/src/Client/...csproj]

Any workaround ? I know it can be solved by using Debian 12 instead.

PS : The error is happening during the execution of the command : RUN dotnet build

lbussell commented 9 months ago

I am hitting this issue today with Alpine 3.18 + .NET 8 compiling a Blazor WASM app. @directhex it seems your fix in runtime may not have worked for Alpine?

Error output:

 > [publish 2/2] RUN dotnet publish "BlazorApp1.csproj" -c Release -o /app/publish /p:UseAppHost=false:
1.533 MSBuild version 17.8.3+195e7f5a3 for .NET
2.436   Determining projects to restore...
2.966   All projects are up-to-date for restore.
3.965   BlazorApp1 -> /src/bin/Release/net8.0/BlazorApp1.dll
3.968   BlazorApp1 (Blazor output) -> /src/bin/Release/net8.0/wwwroot
4.559   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
4.569   Optimizing assemblies for size. This process might take a while.
17.18   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
17.28   AOT'ing 32 assemblies
18.27 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.0/Sdk/WasmApp.Native.targets(686,5): error : Precompiling failed for /src/obj/Release/net8.0/wasm/for-publish/aot-in/Microsoft.AspNetCore.Components.dll: An error occurred trying to start process '/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/Sdk/../tools/mono-aot-cross' with working directory '/src/obj/Release/net8.0/wasm/for-publish/aot-in'. No such file or directory [/src/BlazorApp1.csproj]
... 31 more times

/cc @lewing @baronfel

directhex commented 9 months ago

Is this distinct from the known issue where there's a new dependency on the cross compilers which isn't in the docker images? Libatomic I think?

directhex commented 9 months ago

Check with ldd in the docker image to see if any linkage is missing on the aot cross binary

lbussell commented 9 months ago

@directhex: Is this distinct from the known issue where there's a new dependency on the cross compilers which isn't in the docker images? Libatomic I think?

Yes, this is a different issue. I am testing the fix for the libatomic issue and Alpine is the only distro having this problem.

@directhex: Check with ldd in the docker image to see if any linkage is missing on the aot cross binary

Workload install seems to have only installed the linux-x64 version of the package, not the linux-musl-x64 version -

/ # find /usr/share/dotnet -iname "*mono-aot-cross*"
/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross

I am not surprised that ldd shows some issues:

/ # ldd /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross
        /lib64/ld-linux-x86-64.so.2 (0x7f90d0165000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f90d0165000)
        libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f90d0165000)
        libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f90d0165000)
        libc++.so.1 => /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/libc++.so.1 (0x7f90cf25c000)
        libc++abi.so.1 => /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/libc++abi.so.1 (0x7f90cf213000)      
        libz.so.1 => /lib/libz.so.1 (0x7f90cf1f9000)
        librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7f90d0165000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f90cf1db000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f90d0165000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross)
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/libc++.so.1: strtoll_l: symbol not found      
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/libc++.so.1: strtoull_l: symbol not found     
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/libc++abi.so.1: __cxa_thread_atexit_impl: symbol not found
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: backtrace_symbols: symbol not found
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: __isnanf: symbol not found    
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: __isnan: symbol not found     
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: __isinf: symbol not found     
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: __isinff: symbol not found    
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: mallinfo: symbol not found    
Error relocating /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross: backtrace: symbol not found

I'm also not sure why the error message from my previous comment above is "No such file or directory". Clearly the file /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.0/tools/mono-aot-cross exists. I thought it might be talking about /src/obj/Release/net8.0/wasm/for-publish/aot-in instead, but I checked and the folder exists and it contains the DLL's it's trying to compile. So I'm not sure.

directhex commented 9 months ago

Unhelpfully, "No such file or directory" is a normal error on Linux when attempting to execute an ELF but the dynamic linker specified (first line in ldd) is not present. It's commonly seen when trying to run an app from architecture X on a system with architecture Y.

The Musl-native wasm-tools/wasi-experimental workloads are in main, but not in 8.0. I don't know if adding platform support is something we want to do in a point release (I'm personally all for it since I feel disappointed this missed the release deadline - but I'm sure it needs signing off from someone pretty senior).

The runtime/workload commit is https://github.com/dotnet/runtime/commit/7f818485a669eef2271034cb1aee3b01bdeeaef6 but it assumes the availability of packages from wasi-sdk.git and emsdk.git. wasi-sdk Musl packages are published on our internal Net8 feed (the enablement commit was https://github.com/dotnet/wasi-sdk/commit/89411a5bba9dd57d86dc7b065b4058c3c8e4f5f5 ), emsdk wasn't fixed until the end of August (various commits in the middle of https://github.com/dotnet/emsdk/commits/main?after=9902d2ec1695a2ea184003b35beb96232a532434+69&branch=main&path%5B%5D=eng&qualified_name=refs%2Fheads%2Fmain )

Again, happy to discuss lighting this up in 8.0 servicing (as long as someone who isn't me gets approval) but it's known to be missing in 8.0 GA.

lbussell commented 9 months ago

So, I tried this on .NET 9 using Alpine as well. The AOT compilation finishes but it looks like the emcc bundled with the workload is also only for linux-x64:

2.701   BlazorApp1 -> /src/bin/Release/net9.0/BlazorApp1.dll
2.703   BlazorApp1 (Blazor output) -> /src/bin/Release/net9.0/wwwroot
2.963   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
2.968   Optimizing assemblies for size. This process might take a while.
9.927   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
9.979   AOT'ing 32 assemblies
10.51   [1/32] Microsoft.Extensions.Configuration.Abstractions.dll -> Microsoft.Extensions.Configuration.Abstractions.dll.bc
<snip/>
41.35   [32/32] aot-instances.dll -> aot-instances.dll.bc
41.37   IL stripping assemblies
41.74   Compiling native assets with emcc with -Oz. This may take a while ...
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : Failed to compile /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/corebindings.c -> /src/obj/Release/net9.0/wasm/for-publish/corebindings.o [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error :  "/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang" -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Cache.linux-x64/9.0.0-alpha.1.23572.3/tools/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -msimd128 -Oz -g3 -v -fwasm-exceptions -DDISABLE_PERFTRACING_LISTEN_PORTS=1 -DENABLE_AOT=1 -DDRIVER_GEN=1 -DLINK_ICALLS=1 -DGEN_PINVOKE=1 -emit-llvm -I/src/obj/Release/net9.0/wasm/for-publish -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/mono-2.0 -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/wasm -c /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/corebindings.c -o /tmp/tmpABHIBg.tmp [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang: line 25: /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang-16: not found [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : emcc: error: '/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Cache.linux-x64/9.0.0-alpha.1.23572.3/tools/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -msimd128 -Oz -g3 -v -fwasm-exceptions -DDISABLE_PERFTRACING_LISTEN_PORTS=1 -DENABLE_AOT=1 -DDRIVER_GEN=1 -DLINK_ICALLS=1 -DGEN_PINVOKE=1 -emit-llvm -I/src/obj/Release/net9.0/wasm/for-publish -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/mono-2.0 -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/wasm -c /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/corebindings.c -o /tmp/tmpABHIBg.tmp' failed (returned 127) [took 0.25s] [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : Failed to compile /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/driver.c -> /src/obj/Release/net9.0/wasm/for-publish/driver.o [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error :  "/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang" -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Cache.linux-x64/9.0.0-alpha.1.23572.3/tools/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -msimd128 -Oz -g3 -v -fwasm-exceptions -DDISABLE_PERFTRACING_LISTEN_PORTS=1 -DENABLE_AOT=1 -DDRIVER_GEN=1 -DLINK_ICALLS=1 -DGEN_PINVOKE=1 -emit-llvm -I/src/obj/Release/net9.0/wasm/for-publish -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/mono-2.0 -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/wasm -c /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/driver.c -o /tmp/tmpNGLLBg.tmp [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang: line 25: /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang-16: not found [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : emcc: error: '/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Cache.linux-x64/9.0.0-alpha.1.23572.3/tools/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -msimd128 -Oz -g3 -v -fwasm-exceptions -DDISABLE_PERFTRACING_LISTEN_PORTS=1 -DENABLE_AOT=1 -DDRIVER_GEN=1 -DLINK_ICALLS=1 -DGEN_PINVOKE=1 -emit-llvm -I/src/obj/Release/net9.0/wasm/for-publish -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/mono-2.0 -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/wasm -c /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/driver.c -o /tmp/tmpNGLLBg.tmp' failed (returned 127) [took 0.25s] [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : Failed to compile /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/pinvoke.c -> /src/obj/Release/net9.0/wasm/for-publish/pinvoke.o [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error :  "/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang" -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Cache.linux-x64/9.0.0-alpha.1.23572.3/tools/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -msimd128 -Oz -g3 -v -fwasm-exceptions -DDISABLE_PERFTRACING_LISTEN_PORTS=1 -DENABLE_AOT=1 -DDRIVER_GEN=1 -DLINK_ICALLS=1 -DGEN_PINVOKE=1 -emit-llvm -I/src/obj/Release/net9.0/wasm/for-publish -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/mono-2.0 -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/wasm -c /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/pinvoke.c -o /tmp/tmpELcDkf.tmp [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang: line 25: /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang-16: not found [/src/BlazorApp1.csproj]
42.00 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/9.0.0-alpha.1.23577.7/Sdk/WasmApp.Native.targets(366,5): error : emcc: error: '/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/9.0.0-alpha.1.23572.3/tools/bin/clang -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Cache.linux-x64/9.0.0-alpha.1.23572.3/tools/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -msimd128 -Oz -g3 -v -fwasm-exceptions -DDISABLE_PERFTRACING_LISTEN_PORTS=1 -DENABLE_AOT=1 -DDRIVER_GEN=1 -DLINK_ICALLS=1 -DGEN_PINVOKE=1 -emit-llvm -I/src/obj/Release/net9.0/wasm/for-publish -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/mono-2.0 -I/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/include/wasm -c /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/9.0.0-alpha.1.23577.7/runtimes/browser-wasm/native/src/pinvoke.c -o /tmp/tmpELcDkf.tmp' failed (returned 127) [took 0.25s] [/src/BlazorApp1.csproj]
42.01
directhex commented 9 months ago

Ah. Looks like a required change in emsdk.git was missed (the corresponding change in runtime.git was done). I just filed https://github.com/dotnet/emsdk/pull/633

directhex commented 9 months ago

@lbussell we're currently waiting on https://github.com/dotnet/runtime/pull/96483 to merge, then the next runtime build of the main branch from that point should be fixed

directhex commented 9 months ago

Hi @lbussell, can you validate whether .NET 9 is behaving as expected here now? The required changes hit runtime 18 hours ago, I'm not sure if you need to wait for some nightly artifacts or somesuch need to get built before we can validate

lbussell commented 9 months ago

Haven't forgotten about this - we have some other dependency flow issues to fix in .NET Docker before I can validate this fully.

lbussell commented 9 months ago

@directhex this scenario appears to work now with the latest .NET 9.0 SDK (mcr.microsoft.com/dotnet/nightly/sdk:9.0-preview-alpine). Thanks for your help.

lbussell commented 6 months ago

Closing as completed since this is fixed from what I can tell.

boukenka commented 3 months ago

@directhex @lbussell What about a fix for .NET 8.0.x ? I have tried this morning and I am getting the same type of error. This is for a Blazor PWA.

The docker is :

FROM mcr.microsoft.com/dotnet/aspnet:8.0.7-alpine3.20 AS base
WORKDIR ...

FROM mcr.microsoft.com/dotnet/sdk:8.0.303-alpine3.20 AS build
WORKDIR /src
RUN apk update \
    && apk add --upgrade --no-cache python3 \
    && dotnet workload install wasm-tools --skip-manifest-update
...
WORKDIR "/src/Server"
RUN dotnet build ... -c Release -o ...

The error is :

/usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.7/Sdk/WasmApp.Native.targets(686,5): error : 
Precompiling failed for /src/Client/obj/Release/net8.0/wasm/for-publish/aot-in/Blazored.SessionStorage.dll: 
An error occurred trying to start process 
'/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.linux-x64.Cross.browser-wasm/8.0.7/Sdk/../
tools/mono-aot-cross' with working directory '/src/Client/obj/Release/net8.0/wasm/for-publish/aot-in'. 
No such file or directory [/src/Client/WebSubiAnalysis.Client.csproj]

The project file definition is :

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <WasmEnableSIMD>true</WasmEnableSIMD>
    <WasmEnableExceptionHandling>true</WasmEnableExceptionHandling>
    <RunAOTCompilation>true</RunAOTCompilation>
        <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
    <AnalysisMode>recommended</AnalysisMode>
    <DisableParallelEmccCompile>true</DisableParallelEmccCompile>
  </PropertyGroup>
    ...
</Project>
lbussell commented 3 months ago

Yeah, unfortunately this is still a known issue for .NET 8 on Alpine. @lewing, @directhex, @baronfel should we consider backporting the fix to 8.0?

@boukenka, in the meantime, if you are only using BlazorWASM as a frontend, since the output is a static web app, could you use one of the other distros we provide containers for? Such as noble (Ubuntu) instead of alpine3.20. The distro you built with shouldn't make a big difference if you only depend on the static webapp output. Obviously if your project is more complicated and you're depending on Alpine for hosting your app, then it might not be that simple.

boukenka commented 3 months ago

@lbussell Thank you for your reply. I will try to follow your recommendations. I would just like to add that .NET 8 is an LTS version. So it would make sense to backport the fix.