[RFC][DebugInfo/DWARF] Refactor into to lower- and higher-level libraries (original) (raw)

I need to use dwarf expressions from MC, but depending on libDebugInfoDWARF from MC creates a layering violation. The error most easily seen from bazel builds, but it shows up as link-errors under cmake as well:

@@llvm-project//llvm:MC 
.-> @@llvm-project//llvm:MC
|   @@llvm-project//llvm:DebugInfoDWARF 
|   @@llvm-project//llvm:Object 
|   @@llvm-project//llvm:MCParser 
`-- @@llvm-project//llvm:MC

The code already supports not having an object file or section at runtime by checking for null pointers. For example, DWARFDataExtractor::getRelocatedValue. But they still have this build time dependency.

Splitting it up isn’t difficult (list of patches below). But what should the final result look like? One possible solution would be to move these low-level pieces into a new library llvm/DebugInfo/DWARF/LowLevel, with some forwarding headers so that clients that don’t care can continue to work without modification, and clients that want low-level only can depend just on the low level portions.

Any thoughts?

With no responses, I’m going to assume no one has a strong opinion, and will proceed.