<div dir="ltr">On Wed, Apr 6, 2016 at 10:21 AM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I was playing around with the idea of swift and Windows since there are some interesting differences between COFF/PE and (ELF and MachO).</div><div><br></div><div>PE/COFF does not directly address symbols in external modules (DSOs/dylibs/DLLs). Instead, there is an indirect addressing model (thunks in Windows parlance). Fortunately, LLVM has a nice way to model this: GlobalValues have an associated "DLLStorageClass" which indicates whether something is "imported" (provided by an external module), "exported" (provided to external modules), or "default" (everything else).</div><div><br></div><div>Adjusting the IRGen to correctly annotate this part of the semantics should get us part of the way to supporting swift on PE/COFF.</div><div><br></div><div>The thing to consider with this is that the DLL storage class is dependent on how the module(s) are being built. For example, something may change from the exported storage to default if being built into a static library rather than a shared object and is not meant to be re-exported.</div><div><br></div><div>Part of this information really needs to be threaded from the build system so that we know whether a given SIL module is external or internal.</div></div></blockquote><div><br></div><div>To the DLL Storage semantics support, Ive taken a quick first stab at it. Ive pushed the changes to <a href="https://github.com/compnerd/apple-swift/tree/dllstorage">https://github.com/compnerd/apple-swift/tree/dllstorage</a> and created a Pull Request at <a href="https://github.com/apple/swift/pull/2080">https://github.com/apple/swift/pull/2080</a> .</div><div><br></div><div>However, as I expected, this is going to cause problems for building some of the core libraries. In particular, there are mismatches between what gets compiled and is desired. The swiftStubs and swiftRuntime are statically compiled and then merged into swiftCore. There is also the concern of the the support modules (e.g. Platform). If there are stubs that are being used (e.g. via _silgen_name) then there are issues with calculating the correct DLL storage for the associated global values.</div><div><br></div><div>It seems to me, at least initially, that we need a way to treat SwiftModule as a container (a la llvm::Module) and indicate which of the TopLevelDecls are meant to be a single "module" (DSO, DLL, whatever you want to call it) so that we can properly track the DLL storage associated with them. Am I confusing something there?</div><div><br></div><div>Is there a preference on a means to handle this?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Given that this would potentially effect ABI stability, it seems like this is a good time to tackle it so that we can push this into the resilience work that is being done for swift 3.<br clear="all"><div><br></div><div>I would appreciate any pointers and suggestions as to how to best go about handling this.<span class=""><font color="#888888"><br></font></span></div><span class=""><font color="#888888"><div><br></div>-- <br><div>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>