bazelbuild/bazel

C++ param files are not compatible with MSVC

Open

#16.704 aperta il 8 nov 2022

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Java (4465 fork)batch import
P3area-Windowshelp wantedteam-Rules-CPPtype: bug

Metriche repository

Star
 (25.384 star)
Metriche merge PR
 (Merge medio 22g 20h) (77 PR mergiate in 30 g)

Descrizione

Description of the bug:

  1. When --features=compiler_param_file feature is enabled compilation rules produce param file for the compiler to read. When "dangerous" symbols (like spoaces, quotes and such) are present individual arguments in param file are escaped. Unfortunately escaping schema is hardcoded as GCC_QUOTED which is not compatible with how MSVC expects the file to be escaped.

  2. With linking the situation is even worse. --features=linker_param_file is always enabled and cannot be disabled. And the same problem with escaping is present.

As the result of this issue any source files with the spaces or special symbols in the names cannot be compiled with Bazel on Windows. The same applies to defines, copts and other attributes.

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

I have created a minimal standalone repro here. Obviously to get a repro you need to run it on Windows.

If you build with bazel build bin then the linking fails, because the source file name (and therefore object file name) contains a space in it.

If you build with bazel build bin --features=compiler_param_file then it fails on compilation because the param file generated is not escaped properly for MSVC.

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

6.0.0rc1

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

No response

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

No response

Have you found anything relevant by searching the web?

No response

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

No response

Guida contributor