Skip to content

CGO constraint does nothing #4356

Open
Open
@alercah

Description

@alercah

Platform: Windows 11 x64

I cannot get cgo to work, and this is one of the ways I tried that is not being respected.

Reproduction steps

Add the following to BUILD.bazel:

platform(
    name = "x64_windows-clang-cl",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:windows",
        "@bazel_tools//tools/cpp:clang-cl",
        "@rules_go//go/toolchain:cgo_on",
    ],
)

Run bazel with --platforms=//tools:x64_windows-clang-cl --host_platform=//tools:x64_windows-clang-cl and compile a cgo rule with -s.

Expected behaviour

Either the rule is compiled with CGO_ENABLED=1, or an error occurs because the toolchain is not compatible with the cgo_on constraint.

Actual behaviour

The rule is compiled with CGO_ENABLED=0

What should happen

Either the cgo_on constraint should only be supported by toolchains that actually support cgo, or it should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions