Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkdir -p $depfile crashes with fatal: cycle in rule variables: depfile -> depfile #2305

Open
infinity0 opened this issue Jun 28, 2023 · 1 comment

Comments

@infinity0
Copy link

rule cat
  depfile = d
  command = $
   mkdir -p "$$(dirname $depfile)"; $
   mkdir -p "$$(dirname $out)"; $
   cat $in > $out; $
   touch $depfile

build c: cat /dev/null
$ ninja -f lol.ninja c
ninja: fatal: cycle in rule variables: depfile -> depfile

Error remains even if you comment out the mkdir -p $depfile line.

Error goes away if you REMOVE that line.

Behaviour is very counterintuitive - wasted hours debugging thinking it was to do with complex depfile behaviour, when it was just this dumb unrelated thing. Seems like ninja-build is scanning command including comments to look for undeclared dependencies, and has an exception for $out but not $depfile???

$ ninja --version
1.11.1
$ apt-cache policy ninja-build
[..]
 *** 1.11.1-1 990
        990 http://deb.debian.org/debian testing/main amd64 Packages
[..]
@digit-google
Copy link
Contributor

FWIW, this was fixed by PR #2291, which will be part of the next 1.12 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants