Resolve Windows long path issue during C++ compilation
See original GitHub issuehttps://stackoverflow.com/questions/47412512/bazel-build-nccl-archive-nccl-could-not-resolve-label-ws2-32-lib
When I tried to help a user build tensorflow_serving on Windows, I encountered an error Cannot open compiler generated file: '': Invalid argument
:
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe /c external/org_tensorflow/tensorflow/core/profiler/internal/advisor/internal_checker_runner_dummy.cc /Fobazel-out/msvc_x64-py3-opt/bin/external/org_tensorflow/tensorflow/core/profiler/internal/advisor/_objs/internal_checker_runner_dummy/external/org_tensorflow/tensorflow/core/profiler/internal/advisor/internal_checker_runner_dummy.o /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /bigobj /Zm500 /J /Gy /GF /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /Iexternal/org_tensorflow /Ibazel-out/msvc_x64-py3-opt/genfiles/external/org_tensorflow /Iexternal/protobuf_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/protobuf_archive /Iexternal/bazel_tools /Ibazel-out/msvc_x64-py3-opt/genfiles/external/bazel_tools /Iexternal/com_google_absl /Ibazel-out/msvc_x64-py3-opt/genfiles/external/com_google_absl /Iexternal/nsync /Ibazel-out/msvc_x64-py3-opt/genfiles/external/nsync /Iexternal/eigen_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/eigen_archive /Iexternal/local_config_sycl /Ibazel-out/msvc_x64-py3-opt/genfiles/external/local_config_sycl /Iexternal/gif_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/gif_archive /Iexternal/jpeg /Ibazel-out/msvc_x64-py3-opt/genfiles/external/jpeg /Iexternal/com_googlesource_code_re2 /Ibazel-out/msvc_x64-py3-opt/genfiles/external/com_googlesource_code_re2 /Iexternal/farmhash_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/farmhash_archive /Iexternal/fft2d /Ibazel-out/msvc_x64-py3-opt/genfiles/external/fft2d /Iexternal/highwayhash /Ibazel-out/msvc_x64-py3-opt/genfiles/external/highwayhash /Iexternal/png_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/png_archive /Iexternal/zlib_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/zlib_archive /Iexternal/snappy /Ibazel-out/msvc_x64-py3-opt/genfiles/external/snappy /Iexternal/protobuf_archive/src /Ibazel-out/msvc_x64-py3-opt/genfiles/external/protobuf_archive/src /Iexternal/bazel_tools/tools/cpp/gcc3 /Iexternal/nsync/public /Ibazel-out/msvc_x64-py3-opt/genfiles/external/nsync/public /Iexternal/eigen_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/eigen_archive /Iexternal/gif_archive/lib /Ibazel-out/msvc_x64-py3-opt/genfiles/external/gif_archive/lib /Iexternal/gif_archive/windows /Ibazel-out/msvc_x64-py3-opt/genfiles/external/gif_archive/windows /Iexternal/farmhash_archive/src /Ibazel-out/msvc_x64-py3-opt/genfiles/external/farmhash_archive/src /Iexternal/png_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/png_archive /Iexternal/zlib_archive /Ibazel-out/msvc_x64-py3-opt/genfiles/external/zlib_archive /D__CLANG_SUPPORT_DYN_ANNOTATION__ /DEIGEN_MPL2_ONLY /DTENSORFLOW_USE_ABSL /DTF_USE_SNAPPY /showIncludes /MD /O2.
C:\tmp\_bazel_pcloudy\dpitg86y\execroot\tf_serving\external\org_tensorflow\tensorflow\core\profiler\internal\advisor\internal_checker_runner_dummy.cc : fatal error C1083: Cannot open compiler generated file: '': Invalid argument
It turns out that the object file the compiler trying to write C:/tmp/_bazel_pcloudy/dpitg86y/execroot/bazel-out/msvc_x64-py3-opt/bin/external/org_tensorflow/tensorflow/core/profiler/internal/advisor/_objs/internal_checker_runner_dummy/external/org_tensorflow/tensorflow/core/profiler/internal/advisor/internal_checker_runner_dummy.o
is longer than 270 characters.
This happens when I already set the output directory to a short path C:/tmp
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:30 (29 by maintainers)
Top Results From Across the Web
Long paths causing errors in latest MSBuild (with long path ...
As title says. Numerous warnings and finally an error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.
Read more >Long paths not working in windows 2019 - Microsoft Q&A
Long paths not working in windows 2019 · Press Win + R keys on your keyboard and type regedit then press Enter. ·...
Read more >Fix: "Error 0x80010135: Path Too Long" Error on Windows
3. Enable Long Path Support via Group Policy Editor · Press Win + R to open Run. · Type gpedit. · Click Yes...
Read more >Best way to resolve file path too long exception - Stack Overflow
Here's a quote from the link: Maximum Path Length Limitation In the Windows API (with some exceptions discussed in the following paragraphs), ...
Read more >Enable long path compilation - Beginner Questions - ITK
If you are confident that you won't have problems due to long paths then disable the check and see if you succeed. If...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey, everyone, this issue has been resolved by https://github.com/bazelbuild/bazel/commit/bb9ae6a174b8cd255a62249f01919426f1d817f8. You can now use
--experimental_shortened_obj_file_path
option to have a short object file path with Bazel@HEAD. This change will be released with 0.13.0 and the short object file will be default in the future. For more details of this change, please read the commit message.@rongjiecomputer Glad to hear it worked! I’m working on fixing the TF’s Windows build and setting up a presubmit for it. Should be done next week.
Yes, this change only affected C++, because it’s only
cl.exe
(and other MSVC build tools) that doesn’t support long path. I tested withjava.exe
andjavac.exe
, they both accept long path. So we are saved here.