Skip to content

--host_cxxopt and --cxxopt are passed to the compiler also for .c files on Windows #15073

@foxandi

Description

@foxandi

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?

#14005
#14131

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)

public static final FileType CPP_SOURCE =
FileType.of(".cc", ".cpp", ".cxx", ".c++", ".C", ".cu", ".cl");

Which results in passing cxxopt for .c files

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());
}

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)help wantedSomeone outside the Bazel team could own thisteam-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