dotnet / runtime

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

[wasm] Emscripten cache being unwritable due to permissions can cause AOT build to get stuck #75345

Closed Hazardu closed 1 year ago

Hazardu commented 2 years ago

Description

I am trying to build a Blazor WebAssembly app referencing a C++ library built with emcc, but the build problem halts after finishing the pre-build event and a warning about a nullable field, and prints out this warning:

cache : warning : Accessing the Emscripten cache at "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache" is taking a long time, another process should be writing to it. If there are none and you suspect this process has deadlocked, try deleting the lock file "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache\cache.lock" and try again. If this occurs deterministically, consider filing a bug.

The cache file is not cache.lock is not created

Reproduction Steps

https://github.com/Devsh-Graphics-Programming/GPU-With-C-Sharp-Angular-WASM/tree/master/BlazorEmscripten Clone the repo with a test blazor app, Downloaded SWIG (C#/C++ pinvoke generator) and add it to PATH (such that a prebuild event successfully executed) Tried to build, got asked for a runtime Download latest dotnet runtimes and sdks as of 9.09.2022 Closed and relaunched the solution in VS2022 Try to build the BlazorEmscripten.Client and fail

Expected behavior

Blazor app builds and runs the browser.

Actual behavior

The build process stalls after printing

2>------ Build started: Project: BlazorEmscripten.Client, Configuration: Debug Any CPU ------
2>SWIG/fixswig.py:10: SyntaxWarning: "is not" with a literal. Did you mean "!="?
2>  if (lines[13].find("SWIGExceptionHelper") is not -1 ):
2>D:\Hazard\Repos\GPU-With-C-Sharp-Angular-WASM\BlazorEmscripten\Client\Pages\Pathtracing.razor(22,24,22,32): warning CS8618: Non-nullable property 'renderer' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
2>cache : warning : Accessing the Emscripten cache at "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache" is taking a long time, another process should be writing to it. If there are none and you suspect this process has deadlocked, try deleting the lock file "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache\cache.lock" and try again. If this occurs deterministically, consider filing a bug.

Regression?

I have not tried .NET other than 6 because that was when NativeFileReference was added

Known Workarounds

No response

Configuration

dotnet runtime 6.0.8 win x64 windowsdesktop runtime 6.0.8 win x64 Tested on two computers, one running Windows 10 and Windows 11

Did not get to launching the browser

Other information

No response

ghost commented 2 years ago

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

Issue Details
### Description I am trying to build a Blazor WebAssembly app referencing a C++ library built with `emcc`, but the build problem halts after finishing the pre-build event and a warning about a nullable field, and prints out this warning: ``` cache : warning : Accessing the Emscripten cache at "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache" is taking a long time, another process should be writing to it. If there are none and you suspect this process has deadlocked, try deleting the lock file "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache\cache.lock" and try again. If this occurs deterministically, consider filing a bug. ``` The cache file is not cache.lock is not created ### Reproduction Steps https://github.com/Devsh-Graphics-Programming/GPU-With-C-Sharp-Angular-WASM/tree/master/BlazorEmscripten Clone the repo with a test blazor app, Downloaded SWIG (C#/C++ pinvoke generator) and add it to PATH (such that a prebuild event successfully executed) Tried to build, got asked for a runtime Download latest dotnet runtimes and sdks as of 9.09.2022 Closed and relaunched the solution in VS2022 Try to build the BlazorEmscripten.Client and fail ### Expected behavior Blazor app builds and runs the browser. ### Actual behavior The build process stalls after printing ``` 2>------ Build started: Project: BlazorEmscripten.Client, Configuration: Debug Any CPU ------ 2>SWIG/fixswig.py:10: SyntaxWarning: "is not" with a literal. Did you mean "!="? 2> if (lines[13].find("SWIGExceptionHelper") is not -1 ): 2>D:\Hazard\Repos\GPU-With-C-Sharp-Angular-WASM\BlazorEmscripten\Client\Pages\Pathtracing.razor(22,24,22,32): warning CS8618: Non-nullable property 'renderer' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. 2>cache : warning : Accessing the Emscripten cache at "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache" is taking a long time, another process should be writing to it. If there are none and you suspect this process has deadlocked, try deleting the lock file "C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten\cache\cache.lock" and try again. If this occurs deterministically, consider filing a bug. ``` ### Regression? I have not tried .NET other than 6 because that was when NativeFileReference was added ### Known Workarounds _No response_ ### Configuration dotnet runtime 6.0.8 win x64 windowsdesktop runtime 6.0.8 win x64 Tested on two computers, one running Windows 10 and Windows 11 Did not get to launching the browser ### Other information _No response_
Author: Hazardu
Assignees: -
Labels: `arch-wasm`, `untriaged`, `area-Build-mono`
Milestone: -
radical commented 2 years ago

cc @radekdoulik

radical commented 2 years ago
  1. Does this happen only when you have the NativeFileReference?
  2. Are you able to reproduce this from the command line? if so, then can you run it with /v:diag? That should give us some idea about where it is actually stuck.
Hazardu commented 2 years ago
  1. Yes, if i remove the native file reference it compiles just fine
  2. After running it with dotnet run --verbosity diag the build process stalled after
    22:28:10.517   1:7>Done building target "_GenerateICallTable" in project "BlazorEmscripten.Client.csproj".: (TargetId:1
                   74)
    22:28:10.517   1:7>Target "_WasmCompileNativeFiles: (TargetId:175)" in file "C:\Program Files\dotnet\packs\Microsoft.NE
                   T.Runtime.WebAssembly.Sdk\6.0.8\Sdk\WasmApp.Native.targets" from project "D:\Hazard\Repos\GPU-With-C
                   -Sharp-Angular-WASM\BlazorEmscripten\Client\BlazorEmscripten.Client.csproj" (target "_WasmBuildNativ
                   eCore" depends on it):
                   Set Property: _EmBuilder=embuilder.bat
                   Task "WriteLinesToFile" (TaskId:119)
                     Task Parameter:Overwrite=True (TaskId:119)
                     Task Parameter:WriteOnlyWhenDifferent=True (TaskId:119)
                     Task Parameter:
                         Lines=
                             -O1
                             -s DISABLE_EXCEPTION_CATCHING=0
                             -g
                             -v
                             -DLINK_ICALLS=1
                             -DCORE_BINDINGS
                             -DGEN_PINVOKE=1
                             -emit-llvm
                             "-ID:\Hazard\Repos\GPU-With-C-Sharp-Angular-WASM\BlazorEmscripten\Client\obj\Debug\net6.0\
                     wasm\for-build"
                             "-IC:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\6.0.8\run
                     times\browser-wasm\native\include\mono-2.0"
                             "-IC:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.browser-wasm\6.0.8\run
                     times\browser-wasm\native\include\wasm"
                             -g (TaskId:119)
                     Task Parameter:File=D:\Hazard\Repos\GPU-With-C-Sharp-Angular-WASM\BlazorEmscripten\Client\obj\Debu
                     g\net6.0\wasm\for-build\emcc-compile.rsp (TaskId:119)
                     Skipping write to file "D:\Hazard\Repos\GPU-With-C-Sharp-Angular-WASM\BlazorEmscripten\Client\obj\
                     Debug\net6.0\wasm\for-build\emcc-compile.rsp" because content would not change. (TaskId:119)
                   Done executing task "WriteLinesToFile". (TaskId:119)
                   Added Item(s): FileWrites=D:\Hazard\Repos\GPU-With-C-Sharp-Angular-WASM\BlazorEmscripten\Client\obj\
                   Debug\net6.0\wasm\for-build\emcc-compile.rsp
                   Task "Exec" (TaskId:120)
                     Task Parameter:Command=embuilder.bat build MINIMAL (TaskId:120)
                     Task Parameter:StandardErrorImportance=Low (TaskId:120)
                     Task Parameter:
                         EnvironmentVariables=
                             EMSDK_PYTHON=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Python.
                     win-x64\6.0.4\Sdk\..\tools\\python.exe
                             PYTHONUTF8=1
                             DOTNET_EMSCRIPTEN_LLVM_ROOT=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten
                     .2.0.23.Sdk.win-x64\6.0.4\tools\bin
                             DOTNET_EMSCRIPTEN_BINARYEN_ROOT=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscri
                     pten.2.0.23.Sdk.win-x64\6.0.4\tools\
                             DOTNET_EMSCRIPTEN_NODE_JS=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2
                     .0.23.Node.win-x64\6.0.4\tools\bin\node.exe
                             PATH=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Python.win-x64\
                     6.0.4\Sdk\..\tools;C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Node.win-
                     x64\6.0.4\Sdk\..\tools\bin;C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.S
                     dk.win-x64\6.0.4\Sdk\..\tools\bin;C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2
                     .0.23.Sdk.win-x64\6.0.4\Sdk\..\tools\emscripten;D:\Programy\CUDA\bin;D:\Programy\CUDA\libnvvp;C:\P
                     rogram Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\jav
                     apath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShel
                     l\v1.0\;C:\Windows\System32\OpenSSH\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WI
                     NDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Pr
                     ogram Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (
                     x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management En
                     gine Components\DAL;D:\Programy\Cmake\bin;D:\Programy\doxygen\bin;D:\Programy\Git\cmd;C:\WINDOWS\s
                     ystem32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS
                     \System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;D:\OpenGL\GLEW\bin\Releas
                     e\x64;D:\OpenGL\GLFW\lib-vc2022;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program F
                     iles\NVIDIA Corporation\Nsight Compute 2022.2.1\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\C
                     ommon;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Programy\Ninja;C:\Program Files\Mono\b
                     in;D:\Hazard\Repos\swigwin-4.0.2;D:\OpenGL\GLEW;C:\Program Files\Microsoft SQL Server\Client SDK\O
                     DBC\170\Tools\Binn\;D:\Hazard\Repos\emsdk;D:\Hazard\Repos\emsdk\node\14.18.2_64bit\bin;D:\Hazard\R
                     epos\emsdk\upstream\emscripten;C:\Users\Hazard\AppData\Local\Programs\Python\Python38-32\Scripts\;
                     C:\Users\Hazard\AppData\Local\Programs\Python\Python38-32\;D:\Programy\PHP;C:\Program Files\MySQL\
                     MySQL Shell 8.0\bin\;C:\Users\Hazard\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Hazard\
                     AppData\Local\GitHubDesktop\bin;C:\Users\Hazard\AppData\Local\Microsoft\WindowsApps;C:\Program Fil
                     es\Java\jdk-17.0.1\bin;C:\Users\Hazard\.dotnet\tools
                             PYTHONUTF8=1 (TaskId:120)
                     Task Parameter:StandardOutputImportance=Low (TaskId:120)
                     Environment Variables passed to tool: (TaskId:120)
                       EMSDK_PYTHON=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Python.win-x6
                     4\6.0.4\Sdk\..\tools\\python.exe (TaskId:120)
                       PYTHONUTF8=1 (TaskId:120)
                       DOTNET_EMSCRIPTEN_LLVM_ROOT=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.2
                     3.Sdk.win-x64\6.0.4\tools\bin (TaskId:120)
                       DOTNET_EMSCRIPTEN_BINARYEN_ROOT=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2
                     .0.23.Sdk.win-x64\6.0.4\tools\ (TaskId:120)
                       DOTNET_EMSCRIPTEN_NODE_JS=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.
                     Node.win-x64\6.0.4\tools\bin\node.exe (TaskId:120)
                       PATH=C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Python.win-x64\6.0.4\
                     Sdk\..\tools;C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Node.win-x64\6.
                     0.4\Sdk\..\tools\bin;C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win
                     -x64\6.0.4\Sdk\..\tools\bin;C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.
                     Sdk.win-x64\6.0.4\Sdk\..\tools\emscripten;D:\Programy\CUDA\bin;D:\Programy\CUDA\libnvvp;C:\Program
                      Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
                     C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0
                     \;C:\Windows\System32\OpenSSH\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\
                     System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program
                     Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\I
                     ntel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine C
                     omponents\DAL;D:\Programy\Cmake\bin;D:\Programy\doxygen\bin;D:\Programy\Git\cmd;C:\WINDOWS\system3
                     2;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\Syste
                     m32\OpenSSH\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;D:\OpenGL\GLEW\bin\Release\x64;
                     D:\OpenGL\GLFW\lib-vc2022;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\N
                     VIDIA Corporation\Nsight Compute 2022.2.1\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
                     C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Programy\Ninja;C:\Program Files\Mono\bin;D:\
                     Hazard\Repos\swigwin-4.0.2;D:\OpenGL\GLEW;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\17
                     0\Tools\Binn\;D:\Hazard\Repos\emsdk;D:\Hazard\Repos\emsdk\node\14.18.2_64bit\bin;D:\Hazard\Repos\e
                     msdk\upstream\emscripten;C:\Users\Hazard\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Use
                     rs\Hazard\AppData\Local\Programs\Python\Python38-32\;D:\Programy\PHP;C:\Program Files\MySQL\MySQL
                     Shell 8.0\bin\;C:\Users\Hazard\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Hazard\AppDat
                     a\Local\GitHubDesktop\bin;C:\Users\Hazard\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Jav
                     a\jdk-17.0.1\bin;C:\Users\Hazard\.dotnet\tools (TaskId:120)
                       PYTHONUTF8=1 (TaskId:120)
                     embuilder.bat build MINIMAL (TaskId:120)
Hazardu commented 2 years ago

Update:

I had a hunch it had something to do with me having 2 different emsdks on my computer. After removing the one i cloned manually, i was left only with the dotnet emsdk.

Turns out, after adding that dir to PATH even running emcc hangs, when all it should do is print emcc: error: no input files and terminate.

The issue has something to with emcc being in C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.win-x64\6.0.4\tools\emscripten which requires admin rights to modify files. Running VS2022 or powershell in admin mode allowed me to compile the program

63923

devshgraphicsprogramming commented 2 years ago

so the solution is for Blazor/dotnet to stop putting its cache in Program Files I guess, or respect the --cache emcc option or environment variable controlling the cache location.

radical commented 2 years ago

cc @radekdoulik and cc @lambdageek for the Emscripten.Cache pack

curia-damiano commented 1 year ago

+1

radical commented 1 year ago

@radekdoulik this should be fixed now with your cache changes, correct?

curia-damiano commented 1 year ago

I still face this issue, with Visual Studio 17.6 Preview 4 and .NET 8 Preview 3

radekdoulik commented 1 year ago

@radekdoulik this should be fixed now with your cache changes, correct?

yes, this should be fixed by https://github.com/dotnet/runtime/pull/84356.

so .NET8 Preview4 will have it fixed

radekdoulik commented 1 year ago

This is already fixed.