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

Long git directory name causes error C1083 when building coreclr tests (cl.exe) #110407

Open
steveharter opened this issue Dec 4, 2024 · 7 comments
Labels
area-Infrastructure-coreclr untriaged New issue has not been triaged by the area owner

Comments

@steveharter
Copy link
Member

steveharter commented Dec 4, 2024

Having a long directory name causes issues when building the coreclr tests. I verified that long paths are enabled in both git and the registry.

Repro (Windows x64)

  • Create a long directory name such as C:\git\ThisIsSomewhatOfaLongName
  • Clone runtime repo into that
  • build -s clr+libs (this works)
  • src\tests\build.cmd /p:LibrariesConfiguration=Debug (this fails with the error below)

Error:

[219/384] Building CXX object baseservices\exceptions\UnhandledExceptionHandler\ForeignThreadRevPInvokeUnhandled\CMakeFiles\ForeignThreadRevPInvokeUnhandledNative.dir\ForeignThreadRevPInvokeUnhandledNative.cpp.obj
FAILED: baseservices/exceptions/UnhandledExceptionHandler/ForeignThreadRevPInvokeUnhandled/CMakeFiles/ForeignThreadRevPInvokeUnhandledNative.dir/ForeignThreadRevPInvokeUnhandledNative.cpp.obj
C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1443~1.346\bin\Hostx64\x64\cl.exe  /nologo /TP -DForeignThreadRevPInvokeUnhandledNative_EXPORTS -DHOST_64BIT -DHOST_AMD64 -DHOST_WINDOWS -DNDEBUG -DTARGET_64BIT -DTARGET_AMD64 -DTARGET_WINDOWS -DURTBLDENV_FRIENDLY=Retail -DWINDOWS -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -IC:\git\ThisIsSomewhatOfaLongName\src\native -IC:\git\ThisIsSomewhatOfaLongName\src\tests\Common\Platform /DWIN32 /D_WINDOWS  /GR- /O2 /Ob2 /DNDEBUG -MT /GL /Ox /EHa /nologo /W4 /WX /Oi /Oy- /Gm- /Zp8 /Gy /GS /fp:precise /FC /MP /Zm200 /Zc:strictStrings /Zc:wchar_t /Zc:inline /Zc:forScope /wd4065 /wd4100 /wd4127 /wd4131 /wd4189 /wd4200 /wd4201 /wd4206 /wd4239 /wd4245 /wd4291 /wd4310 /wd4324 /wd4366 /wd4456 /wd4457 /wd4458 /wd4459 /wd4463 /wd4505 /wd4702 /wd4706 /wd4733 /wd4815 /wd4838 /wd4918 /wd4960 /wd4961 /wd5105 /wd5205 /we4007 /we4013 /we4102 /we4551 /we4640 /we4806 /we4055 /we4146 /we4242 /we4244 /we4267 /we4302 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4611 /we4700 /we4701 /we4703 /we4789 /we4995 /we4996 /w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530 /w35038 /w44177 /Zi /ZH:SHA_256 /source-charset:utf-8 /guard:cf /guard:ehcont -wd4100 -wd4242 -wd4244 -wd4514 -wd4625 -wd4626 -wd4668 -wd4710 -wd4711 -wd4774 -wd4820 -wd5025 -wd5026 -wd5027 -wd5039 /showIncludes /Fobaseservices\exceptions\UnhandledExceptionHandler\ForeignThreadRevPInvokeUnhandled\CMakeFiles\ForeignThreadRevPInvokeUnhandledNative.dir\ForeignThreadRevPInvokeUnhandledNative.cpp.obj /Fdbaseservices\exceptions\UnhandledExceptionHandler\ForeignThreadRevPInvokeUnhandled\CMakeFiles\ForeignThreadRevPInvokeUnhandledNative.dir\ /FS -c C:\git\ThisIsSomewhatOfaLongName\src\tests\baseservices\exceptions\UnhandledExceptionHandler\ForeignThreadRevPInvokeUnhandled\ForeignThreadRevPInvokeUnhandledNative.cpp
C:\git\ThisIsSomewhatOfaLongName\src\tests\baseservices\exceptions\UnhandledExceptionHandler\ForeignThreadRevPInvokeUnhandled\ForeignThreadRevPInvokeUnhandledNative.cpp : fatal error C1083: Cannot open compiler generated file: '': Invalid argument
[240/384] Building CXX object profiler\native\CMakeFiles\Profiler.dir\rejitprofiler\rejitprofiler.cpp.obj
ninja: build stopped: subcommand failed.
BUILDTEST: Error: native test build failed.

I did not attempt to diagnose the root cause but note that the path C:\git\ThisIsSomewhatOfaLongName\src\tests\baseservices\exceptions\UnhandledExceptionHandler\ForeignThreadRevPInvokeUnhandled\ForeignThreadRevPInvokeUnhandledNative.cpp is 169 characters, short of MAX_PATH (260).

@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 Dec 4, 2024
@steveharter steveharter added area-Infrastructure-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Dec 4, 2024
@steveharter steveharter added the untriaged New issue has not been triaged by the area owner label Dec 4, 2024
Copy link
Contributor

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

@steveharter steveharter changed the title Long git directory name causes build error C1083 when building coreclr tests (cl.exe) Long git directory name causes error C1083 when building coreclr tests (cl.exe) Dec 4, 2024
@huoyaoyuan
Copy link
Member

Enabling long path support is listed under Windows requirements. Do you still encounter this error with long path enabled? It can be easily enabled with Dev Home.

@steveharter
Copy link
Member Author

I do have long paths enabled:

PS C:\git\ThisIsSomewhatOfaLongPath> git config --system core.longpaths
true

PS C:\git\ThisIsSomewhatOfaLongPath> Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled
LongPathsEnabled : 1

@steveharter
Copy link
Member Author

I believe cl.exe has issues with MAX_PATH even when long paths are enabled in Windows registry:
https://developercommunity.visualstudio.com/t/compiler-cant-find-source-file-in-path-/10221576
https://developercommunity.visualstudio.com/t/clexe-command-line-error-d8022-cannot-open-path-re/1478916

However, I didn't see where I was very close to MAX_PATH. Perhaps there was some artifacts\bin folders that have a longer path but not shown in the error message.

@mdh1418
Copy link
Member

mdh1418 commented Dec 10, 2024

I'm starting to see this too when building runtime tests locally after rebasing on main. It seems to be related to the new test added in #109806. I'm also not sure why that test needs to be compiled if I want to just build a separate particular runtime test .\src\tests\build.cmd test <path_to_specific_runtime_test_csproj>

@mdh1418
Copy link
Member

mdh1418 commented Dec 11, 2024

I ended up using subst to associate my local repo's path to a drive letter (Thanks @tommcdon for the suggestion), and was able to shorten the generated ForeignThreadRevPInvokeUnhandledNative object path to under 250 chars. (I also have long paths enabled, similar to Steve)

@tommcdon
Copy link
Member

Another thing to try is to enable long paths in windows per
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infrastructure-coreclr untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Development

No branches or pull requests

4 participants