Skip to content

Conversation

@auscompgeek
Copy link
Member

This sets rules_cc's compiler_flag to gcc for the cross-compiler platforms, to allow for easily selecting gcc targets (e.g. to specify compiler flags) downstream.

Example usage:

cc_library(
    # ...
    copts = select({
        "@bazel_tools//tools/cpp:msvc": [
            "/wd4005",
            "/wd4018",
            "/wd4244",
            "/wd4267",
            "/wd4996",
        ],
        "@bazel_tools//tools/cpp:gcc": [
            "-Wno-format-nonliteral",
            "-Wno-maybe-uninitialized",
            "-Wno-sign-compare",
            "-Wno-type-limits",
        ],
        "//conditions:default": [],
    }),
)

Also add the OS and compiler constraints to the cross-compilers, since that was also simple to do, to doubly-ensure nobody's trying to request contradictory compilers. (Adding the CPU constraint was too much for my 2am brain.)

@pjreiniger
Copy link
Collaborator

This seems to make sense to me, but @AustinSchuh is much more familiar with the nitty gritty of toolchains so I'd rather have him approve

@AustinSchuh
Copy link
Contributor

That's reasonable. I still feel like there isn't a great consensus in the bazel community for the canonical way to select gcc vs clang, but this is as reasonable as any.

@auscompgeek
Copy link
Member Author

auscompgeek commented Nov 23, 2025

Yeah, I figure since both the toolchain and platform definitions are being controlled here, it makes sense to make the constraint that already exists selectable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants