Skip to content

Enable transitive target CPU constraint #1264

@steeve

Description

@steeve

Hi,

As part of implementing c-archive and c-shared support, I'm trying to properly propagate CPU selection to the Go toolchain when doing things such as building an iOS app or library.
See https://github.com/znly/rules_go/commit/344d1337b0350ea5e3b9e712437d38f33054d8a7 and https://github.com/znly/rules_go/commit/fce5ac2d1f8a18ae77712cd392c76b54cb03e2d8.

I'm am quite confused as to how to do that properly based on constraints.

I am able to properly select based on a config_setting such as:

config_setting(
    name = 'ios_arm64',
    values = {"cpu": "ios_arm64"},
)

However, when trying to turn that into a constraint, in doing either:

constraint_setting(name = ":cpu")
constraint_value(
    name = 'ios_arm64',
    constraint_setting = ":cpu",
)

Or even:

constraint_value(
    name = 'ios_arm64',
    constraint_setting = "@bazel_tools//platforms:cpu",
)

And adding that constraints to the arch in list.bzl, it fails to properly select the correct target based on the ios_application I'm building, where config_setting works as expected.
I'm using the following command line

$ bazel build --ios_multi_cpus=arm64 //:sampleapp

This isn important because in the case of iOS one could have multiple versions of the c-archive built on different archs (armv7 and arm64).

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions