Skip to content

A group under an earlier rule's generated file is accepted, because the in-tree alias runs only from build path to source path #499

Description

@typeless

Symptom

A group can be declared under a path an earlier rule generates as a file:

: |> echo hi > %o |> d
: |> echo a > %o |> a.txt d/<g>
$ putup -B .
[.] Build completed: 2 commands in 4ms

The graph now holds d twice: once as a generated file and once as a directory containing <g>. The pre-#497 binary behaves the same. Run against build/putup from PR #497 (0dc8b5352).

An output in the same position is already refused ("Unable to create 'd/x' because the generated file 'd' is not a directory"). So is a group under a source file.

Upstream

tup error: Unable to output to a different directory because 'd' is a generated file
tup error: Failed to find directory ID for dir 'd/<g>' relative to '.'

This is find_dir_tupid_dt_pg.

Cause

get_or_create_group_node interns the group's directory as a source-root path, but a rule output is a build-root path. In an in-tree build, ensure_file_node aliases a build path to its source twin (src/graph/dag.cpp:171) but never a source path to its build twin. So the group's ensure_file_node(source d, Directory) finds no node, and creates a fresh Directory beside the generated file. add_file_node's parent check never sees the generated d.

Fix direction

In an in-tree build, when a source path has no node, the lookup should also try its build-root twin, the reverse of the existing alias. Then the group lands under the generated file and #494's parent check refuses it. REQ-OUTPUT-UNDER-DIRECTORY (spec/requirements/output-paths.ears.md) records this gap in its reference and leaves "a generated file" out of the group clause; the fix should restore it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions