Skip to content

C++ object files path is too long for some projects #15961

@coryan

Description

@coryan

Description of the bug:

Bazel generates very deeply nested names for the object file path. For external dependencies this include the name of the dependency, the path of the target, the name of the target, and the name of the object within that target. Even with --output_user_root that can exceed the cl.exe limits fairly easily.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

c:
cd \
git clone https://github.com/googleapis/google-cloud-cpp
cd google-cloud-cpp
set BAZEL_VC="C:\Program Files\Microsoft Visual Studio\2022\Community\VC"
c:\bin\bazelisk.exe info release
c:\bin\bazelisk.exe --output_user_root=c:\b build @com_google_googleapis//google/cloud/beyondcorp/clientconnectorservices/v1:clientconnectorservices_cc_grpc

The output will include:

ERROR: C:/b/3tuii5u7/external/com_google_googleapis/google/cloud/beyondcorp/clientconnectorservices/v1/BUILD.bazel:321:16: Compiling external/com_google_googleapis/google/cloud/beyondcorp/clientconnectorservices/v1/client_connector_services_service.grpc.pb.cc failed: (Exit 1): cl.exe failed: error executing command C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE ... (remaining 42 arguments skipped)
C:\b\3tuii5u7\execroot\com_github_googleapis_google_cloud_cpp\bazel-out\x64_windows-fastbuild\bin\external\com_google_googleapis\google\cloud\beyondcorp\clientconnectorservices\v1\client_connector_services_service.grpc.pb.cc : fatal error C1083: Cannot open compiler generated file: '': Invalid argument

Which operating system are you running Bazel on?

OS Name:                   Microsoft Windows Server 2019 Datacenter
OS Version:                10.0.17763 N/A Build 17763

What is the output of bazel info release?

c:\bin\bazelisk.exe info release
release 5.2.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

N/A

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

I followed the recommendations on https://bazel.build/rules/windows_tips, they do not help in this case. Apparently there used to be some options to reduce the path length, they were removed in 9f380c5

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)area-WindowsWindows-specific issues and feature requestsplatform: windowsstaleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions