-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--host_cxxopt and --cxxopt are passed to the compiler also for .c files on Windows #15073
Comments
Maybe this is a similar bug that should be fixed like edfe2a1? |
We also encounter this problem. Unfortunately this causes us to not be able to compile Android on windows. Which is a major block for our project. Is there a rough estimate of when this will be fixed? Or is there any way we can workaround this? Thanks. |
The worst thing here is that this issue is not even particularly complicated, even with Which is a pity. |
Currently, you can workaround this by replacing But I agree that it's very confusing why this issue is a feature request and is P4. |
It won't work for flags which are set in the actual BUILD files. The primary issue here, is that bazel offers no way to say "this file is plain C" explicitly. So, in a project with several dozens of third party dependencies a lot of patching and testing is needed to get anywhere with Bazel v5. Bazel v4 sort of works, but then it can not be used with VS2022 due to another open issue. |
I thought this is not a problem for a msbuild based toolchain because msbuild only gives a warning? For us, it's a block issue because we're doing android cross compile on Windows and pass C++ flag to C compile simply failed. Another interesting workaround is that we found somehow the C++ flags defined in toolchain won't be passed to C targets. So we end up moving the C++ flags to toolchain. But yeah it's lucky for us to be able to workaround this bug. For some complex project this may not work. |
VS2022 is broken pretty badly, we had to go back to VS2019/bazel v4 for now. We may figure something out going forward; possibly by making all sources C++ compatible (this appears to be the best option on the cost/benefit scale). Still, not nice. |
@oquenchil This issue seems to have wide user impact on Windows. Is it caused by starlarkfifying the cc rules? Do you know which exact change caused this and how hard is it to fix this? |
@meteorcloudy Looks like is caused by #14005. The |
Not sure why |
We don't actually have any |
@meteorcloudy Also see #15550 for some further info. |
Any progress on this issue? Bazel cannot compile C targets under Windows anymore since version 5. I don't think this warrants classification as a "feature request" or "P4". |
Bazel can compile things on Windows, it just requires jumping through ugly loops with But yes, this issue is bad and the lack of proper support for case sensitive abilities of NTFS is also unfortunate - that is, bazel would have worked fine on Windows with some extra configs if not for the rather stupid case forcing inside the Windows path resolver. |
From the documentation: I find if concerning that something that elementary is broken in bazel and swiped under the rug. |
This bug is still causing significant problems in a project, forcing us to use an old bazel version which causes further compatibility issues and surfaces other bugs without fixes. Will it ever be looked at? |
It's almost like Windows is not an important OS for developers any more. :-D Yet, Windows is still the most used developer OS by a huge margin. |
@oquenchil I think this shouldn't be a P4 issue, can you take a look? If anyone has a fix for this, a PR is also very welcome! |
This fixes an issue introduced by PR bazelbuild#14005 where .c and .C extensions were handled case-insensitive on Windows so the cxxopt will be passed to C source files. Closes bazelbuild#15073 .
Hi, I've created a PR. It's basically learned from edfe2a1 . I'm not very familiar to java actually, so please tell me if I did anything wrong. I've tested it on my environment and added a test. |
This fixes an issue introduced by PR bazelbuild#14005 where .c and .C extensions were handled case-insensitive on Windows so the cxxopt will be passed to C source files. Closes bazelbuild#15073 . Closes bazelbuild#18119. PiperOrigin-RevId: 526001251 Change-Id: I464e5feae397bdac443ddd159309f77071629e01
This fixes an issue introduced by PR bazelbuild#14005 where .c and .C extensions were handled case-insensitive on Windows so the cxxopt will be passed to C source files. Closes bazelbuild#15073 . Closes bazelbuild#18119. PiperOrigin-RevId: 526001251 Change-Id: I464e5feae397bdac443ddd159309f77071629e01
Created the referenced Cherrypick @kkpattern Any objections agains the attempt? |
Not at all😃. |
This fixes an issue introduced by PR #14005 where .c and .C extensions were handled case-insensitive on Windows so the cxxopt will be passed to C source files. Closes #15073 . Closes #18119. PiperOrigin-RevId: 526001251 Change-Id: I464e5feae397bdac443ddd159309f77071629e01 Co-authored-by: Kai Zhang <[email protected]>
This reverts commit 28e4a1b. Bazel broke --cxxopt on Windows in bazelbuild/bazel#15073, which means projects enabling, say, C++20 with --cxxopt=/std:c++20 are silently passing /std:c++20 to our C files. This is already a problem, but MSVC is smart enough to silently ignore the flag when building C. However, MSVC will report an error if you then pass /std:c++20 /std:c11 into the same command. It seems that check is not aware of this ignoring behavior. Ultimately, this is a Bazel bug, and one that makes the broken versions of Bazel unsuitable for use with C. This was fixed in Bazel in bazelbuild/bazel#18119 and backported to the upcoming Bazel 6.3.0 release in bazelbuild/bazel#18552 Temporarily revert the change. When Bazel 6.3.0 is released, we'll put this back and require Windows users use a functioning version of Bazel. Bug: 624 Fixed: 623 Change-Id: I68d9b2ed8751b4cf5dc7f42f8c1fbd42a97d6ca2 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61365 Auto-Submit: David Benjamin <[email protected]> Commit-Queue: David Benjamin <[email protected]> Commit-Queue: Adam Langley <[email protected]> Reviewed-by: Adam Langley <[email protected]>
Why is this closed? Observed in the latest 5.x and 6.x builds. This is C code!
|
6.3.0 should contain the fix? #18552 |
I did a simple test. When compile with MSVC with
while bazel 6.3.2 didn't:
|
I'm using Ubuntu 22.04... so I'm seeing the problem on Linux. Given that we're not using Bzlmod (because of incompatibilities), it's possible that I have a dependency of a dependency that's getting an old version of cc_tools or something. It's frustrating because it my build is broken because of two rather trivial bugs that look like they're in bazel. (Where does @local_config_cc come from, after all???) |
This reverts 1e2f169. Bazel 6.3 has since been released, which includes a fix for bazelbuild/bazel#15073. Envoy and gRPC have both since updated to this Bazel version. The policies in https://opensource.google/documentation/policies/cplusplus-support#build_systems also imply a minimum Bazel version of 6.3.2. I'm thinking we let this bake for a little while, to catch any unexpected issues, and then, if it sticks, we try to go ahead and require C11 across the board. Update-Note: If using Bazel with MSVC, and the build fails with something like "Command line error D8016 : '/std:c++20' and '/std:c11' command-line options are incompatible", you are likely running into the above Bazel bug. Update to Bazel 6.3 or later. Bug: 623, 624 Change-Id: I8baa99392ca47bc7580bc2930e7f4b16beced91e Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/62905 Auto-Submit: David Benjamin <[email protected]> Reviewed-by: Adam Langley <[email protected]> Commit-Queue: Adam Langley <[email protected]>
* Move testonly deps to `tink_cc_testonly_deps()` * Upgrade deps: * googletest (=> 1.14) * absl (=> 20230802.1) * BoringSSL (=> commit 667d54c96acda029523c5bf425e8eb9079dbe94a from the `master-with-bazel` branch) * bazel_skylib (=> 1.5.0) * bazel (=> 6.4.0) (this is needed because of [1] and [2]) [1] bazelbuild/bazel#15073 [2] google/boringssl@235ee97 PiperOrigin-RevId: 596709495 Change-Id: I04e978161ee9b6adf8ccdf3e73f8a54abffc7ded
* Move testonly deps to `tink_cc_testonly_deps()` * Upgrade deps: * googletest (=> 1.14) * absl (=> 20230802.1) * BoringSSL (=> commit 667d54c96acda029523c5bf425e8eb9079dbe94a from the `master-with-bazel` branch) * bazel_skylib (=> 1.5.0) * bazel (=> 6.4.0) (this is needed because of [1] and [2]) [1] bazelbuild/bazel#15073 [2] google/boringssl@235ee97 PiperOrigin-RevId: 596709495
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
bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
Line 28 in 88499f6
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
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
The text was updated successfully, but these errors were encountered: