Skip to content

Set OS and compiler constraints - #35

Open
auscompgeek wants to merge 3 commits into
wpilibsuite:mainfrom
auscompgeek:constraints-gcc
Open

auscompgeek wants to merge 3 commits into
wpilibsuite:mainfrom
auscompgeek:constraints-gcc

Conversation

@auscompgeek

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

auscompgeek commented Nov 23, 2025

Copy link
Copy Markdown
Member Author

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