<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Nikola, thanks for bringing the issue to our attention, but let’s decouple the windows issue from this proposal. It would be good to focus the discussion on the enhancement we are proposing, without mixing general file system issues.<div>The windows issue can still be addressed separately.<br><div><br><div><div>On Feb 6, 2014, at 3:15 PM, Nikola Smiljanic <<a href="mailto:popizdeh@gmail.com">popizdeh@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I'd just like to point out that this might be the right time to fix the handling of unicode paths on windows. Calls to ::open, ::stat and friends don't support utf8 encoded input on windows <a href="http://llvm.org/bugs/show_bug.cgi?id=10348">http://llvm.org/bugs/show_bug.cgi?id=10348</a></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 7, 2014 at 10:04 AM, Ben Langmuir <span dir="ltr"><<a href="mailto:blangmuir@apple.com" target="_blank">blangmuir@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi all,</div><div><br></div><div>I’ve been hacking on a virtual file system for clang and this seemed like the right time to start getting some feedback. Briefly, the idea is to interpose a virtual file system layer between llvm::sys::fs and Clang’s FileManager that allows us to mix virtual files/links/etc. with the ‘real’ file system in a general way.</div>
<div><br></div><div><br></div><div>Motivation</div><div><br></div><div>The use case that I have in mind is to allow a build system to provide a file/directory layout to clang without having to construct it “for real” on disk. For example, I am building a project containing two modules, and module A imports module B. It would be useful if we could bundle up the headers and module.map file for module B from wherever they may exist in the source directories and provide clang with a notion of the file layout of B _as it will be installed_. Right now, I know of two existing ways to accomplish this:</div>
<div><br></div><div>1) Copy the files into a fake installation during build. This is unsatisfying, as it requires tracking and copying files every time they are changed. And diagnostics, debug info, etc. do not refer back to the original source file.</div>
<div><br></div><div>2) Header maps provide this functionality for header files. However, header maps work from within the header search logic, which does not extend well to other kinds of files. They are also insufficient for bundling modules, as clang needs to see the framework for the module laid out as described in the module map.</div>
<div><br></div><div><br></div><div>Description</div><div><br></div><div>The idea is to abstract the view of the file system using an AbstractFileSystem class that mimics the llvm::sys::fs interface:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div>class AbstractFileSystem {</div><div>public:</div><div> class Status { … };</div><div> // openFileForRead</div><div> // status, and maybe ‘stat'</div><div> // recursive iteration</div><div> // getBuffer</div>
<div> // getBufferForOpenFile</div><div> // recursive directory iteration</div><div>};</div><div><br></div></blockquote>that can be implemented by any concrete file system that we want. Clients that want to lookup files/directories (notably the FileManager) can operate on an AbstractFileSystem object. One leaky part of this interface is that clients that need to care whether they are working with a ‘real path’ will need to explicitly ask for it. For example, debug information and diagnostics should ask for the real path. I suggest putting that information into the AbstractFIleSystem::Status object.<div>
<br></div><div><div>Some non-goals (at least for a first iteration):</div><div>1) File system modification operations (create_directory, rename, etc.). Clients will continue to use the real file system for these operations, and we don’t intend to detect any conflicts this might create.</div>
<div>2) Completely virtual file buffers that do not exist on disk.</div></div><div><br></div><div>One implementation of the AbstractFileSystem interface would be a wrapper over the ‘real’ file system, which would just defer to llvm::sys::fs.<div>
<div><br></div><div><span style="white-space:pre-wrap"> </span>class RealFileSystem : public AbstractFileSystem { … };</div><div><br></div><div>And to provide a unified view of the file system, we can create an overlay file system, similar to [1].</div>
<div><br></div><div><span style="white-space:pre-wrap"> </span>class OverlayFileSystem : public AbstractFileSystem { … };</div><div><br></div><div>To support a build system providing clang with a virtual file layout, we could add an option to clang that accepts a file describing the layout of a virtual file system. In a first iteration, this could be a simple json file describing the mapping from virtual paths to real paths, and a corresponding class VFSFromJSONFile : public AbstractFileSystem. Later we can evolve a more efficient binary format for this. In addition we should provide functions in libclang to produce these files.</div>
<div><br></div><div><div><br></div><div>I would appreciate any feedback you might have,</div><div><br></div><div>Ben</div><div><br></div><div>[1] <a href="https://git.kernel.org/cgit/linux/kernel/git/mszeredi/vfs.git/plain/Documentation/filesystems/overlayfs.txt?h=overlayfs.current" target="_blank">https://git.kernel.org/cgit/linux/kernel/git/mszeredi/vfs.git/plain/Documentation/filesystems/overlayfs.txt?h=overlayfs.current</a></div>
</div></div></div><div><br></div><div>Also, thanks to everyone who has already given me feedback thus far.</div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></body></html>