[PATCH] D78058: option to write files to memory instead of disk

Marc Rasi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 13 14:48:04 PDT 2020


marcrasi created this revision.
Herald added subscribers: cfe-commits, jfb, mgorny.
Herald added a project: clang.
marcrasi edited the summary of this revision.

This allows clients to invoke clang without writing anything to disk.

I'm not sure if this is the right design, so I'm sending this patch to
start a discussion about the right way to do this. I'll be happy to make
changes and add tests after talking about the right way to do this!

Motivation:

At Google, we run some Swift source tooling on diskless servers. The
Swift source tooling calls Clang through the ClangImporter
(https://github.com/apple/swift/blob/master/lib/ClangImporter/ClangImporter.cpp).
Clang compiles module to an on-disk module cache, which does not work on
the diskless servers. This patch lets clients ask Clang to write the
module cache to memory.

Current design:

- Adds `class InMemoryOutputFileSystem : public llvm::vfs::FileSystem` that supports write operations backed by memory. After a file is written, its contents are accessible through the `llvm::vfs::FileSystem` interface.
- Adds an `InMemoryOutputFileSystem` field to `CompilerInstance`. When this field is set, the `CompilerInstance` writes to the `InMemoryOutputFileSystem` instead of the real file system.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78058

Files:
  clang/include/clang/Basic/InMemoryOutputFileSystem.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/InMemoryOutputFileSystem.cpp
  clang/lib/Frontend/CompilerInstance.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78058.257119.patch
Type: text/x-patch
Size: 11602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200413/2ca8751f/attachment-0001.bin>


More information about the cfe-commits mailing list