We intend to use this contraint for cpu & compiler selection for the
OpenTitan project. We are working on creating a riscv32 compiler
configuration in the bazel-embedded project.
Signed-off-by: Chris Frantz <cfrantz@google.com>
On Apple silicon Macs, auto-detected host platform constraints' cpu is
aarch64, but arm64 is used everywhere else. This change ensures that you
will get the same cpu when your target depends on an arm64 or an aarch64
cpu contraint.
The bazel docs [1] currently recommend users to create an
`incompatible` constraint in their own code base. This constraint is
useful in expressing more advanced target compatibilities.
Currently every project has to create their own definition for this
constraint. That is unnecessary proliferation of something that can be
easily centralized here.
This patch makes it so users will be able to use the following pattern
in their BUILD files:
cc_library(
name = "unixish_lib",
srcs = "unixish_lib.cc",
target_compatible_with = select({
"@platforms//os:osx": [],
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
],
)
[1]: https://docs.bazel.build/versions/master/platforms.html#skipping-incompatible-targets
This is commonly known thumbv6. However, it appears that the name
is split between armv6-m and thumbv6 globally. I choose the arm
notation in order to be consistent with the other arm platforms.
NixOS uses the Linux kernel, but that's where commonality with the
myriad Linux distributions out there stops. Like the different BSD's,
NixOS is sufficiently different that it warrants a constraint value.
In particular, no non-static binary has any chance of running on NixOS
unless it was specifically built for it, because the dynamic linker is
in a non-standard location. This means that toolchains downloaded as
part of host autoconfiguration that detect Linux (like
`go_register_toolchains()`) always fail on NixOS.
NixOS is a popular operating system used by thousands, one of the most
active projects on all of GitHub, and with more unique packages than
even Debian, Fedora or Gentoo according to https://repology.org/.