Question about circular dependency checker

So I decided to bundle up the small amount of work I've done on generating source-level debugging info into a DebugInfoBuilder class like I described earlier. I went and added a new file to the "Support" directory (in include and lib). However, when I try to compile it, it complains of a circular dependency error between libCore and libSupport:

    find-cycles.pl: Circular dependency between *.a files:
    find-cycles.pl: libLLVMCore.a libLLVMSupport.a

The odd part is, that no other file in LLVM even references my header, so I'm not sure where the cycle is.

The headers that I am including in my .cpp file are:

    #include <llvm/DerivedTypes.h>
    #include <llvm/Constants.h>
    #include <llvm/GlobalVariable.h>
    #include <llvm/Module.h>
    #include <llvm/CodeGen/MachineModuleInfo.h>
    #include <llvm/Support/Dwarf.h>
    #include <llvm/System/Path.h>

My .h file uses forward declarations for everything and needs no headers (yet).

I need MachineMouleInfo.h to get LLVMDebugVersion, and I use Path to split the module directory name from the file name.

Any ideas? Am I going to have to put my .cpp file in some library other than Support?

-- Talin

I'm not a LLVM developer, but I'll give it a try...

I went and added a new file to the "Support"
directory (in include and lib). However, when I try to compile it, it
complains of a circular dependency error between libCore and libSupport:

   find-cycles.pl: Circular dependency between *.a files:
   find-cycles.pl: libLLVMCore.a libLLVMSupport.a

The odd part is, that no other file in LLVM even references my header,
so I'm not sure where the cycle is.

The problem is not other code depending on your files directly. The
"Support" library consists (AFAIK) of utility code that is used
everywhere in other LLVM libraries. So you cannot add code to the
"Support" library that calls code in other LLVM libraries on a higher
level, like "VMCore", without introducing a circular dependency
between the libraries.

The headers that I am including in my .cpp file are:

   #include <llvm/DerivedTypes.h>
   #include <llvm/Constants.h>
   #include <llvm/GlobalVariable.h>
   #include <llvm/Module.h>
   #include <llvm/CodeGen/MachineModuleInfo.h>
   #include <llvm/Support/Dwarf.h>
   #include <llvm/System/Path.h>

There's your problem.

Any ideas? Am I going to have to put my .cpp file in some library other
than Support?

If you need the includes, and you probably do, then you have no choice
but to put your code in another library.

Regards,
Kevin André

HyperQuantum wrote:

I'm not a LLVM developer, but I'll give it a try...

I went and added a new file to the "Support"
directory (in include and lib). However, when I try to compile it, it
complains of a circular dependency error between libCore and libSupport:

   find-cycles.pl: Circular dependency between *.a files:
   find-cycles.pl: libLLVMCore.a libLLVMSupport.a

The odd part is, that no other file in LLVM even references my header,
so I'm not sure where the cycle is.
    
The problem is not other code depending on your files directly. The
"Support" library consists (AFAIK) of utility code that is used
everywhere in other LLVM libraries. So you cannot add code to the
"Support" library that calls code in other LLVM libraries on a higher
level, like "VMCore", without introducing a circular dependency
between the libraries.

The headers that I am including in my .cpp file are:

   #include <llvm/DerivedTypes.h>
   #include <llvm/Constants.h>
   #include <llvm/GlobalVariable.h>
   #include <llvm/Module.h>
   #include <llvm/CodeGen/MachineModuleInfo.h>
   #include <llvm/Support/Dwarf.h>
   #include <llvm/System/Path.h>
    
There's your problem.

Any ideas? Am I going to have to put my .cpp file in some library other
than Support?
    
If you need the includes, and you probably do, then you have no choice
but to put your code in another library.
  

All right, then, which library should it go in to? I wanted it to go into "Support" because logically it is a sibling of IRBuilder - it does what IRBuilder does, only for source-level debugging info.

CodeGen, since it depends on MachineModuleInfo.

Gordon Henriksen wrote:

CodeGen, since it depends on MachineModuleInfo.
  

I started to do that, but after some investigation I came to the conclusion that putting it there was wrong. So instead, I removed the dependencies on System/Path and MachineModuleInfo (the only thing it was getting from there was LLVMDebugVersion.)

Unfortunately, I am still getting circular dependency errors. My headers now look like this:

    #include <llvm/Support/DebugInfoBuilder.h>
    #include <llvm/DerivedTypes.h>
    #include <llvm/Constants.h>
    #include <llvm/GlobalVariable.h>
    #include <llvm/Module.h>
    #include <llvm/Support/Dwarf.h>

I also think that the definition of LLVMDebugVersion should be moved out of CodeGen. AFAICT, Frontends can write bitcode files without ever linking to CodeGen, but they will want to know the debug version.

Also - I'd like to send what I have done so far just for sanity checking and approval of the overall direction I am taking with the API for this thing.

Oh, and one other thing - I was wondering how incomplete a debug descriptor graph can be and still be valid. For example: The source line number descriptors contain references to function descriptors, which contain references to type descriptors, and so on. Suppose I want to just generate line number information without all of the complete typing information. Can the appropriate descriptor fields be left blank?