<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;"><div>Hi Richard,</div><div><br></div><div>Thanks for the review! As I said, this didn’t feel like a great fix to me either.</div><br><div><blockquote type="cite"><div>On May 27, 2014, at 3:00 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 27, 2014 at 8:31 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">CC’ing djasper, since you made -fmodule-name a driver option, so you may be familiar with this code.<br>
<br>
I’m not super happy with this patch, but we really need some way to not use modular imports while compiling the implementation (e.g. .c/.cpp/.m files) files that correspond to module headers. Both because we are not yet isolating submodules from each other enough to do incremental rebuilding</blockquote>
<div><br></div><div>Can you explain what you mean by this? In particular, I'm very unclear on how it the translation unit being compiled has any relation to this issue. (I've not seen any problems that match this description so far.)</div></div></div></div></div></blockquote><div><br></div><div>My understanding is that when we build a module with submodules, the submodules can access the declarations/definitions in previously built submodules. Until that is fixed, it seems that to be safe we should rebuild everything that depends on a module whenever any of its headers change. That ruins incremental rebuilding for the author of the module whenever they change their headers since all of their implementation files likely would depend on the module.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> and because with the VFS added to the mix we may get a mix of textual and modular imports of the same headers when doing “quote”-style includes, which doesn’t yet work properly (multiple definitions, hidden definitions, fun stuff).<br>
</blockquote><div><br></div><div>I assume you intend for this bug to be fixed eventually. Once that's done, is there still value in this flag?</div></div></div></div></blockquote><div><br></div><div>Right, ideally we should still find the module with the VFS, and even if we don’t it shouldn’t matter. Once that (and the above) is fixed, the flag has no use that I can think of.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Add stopgap option -fmodule-implementation-of <name><br></blockquote><div><br></div><div>Please do not add a stopgap workaround to our stable and backwards-compatible driver interface; just add it to -cc1 instead.</div></div></div></div></blockquote><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This flag specifies that we are building an implementation file of the<br>
module <name>, preventing importing <name> as a module. This does not<br>
consider this to be the 'current module' for the purposes of doing<br>
modular checks like decluse or non-modular-include warnings, unlike<br>
-fmodule-name.</blockquote><div><br></div><div>I don't see any relation between the flag's name and its functionality; there seems to be no reason for this to be linked to the translation unit being the implementation of any particular module (and if there were, that's what -fmodule-name is for). Instead, I think what you're trying to specify is that a particular module is included textually for this compilation. Please pick a name that suggests that functionality instead.</div></div></div></div></blockquote><div><br></div><div>The name is related to the use-case, not the mechanism. I originally thought about something like “-no-module=<name>", but I didn’t want to use a generic diagnostic e.g. “error: @import of module specified with -no-module=”). With the more specific flag I have a more specific diagnostic that says not to @import the module you’re implementing and use #import instead.</div><div><br></div><div>The reason -fmodule-name didn’t seem right here is that it treats the current TU as being part of a module build (i.e. we are inside compileModule and/or have set -emit-module). We look at CurrentModule (which is what -fmodule-name sets) in a number of places and can get odd behaviour if you aren’t actually compiling a module. For example, when we call loadModule, we skip loading the named module and making it visible, but we still add it to the list of imports. That causes trouble with PCH, which then think that this module was actually loaded already. I also don’t want to unconditionally do decluse checking or give non-modular include warnings, etc when building an implementation file.</div><div><br></div><div>Maybe when we really are inside a module build, a better way to spell -fmodule-name=Blah -emit-module would be -emit-module=Blah? But we already have -fmodule-name as a driver option so I don’t know if we would really want to change this.</div><div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><br></div><div>I'm also not sure how this is supposed to work in general: suppose the implementation of module A imports module B, and module B includes a header from module A. Do we get another variant of module B, or do we textually include A into B (generating probably-broken submodule visibility), or is that now an error, or something else?</div>
</div></div></div>
</blockquote></div><br><div>Module B is unaffected by this option, since it gets reset in LangOptions::resetNonModularOptions(), which admittedly would end up going back to mixing modular and non-modular includes so maybe an error is more appropriate. I’m curious: what would the use case for this pattern be? I can see why you would want a submodule of A (e.g. A.Internal) to do this, but why some other top-level module B?</div><div><br></div><div><br></div><div>Ben</div></body></html>