We’ve recently completed a long-term project to annotate all the publicly exported symbols in the libLLVM.so shared object with explicit visibility attributes. I would like to take the next step in this project and start removing public symbols from the shared object that aren’t really useful to library consumers (e.g. GlobalISel, SelectionDAG, etc.)
This leads me to the question of how to approach this. Should we leave all the headers with non-exported symbols in the public include directory (include/llvm) or should we move them somewhere else? Either the same directory as their .cpp implementation files or a shared include/llvm-private directory in the source tree?
The only reason I see to have non-public headers in include/llvm is just for build system convenience, but I could be missing something. Having them in another directory will make it easier for tooling we have that checks for missing visibility attributes on symbols, because we won’t need to have it scan these other directories to make sure that new symbols have the correct visibility attributes.
Having a single include/llvm-private directory would simplify the build system, since we could set this include directory as a global property, but it would mean we have 3 locations for headers depending on how they are used:
- include/llvm for headers with public symobls
- include/llvm-private for headers with non-public symbols that are used by multiple different llvm components.
- $CPP_DIRECTORY for headers with non-public symbols that aren’t used outside of their own component.
What’s the best approach here?
cc @Steelskin