Skip to content
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

Bazel build: Fix ignoring unknown option '-std=c++14' for Windows builds #1100

Open
Vertexwahn opened this issue Jun 8, 2024 · 2 comments
Open
Assignees

Comments

@Vertexwahn
Copy link
Contributor

When build glog on Windows you get the following warning when using Visual Studio 2022: unknown option '-std=c++14' for Windows builds.

The reason for this is here.

Abseil has a good way to handle flags for different compilers - could copied here - something like this:

in configure_copts.bzl:

GLOG_MSVC_FLAGS = [
    "/std:c++20",
]

GLOG_GCC_FLAGS = [
    "-std=c++23",
]

GLOG_CLANG_FLAGS = [
    "-std=c++20",
]

GLOG_DEFAULT_COPTS = select({
    "//glog:msvc_compiler": GLOG_MSVC_FLAGS,
    "//glog:gcc_compiler": GLOG_GCC_FLAGS,
    "//glog:clang_compiler": GLOG_CLANG_FLAGS,
    "//conditions:default": GLOG_GCC_FLAGS,
})

In BUILD file:

config_setting(
    name = "msvc_compiler",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "msvc-cl",
    },
    visibility = [":__subpackages__"],
)

config_setting(
    name = "gcc_compiler",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "gcc",
    },
    visibility = [":__subpackages__"],
)

config_setting(
    name = "clang_compiler",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "clang",
    },
    visibility = [":__subpackages__"],
)
@drigz
Copy link
Member

drigz commented Jun 10, 2024

@Vertexwahn I don't have a way to test this but happy to review a PR if you'd like to assign yourself and try out that suggestion.

@drigz
Copy link
Member

drigz commented Jun 10, 2024

If absl have a precedent for testing this with the Bazel CI that would be ideal: https://github.com/google/glog/blob/master/.bazelci/presubmit.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants