<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 17, 2014 at 6:08 PM, 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">Hey Richard (& cfe-dev),<br>
<br>
Currently if one AST file imports another (e.g. module A imports module B), we store the absolute path of module B inside module A’s IMPORTS record.  When we know that both files will always be in the same directory, this wastes space and more importantly prevents moving those modules to another directory.  The latter is very handy when debugging a module bug for which someone has given you their broken module cache.<br>
<br>
When an implicitly built module imports another implicitly built module, we can rely on the modules always being in the same module cache, and I think we should switch to a relative path that is either looked up relative to the current pcm file or the (hash-specific) module cache dir.  Do you think we should do this for explicitly built modules that happen to be in the same directory?</blockquote><div><br></div><div>My initial reaction is that we should preserve the path given in the -fmodule-file= argument on the command line. If I use -fmodule-file=x/foo.pcm and explicitly build y/bar.pcm, I think that y/bar.pcm should say that it finds foo in 'x/foo.pcm'.</div><div><br></div><div>If the user then builds with -fmodule-file=z/foo.pcm -fmodule-file=y/bar.pcm, we should probably ignore the path that was specified for 'foo' when building 'bar'.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What about implicitly built modules that are imported by explicitly built modules?<br></blockquote><div><br></div><div>It seems tricky to make that work transparently if the modules have been relocated. We shouldn't expect that explicitly-built modules are located anywhere near the module cache, so I guess the best we can do is to look for such files in the module cache by default (even if the module cache has moved), and not bother writing out /path/to/module/cache/thing.pcm. If they've been relocated, then I suppose you could explicitly import them with -fmodule-file=$foo.</div><div><br></div><div>However, we need to be cautious that things can change between explicit module build and use, so we need to use the parameters from the explicit module itself when determining the configuration hash of the implicit module. Maybe the simplest thing to do is to skip this case for now; we'd only be saving the space cost of writing out the path to the module cache, and I don't think that's a big deal (at least, not compared to the 100K we waste on a name lookup table for builtins and keywords in each module).</div></div></div></div>