<div dir="ltr">Hi all,<div><br></div><div>I merged Saleem's #2080 to my working branch, and did some experiment.</div><div><br></div><div>I could compile easily Hello.swift with #2080 merged one.</div><div><br></div><div><div> swiftc -c -o Hello.obj Hello.swift</div><div> clang -o Hello.exe Hello.obj -llibswiftCore -llibswiftSwiftOnoneSupport -Wl,<some link options></div></div><div><br></div><div>Without #2080, I should use the *.ll-modifying-trick. It is perfect in this example.</div><div><br></div><div>But, we need the way to disable dllimport. The immediate mode did not work.</div><div><br></div><div> swift Hello.swift</div><div> LLVM ERROR: Program used external function '__imp_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_func3' which could not be resolved!</div><div><br></div><div><div> swift -O Hello.swift</div><div> LLVM ERROR: Program used external function '__imp__swift_getExistentialTypeMetadata' which could not be resolved!</div></div><div><br></div><div>It seems swift.exe call directly the function in the DLL without import library.</div><div><br></div><div>The feature also needed when we link to static library.</div><div><br></div><div>I don't know about the SIL, IR, so it is thankful someone tell me how to approach this problem.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-05-07 5:01 GMT+09:00 Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="">On Thu, May 5, 2016 at 5:26 PM, Joe Groff via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span class=""><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"><span><br>
> On May 5, 2016, at 4:18 PM, Sangjin Han via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I made an experimental MSVC port. Of cause, dllimport/dllexport and the driver for linking and many other part is not implemented. But dynamic linking was possible with some trick.<br>
><br>
> I think it is useful for designing, my observation about the experimental building of libswiftCore.dll, libswiftSwiftOnoneSupport.dll and linking of Hello.exe - its source has only 'print("Hello")'.<br>
><br>
> 1) SWIFT_RUNTIME_EXPORT was not enough for dllexport.<br>
> Hello.obj needed defined in libswift*.dll<br>
> _swift_getExistentialTypeMetadata,<br>
> _TFs5printFTGSaP__9separatorSS10terminatorSS_T_,<br>
> _TMSS,<br>
> _TZvOs7Process5_argcVs5Int32,<br>
> swift_bufferAllocate, ....<br>
> Some of above are dllexported by the macro, but _T* are not. Maybe, it generated by swiftc.exe.<br>
> I used the utility 'dlltool.exe' from Cygwin/MinGW world. It extracts all symbols and generates 'allsymbol.def'.<br>
> With that .def, I could build the all-symbol-dllexported libswiftCore.dll.<br>
> (I'm hoping we can build it without this trick.)<br>
<br>
</span>The _T symbols are emitted by the Swift compiler. You should modify swiftc's IRGen to generate public symbols with LLVM's "dllexport" storage class when targeting Windows.</blockquote><div><br></div></span><div><a href="https://github.com/apple/swift/pull/2080" target="_blank">https://github.com/apple/swift/pull/2080</a> is a first cut attempt to do this.<br></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"><span><font color="#888888"><br>
-Joe<br>
</font></span><span class=""><div><div>_______________________________________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
</div></div></span></blockquote></div><br><br clear="all"><span class=""><div><br></div>-- <br><div>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</span></div></div>
</blockquote></div><br></div>