Skip to content

dynamic output -> dynamic input does not trigger rebuild, depending on order of build.ninja statements #2653

@dseomn

Description

@dseomn

With this build file that has a file out-1 that's both a dynamic output of stamp-1 and a dynamic input of stamp-2:

rule dd
  command = printf 'ninja_dyndep_version = 1\nbuild $stamp | $dyn_out: dyndep | $dyn_in\n' > $stamp.dd

rule dyn_copy
  command = cp $dyn_in $dyn_out && touch $stamp
  dyndep = $stamp.dd

build stamp-1.dd: dd
  stamp = stamp-1
  dyn_in = source
  dyn_out = out-1

build stamp-2.dd: dd
  stamp = stamp-2
  dyn_in = out-1
  dyn_out = out-2

build stamp-1: dyn_copy || stamp-1.dd
  stamp = stamp-1
  dyn_in = source
  dyn_out = out-1

build stamp-2: dyn_copy || stamp-1.dd stamp-2.dd
  stamp = stamp-2
  dyn_in = out-1
  dyn_out = out-2

Both the initial and a second build work correctly:

$ touch source && ninja -d explain -v
ninja explain: output stamp-1.dd doesn't exist
ninja explain: output stamp-1 doesn't exist
ninja explain: output stamp-2.dd doesn't exist
ninja explain: output stamp-2 doesn't exist
[1/4] printf 'ninja_dyndep_version = 1\nbuild stamp-1 | out-1: dyndep | source\n' > stamp-1.dd
ninja explain: loading dyndep file 'stamp-1.dd'
ninja explain: output stamp-1 doesn't exist
ninja explain: output stamp-2 doesn't exist
[2/4] printf 'ninja_dyndep_version = 1\nbuild stamp-2 | out-2: dyndep | out-1\n' > stamp-2.dd
ninja explain: loading dyndep file 'stamp-2.dd'
ninja explain: out-1 is dirty
[3/4] cp source out-1 && touch stamp-1
[4/4] cp out-1 out-2 && touch stamp-2
$ touch source && ninja -d explain -v
ninja explain: loading dyndep file 'stamp-1.dd'
ninja explain: output stamp-1 older than most recent input source (1755384471679080143 vs 1755384474423035509)
ninja explain: loading dyndep file 'stamp-2.dd'
ninja explain: out-1 is dirty
[1/2] cp source out-1 && touch stamp-1
[2/2] cp out-1 out-2 && touch stamp-2

However, if I move the build stamp-2 statement above the build stamp-1 statement, the initial build is good, but a second build does not build stamp-2:

$ touch source && ninja -d explain -v
ninja explain: output stamp-2.dd doesn't exist
ninja explain: output stamp-1.dd doesn't exist
ninja explain: output stamp-2 doesn't exist
ninja explain: output stamp-1 doesn't exist
[1/4] printf 'ninja_dyndep_version = 1\nbuild stamp-1 | out-1: dyndep | source\n' > stamp-1.dd
ninja explain: loading dyndep file 'stamp-1.dd'
ninja explain: output stamp-2 doesn't exist
ninja explain: output stamp-1 doesn't exist
[2/4] printf 'ninja_dyndep_version = 1\nbuild stamp-2 | out-2: dyndep | out-1\n' > stamp-2.dd
ninja explain: loading dyndep file 'stamp-2.dd'
ninja explain: out-1 is dirty
[3/4] cp source out-1 && touch stamp-1
[4/4] cp out-1 out-2 && touch stamp-2
$ touch source && ninja -d explain -v
ninja explain: loading dyndep file 'stamp-2.dd'
ninja explain: loading dyndep file 'stamp-1.dd'
ninja explain: output stamp-1 older than most recent input source (1755384556861695847 vs 1755384558069676234)
[1/1] cp source out-1 && touch stamp-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions