-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Description of the problem / feature request:
Since Bazel 5.0.0 --host_cxxopt
and --cxxopt
are passed to compilers compiling .c files on Windows.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Use the autoconfigure toolchain to build (with -s) a .c file in Windows. Set --host_cxxopt
and --cxxopt
in the .bazelrc and see in the compiler call the passed opts from the .bazelrc. Doing the same on Linux show, that the opts here are not passed.
What operating system are you running Bazel on?
Windows 10 Enterprise (Version 10.0.19042 Build 19042)
What's the output of bazel info release
?
release 5.0.0
Have you found anything relevant by searching the web?
Any other information, logs, or outputs that you want to share?
This commit 861584c introduced case insensity for files types on Windows
private static final OsPathPolicy OS = OsPathPolicy.getFilePathOs(); |
The change also leads to .c files under Windows match to C_SOURCE (.c extension) and CPP_SOURCE (.C extension)
bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
Lines 33 to 34 in 88499f6
public static final FileType CPP_SOURCE = | |
FileType.of(".cc", ".cpp", ".cxx", ".c++", ".C", ".cu", ".cl"); |
Which results in passing cxxopt for .c files
bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java
Lines 1605 to 1610 in 88499f6
if (CppFileTypes.CPP_SOURCE.matches(sourceFilename) | |
|| CppFileTypes.CPP_HEADER.matches(sourceFilename) | |
|| CppFileTypes.CPP_MODULE_MAP.matches(sourceFilename) | |
|| CppFileTypes.CLIF_INPUT_PROTO.matches(sourceFilename)) { | |
flagsBuilder.addAll(config.getCxxopts()); | |
} |