[cfe-dev] [PATCH] Wrap clang modules inside Mach-O/ELF/COFF containers

Adrian Prantl aprantl at apple.com
Wed Dec 10 17:30:51 PST 2014


> On Dec 10, 2014, at 5:22 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> 
> On Wed, Dec 10, 2014 at 2:36 PM, David Majnemer <david.majnemer at gmail.com <mailto:david.majnemer at gmail.com>> wrote:
> Can we use _cfepch instead?  MSVC linker will silently truncate section names longer than 8 characters.
> 
> I don't like "cfe"; we should indicate which compiler is involved here. I don't like "pch"; this is used for all kinds of AST files, not just PCH files.
> 
> Can we use "ClangAST", or do we need the leading underscore?

The double underscores and all lowercase are a naming convention on Mach-O (which doesn’t have the 8 character restriction, though).
[https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/index.html <https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/index.html>]

Now, we could use different spellings for each platform: “ClangAST” on COFF, and “__clang_ast" on Mach-O, and maybe “.clang_ast" on ELF? It would make the ASTReader code slightly more complicated, but not much.

-- adrian
>  
> On Wed, Dec 10, 2014 at 2:27 PM, Adrian Prantl <aprantl at apple.com <mailto:aprantl at apple.com>> wrote:
> Hi everyone,
> 
> As the first step in preparation for module debugging (see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/040076.html <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/040076.html>) this patch turns the *.pcm files that are used to store clang modules and precompiled headers in a platform-dependent Mach-O/ELF/COFF container, so that eventually we will be able to store debug information alongside the module in the same file.
> 
> This is implemented by using the standard LLVM code generation machinery. Instead of directly writing to the output file, the serialized AST blob is attached to an empty llvm::Module as a ModuleFlag. The module is passed to the backend which emits the AST blob into a special “__clang_pch" section in TargetLoweringObjectFile*.
> On the ASTReader side, any object file is transparently unwrapped and the BitstreamReader is pointed directly to the AST section.
> 
> Other than the .pcm files having an extra header inside, this patch is not meant to have any user-visible effects.
> 
> Known bugs: I still need to figure out how to make c-index-test link against and register the available targets (check-all passes, but the modules created by c-index-test currently are plain old .pcm files).
> Open questions: I made up the name of the new __clang_pch section and the various flags on the different platforms on the spot. I’m open to better suggestions.
> 
> Let me know what you think!
> 
> -- adrian
> 
>  
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141210/11d9974f/attachment.html>


More information about the cfe-dev mailing list