Skip to content

Support overriding exec_groups in child rules #26729

@keith

Description

@keith

Description of the feature request:

With this code:

def _impl(ctx):
    output = ctx.actions.declare_file(ctx.label.name + ".out")
    ctx.actions.write(
        output = output,
        content = """\
#!/bin/sh

exit 0""",
        is_executable = True,
    )

    return [DefaultInfo(executable = output)]

foo_test = rule(
    implementation = _impl,
    test = True,
)

def _child_impl(ctx):
    return ctx.super()

child_test = rule(
    implementation = _child_impl,
    parent = foo_test,
    exec_groups = {
        "test": exec_group(),
    },
)

Bazel crashes with:

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'KeyForBuild{label=//:foo.bzl, isBuildPrelude=false}' (requested by nodes '')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:552)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:435)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: net.starlark.java.eval.Starlark$UncheckedEvalException: DuplicateExecGroupError thrown during Starlark evaluation
        at <starlark>.rule(<builtin>:0)
        at <starlark>.<toplevel>(/tmp/repro/foo.bzl:24)
Caused by: com.google.devtools.build.lib.packages.RuleClass$Builder$DuplicateExecGroupError: Multiple execution groups with the same name: 'test'.
        at com.google.devtools.build.lib.packages.RuleClass$Builder.addExecGroups(RuleClass.java:1576)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleClassFunctions.createRule(StarlarkRuleClassFunctions.java:962)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleClassFunctions.rule(StarlarkRuleClassFunctions.java:604)
...

In my case I was hoping to override the default test exec_group to sidestep the default test toolchain so that my test could run on any exec platform, not just the target platform.

Which category does this issue belong to?

No response

What underlying problem are you trying to solve with this feature?

No response

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

0edd72c

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?


Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

repro.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions