In rule based toolchains, cc_args can carry data files needed by the arguments it expands. When those args are guarded by requires_any_of or are attached to a feature that is not enabled, the flags are correctly omitted from the command line, but their data files can still be added to the action inputs.
This means mutually exclusive or disabled toolchain features may both contribute files to the same action input set. For link actions, this can accidentally place both static and dynamic runtime search directories in the sandbox even though only one link mode is active.
Expected behavior
cc_args(data=...) should follow the same feature/action selection as the args themselves. If the args do not expand for an action, their data files should not be required inputs for that action.
Repro
A minimal repro is a rule based toolchain with two link-mode features:
cc_feature_constraint(
name = "static_linking_mode_enabled",
all_of = ["//cc/toolchains/features:static_linking_mode"],
)
cc_feature_constraint(
name = "dynamic_linking_mode_enabled",
all_of = ["//cc/toolchains/features:dynamic_linking_mode"],
)
cc_args(
name = "static_runtime_search_dir",
actions = ["//cc/toolchains/actions:link_actions"],
args = ["-L{static_dir}"],
data = [":static_dir"],
format = {"static_dir": ":static_dir"},
requires_any_of = [":static_linking_mode_enabled"],
)
cc_args(
name = "dynamic_runtime_search_dir",
actions = ["//cc/toolchains/actions:link_actions"],
args = ["-L{dynamic_dir}"],
data = [":dynamic_dir"],
format = {"dynamic_dir": ":dynamic_dir"},
requires_any_of = [":dynamic_linking_mode_enabled"],
)
When linking dynamically, only dynamic_dir should be an input. Today the disabled static args’ data may still be present.
In rule based toolchains, cc_args can carry data files needed by the arguments it expands. When those args are guarded by requires_any_of or are attached to a feature that is not enabled, the flags are correctly omitted from the command line, but their data files can still be added to the action inputs.
This means mutually exclusive or disabled toolchain features may both contribute files to the same action input set. For link actions, this can accidentally place both static and dynamic runtime search directories in the sandbox even though only one link mode is active.
Expected behavior
cc_args(data=...) should follow the same feature/action selection as the args themselves. If the args do not expand for an action, their data files should not be required inputs for that action.
Repro
A minimal repro is a rule based toolchain with two link-mode features:
When linking dynamically, only dynamic_dir should be an input. Today the disabled static args’ data may still be present.