I'm trying to add an armv6k cpu constraint value to https://github.com/grailbio/bazel-toolchain to create a platform and cross compile for the raspberry pi zero. I'm using this toolchain in another project to compile both on x86-64 and cross compile for the pi (bare minimum test case linked below).
I have this defined in the platforms/BUILD.bazel in my branch of the above repo:
constraint_value(
name = "armv6k",
constraint_setting = "@platforms//cpu:cpu",
)
Which, as I understand the platform docs, should add a "@platforms//cpu:armv6k".
When I define the platform like this (in the same file):
platform(
name = "linux-armv6k",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:armv6k",
],
)
I run into this error:
ERROR: /home/ubuntu/.cache/bazel/_bazel_1000/a08c2e4811c846650b733c6fc815a920/external/com_grail_bazel_toolchain/platforms/BUILD.bazel:38:9: no such target '@platforms//cpu:armv6k': target 'armv6k' not declared in package 'cpu' defined by /home/ubuntu/.cache/bazel/_bazel_1000/a08c2e4811c846650b733c6fc815a920/external/platforms/cpu/BUILD (did you mean 'armv7k'? Tip: use `query "@platforms//cpu:*"` to see all the targets in that package) and referenced by '@com_grail_bazel_toolchain//platforms:linux-armv6k'
I expected that @platforms//cpu:armv6k would be a valid declaration with the constraint_value present. bazel query @platforms//cpu:*
should show armv6k, but it does not.
A bare minimum test case is here: https://github.com/baverbud/armv6k-testcase
Full set of changes to the grailbio toolchain (used by the bare minimum test case above) are here: https://github.com/baverbud/bazel-toolchain-raspi/tree/linux-armv6k
Environment details:
ubuntu@0a6fc3f137a5:/src/workspace$ bazel info release
release 6.2.1
Building using the gcr.io/bazel-public/bazel:latest linux docker image as of today (July 11, 2023) (host machine is windows).
Relevant web searches: I found https://github.com/bazelbuild/bazel/issues/13047 which looks like it could be related
//platforms:armv6k
is a label referring to your new constraint_value
, use that instead. @platforms//cpu:armv6k
is looking in the @platforms//cpu
package, which you haven't modified, so it's not there.
You could also write @com_grail_bazel_toolchain//platforms:armv6k
to fully qualify the label. Because it's in the same package in this case, :armv6k
also works.
For reference, you can inspect what's in that package via the convenience symlink in your workspace directory at bazel-out/../../../external/platforms/cpu/BUILD
. I find that helpful for debugging.