ninja: error: dependency cycle

2,844 views
Skip to first unread message

Jeff.R

unread,
May 13, 2015, 5:46:37 PM5/13/15
to ninja...@googlegroups.com
Hi,

I'm using ninja to build my embedded software project which use TI's MSP430 compiler tool chains. It almost works but the incremental compiling. In this toy example, I only has one main.c. As soon as I edit it and do compiling after, it gave me this error: 
ninja
ninja: error: dependency cycle: RelADebug/main.obj -> RelADebug/main.obj

The attached is the build file, the dependency file produced and the main.c. what's the problem here? I did some google but not find the answer. 

Br,  Jeff.R
main.c
build.ninja
main.obj.dd

Nico Weber

unread,
May 13, 2015, 5:50:34 PM5/13/15
to Jeff.R, ninja-build
I think the problem is that ninja doesn't understand the dependency file format written by your compiler. The d file looks like this:

RelADebug\main.obj: main.c
RelADebug\main.obj: c:/ti/ccsv6/ccs_base/msp430/include/msp430.h
RelADebug\main.obj: c:\ti\ccsv6\ccs_base\msp430\include\msp430f247.h
RelADebug\main.obj: c:\ti\ccsv6\ccs_base\msp430\include\in430.h
RelADebug\main.obj: C:/ti/ccsv6/tools/compiler/msp430_4.3.3/include/intrinsics.h


Ninja expects it to look like "output: input1 input2 input 3". Given your input file, it (incorrectly) thinks that the first mention of "main.obj" is the output, and the other "main.obj"s are inputs. https://github.com/martine/ninja/issues/876 is kind of about this. Ideally, you can convince your toolchain to write depfiles in the format that ninja understands.

Nico

--
You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Evan Martin

unread,
May 13, 2015, 5:58:10 PM5/13/15
to Nico Weber, Jeff.R, ninja-build
The dependency file format is Makefiles, for better or for worse, and
I think that is valid Make syntax for building up a list of
dependencies for a single output. If it's not easy to fix the
compiler it might be easy to fix the depfile parser -- now that we
have deps mode the code to parse these shouldn't be as critical for
performance. (I think in the Windows case we actually touch the file
system when processing its deps output...)

Richard O'Grady

unread,
May 13, 2015, 6:19:51 PM5/13/15
to Evan Martin, Nico Weber, Jeff.R, ninja-build
FWIW, I've made some changes in my fork to parse this kind of depfile, which is also produced by the SNC compiler:
https://github.com/rjogrady/ninja/blob/master/src/depfile_parser.in.cc#L33
"FixupSNCDep()" converts it to gcc style.

We had to add a "depformat" keyword to describe what kind of deps the compiler produces, because writing the fully generic parser was beyond me.  But if that existed it would be amazing.


Reply all
Reply to author
Forward
0 new messages