attr.label executable attribute broken?

20 views
Skip to first unread message

Gregg Reynolds

unread,
Apr 2, 2021, 3:06:39 PMApr 2
to bazel-discuss
I've got a target that depends on an executable that I build, plus another tree of deps.  They have common dependencies.  The rule action executes the executable tool.

My first implementation was:

```
        tool = attr.label(
            mandatory  = True,
            allow_single_file = True,
            executable = True,
            cfg        = "exec",
        ),
```
and then 

```
    ctx.actions.run(
        executable = ctx.file.tool.path,
    ...)
```

This resulted in two output directories with a bunch of duplicate builds.  The executable and its deps go in `bazel-out/darwin-opt-exec-2B5CBBC6/bin`;  the other outputs go in `bazel-out/darwin-fastbuild/bin`.

Aside from the inefficiency of duplicate builds, this breaks my build, because my language (OCaml) sees that some outputs were built with different versions of a common dependency, which it rejects for reasons I need not go into.

My second version eliminated the `executable` and `cfg` attributes on `attr.label`, and changed the run action to use `executable = ctx.file.tool.path`.  This version works.

I think this is a bug, no?

Gregg



Reply all
Reply to author
Forward
0 new messages