C++ param files are not compatible with MSVC
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### 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](https://github.com/Bazel-snippets/compiler_param_file_escaping).
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_
Contributor guide
Research direction
Run the linked standalone repro on Windows with the default build and with --features=compiler_param_file, then trace the handling of compiler_param_file and linker_param_file arguments. Done means compilation and linking succeed when source paths, defines, or copts contain spaces and other special characters under MSVC.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100