Skip to content

Using tools when building for a platform #74

@oliverlee

Description

@oliverlee

I would like to be able to specify that a binary should be built for a specific platform and run it under gdb

toolchains_arm_gnu/examples/bzlmod on  HEAD (2f22aa8) [!] via  6GiB/8GiB | 6GiB/7GiB
❯  bazel run --platforms=//custom/platform:cortex_m3 --run_under=@arm_none_eabi//:gdb //custom:binary

However, this fails as gdb is constrained

native_binary(
name = tool,
src = select({
host: "@%toolchain_name%_{}//:{}".format(host, tool)
for host in hosts["%toolchain_prefix%"].keys()
}),
out = tool,
target_compatible_with = select({
host: constraint_values
for host, constraint_values in hosts["%toolchain_prefix%"].items()
} | {
"//conditions:default": ["@platforms//:incompatible"],
}),
)

Is there a specific reason to constrain the binaries in this way?

If not, would it make sense to remove target_compatible_with and set

src = "@%toolchain_name%_{}//:{}".format(_normalize(HOST_CONSTRAINTS), tool),

similar to how the toolchain alias is created for custom toolchains?

if _normalize(os) == host.os and _normalize(cpu) == host.cpu:
native.alias(
name = name,
actual = ":{}_{}".format(name, host_repo),
visibility = visibility,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions