Skip to content

Commit

Permalink
Build with C11 on MSVC in the standalone Bazel build
Browse files Browse the repository at this point in the history
We require MSVC 2019 now, which has a /std:c11 flag. Enable it to match
the CMake build and remove a blocker for requiring C11 unconditionally.

(This select branch is also used by clang-cl. I had meant to figure out
the @bazel_tools business as part of this, but it turns out clang-cl
works better with the MSVC flags than the GCC ones anyway. -Wall in
clang-cl is like MSVC's /Wall and actually means all warnings. Ideally
we'd still condition this on the compiler, in case anyone uses MinGW,
but we can figure that out later.)

Tested with bazelisk build :all and
bazelisk build --compiler=clang-cl :all on Windows.

Change-Id: I4559789a221071eef39f9d34929f0e9c5994119e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61127
Commit-Queue: Adam Langley <[email protected]>
Auto-Submit: David Benjamin <[email protected]>
Reviewed-by: Adam Langley <[email protected]>
  • Loading branch information
davidben authored and Boringssl LUCI CQ committed Jun 27, 2023
1 parent 286ea21 commit 28e4a1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/BUILD.toplevel
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ boringssl_copts = [
}) + asm_copts

boringssl_copts_c11 = boringssl_copts + select({
"@platforms//os:windows": [],
"@platforms//os:windows": ["/std:c11"],
"//conditions:default": gcc_copts_c11,
})

Expand Down

3 comments on commit 28e4a1b

@Vertexwahn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change broke my build:

Command line error D8016 : '/std:c++20' and '/std:c11' command-line options are incompatible

I am building with this config (in .bazelrc` file):

# Visual Studio 2022
build:vs2022 --cxxopt=/std:c++20
build:vs2022 --cxxopt=/Zc:__cplusplus
build:vs2022 --enable_runfiles # https://github.com/bazelbuild/bazel/issues/8843
build:vs2022 --copt=-DWIN32_LEAN_AND_MEAN
build:vs2022 --copt=-DNOGDI
build:vs2022 --host_copt=-DWIN32_LEAN_AND_MEAN
build:vs2022 --host_copt=-DNOGDI
build:vs2022 --define compiler=vs2022

Any ideas how work around it?

@davidben
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vertexwahn Please see the README for a link to our bug tracker. Can you please file a bug with more information? Specifically, the rest of the build output, so we can see:

  1. What file failed
  2. The compiler command that was run

In particular, /std:c11 should only have been passed to C files, while your /std:c++20 option was passed as --cxxopt which should only have been passed to C++ files. It's strange that, somehow, both flags were passed to some file.

@Vertexwahn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.