Skip to content

BAZEL_CURRENT_REPOSITORY double escaped when using param files #20371

@lwelch

Description

@lwelch

Description of the bug:

When using --features=compiler_param_file to compile a C file, the string added to the param file is "double escaped" so that the result is

/DBAZEL_CURRENT_REPOSITORY=\"\" instead of /DBAZEL_CURRENT_REPOSITORY=""

This does not appear to cause an issue in the clang/gcc compilation, but causes my toolchain with a non-standard compiler (based on clang) to crash. My compiler can't handle /"/" as a define.

Without --features=compiler_param_file set (and using the -s flag) , I can see that the command line is correctly escaped as /DBAZEL_CURRENT_REPOSITORY="" on the command line

The param file should directly mimic the non-param file build, where the the string is properly escaped.

Which category does this issue belong to?

C++/Objective-C Rules, External Dependency

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

Clone the Examples from https://github.com/bazelbuild/examples

change directory to cpp-tutorial/stage3

Run bazel build //main:hello-world --features=compiler_param_file -s --compiler=clang-cl

Observe the .params file at cpp-tutorial\stage3\bazel-out\x64_windows-fastbuild\bin\main_objs\hello-greet\hello-greet.obj.params

bazel clean, then run bazel build //main:hello-world -s --compiler=clang-cl to compare BAZEL_CURRENT_REPOSITORY between the two runs

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 6.4.0

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

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

It appears the problem was introduced as part of #16216

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

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions