bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.03k stars 4.03k forks source link

Refactor `default_compile_flags` defaults for windows cc toolchain #22765

Open pjreiniger opened 3 months ago

pjreiniger commented 3 months ago

Description of the feature request:

The default compiler flags in the windows cc toolchain automatically inserts command line arguments that cannot be disabled. The one that is causing my heartache is "/D_WIN32_WINNT=0x0601", which tells the compiler to target windows 7 features.

Which category does this issue belong to?

C++ Rules

What underlying problem are you trying to solve with this feature?

I maintain a bazel-ified fork of an open source project that relies on a feature added in windows 8.

{
#ifdef _WIN32
  FILETIME ft;
  GetSystemTimePreciseAsFileTime(&ft);
#else
....
#endif
}

It formerly used GetSystemTimeAsFileTime, which would compile, but then it was updated to get more precise timing information, and due to the non-configurable WIN32_WINNT bazel adds by default, the code no longer compiles without doing some hacks

Which operating system are you running Bazel on?

Windows 11

What is the output of bazel info release?

release 7.1.1

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 HEAD ?

git@github.com:bzlmodRio/allwpilib.git
b695fc8ded87127c84067d3c8ec5d7d9a122c52f

Have you found anything relevant by searching the web?

12737 describes a similar complaint. In the issue, a PR of #14735 is mentioned, but then I get this issue.

In the meantime, I can add a copt to undefine it with U_WIN32_WINNT, but it yields a message like this for each compilation step cl : Command line warning D9025 : overriding '/D_WIN32_WINNT=0x0601' with '/U_WIN32_WINNT'

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

No response

dpvdberg commented 1 week ago

I'm experiencing the same issue, where NOMINMAX is defined by default, but I need to compile a library where this define cannot be set.