<div dir="ltr">One more,<div><br></div><div>I couldn&#39;t build the libswiftCore.dll which can be used for Hello.swift. At least one symbol _TMSS is not dllexported.</div><div>(But I could build the dll with dlltool.exe which make all symbols to be dllexported)</div><div><br></div><div>To find out the reason, I built a Swift.ll instead of the Swift.obj for the libswiftCore.dll. The Swift.ll are built from many stdlib/public/core/*.swift and core/8/*.swift files, and about 50MB.</div><div><br></div><div>In that file, I could find many dllexport symbols, like</div><div><div>@_TZvOs7Process5_argcVs5Int32 = dllexport global %Vs5Int32 zeroinitializer, align 4<br></div></div><div>and Hello.ll uses them,</div><div><div>@_TZvOs7Process5_argcVs5Int32 = external dllimport global %Vs5Int32, align 4</div></div><div><br></div><div>In the case of _TMSS, Hello.ll uses the same way,</div><div><div>@_TMSS = external dllimport global %swift.type, align 8</div></div><div>But, Swift.ll did not declared with dllexport.</div><div><div>@_TMSS = alias %swift.type, bitcast (i64* getelementptr inbounds (&lt;{ i8**, i64, i64, %swift.type*, i64 }&gt;, &lt;{ i8**, i64, i64, %swift.type*, i64 }&gt;* @_TMfSS, i32 0, i32 1) to %swift.type*)</div></div><div><br></div><div>How we can make @_TMSS also has the dllexport?  Or any other solution ?</div><div><br></div><div><br></div><div>-Han Sangjin</div><div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-05-08 8:01 GMT+09:00 Sangjin Han <span dir="ltr">&lt;<a href="mailto:tinysun.net@gmail.com" target="_blank">tinysun.net@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I merged Saleem&#39;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,&lt;some link options&gt;</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 &#39;__imp_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_func3&#39; which could not be resolved!</div><div><br></div><div><div>  swift -O Hello.swift</div><div>  LLVM ERROR: Program used external function &#39;__imp__swift_getExistentialTypeMetadata&#39; 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&#39;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=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-05-07 5:01 GMT+09:00 Saleem Abdulrasool <span dir="ltr">&lt;<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span>On Thu, May 5, 2016 at 5:26 PM, Joe Groff via swift-dev <span dir="ltr">&lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;</span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span><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>
&gt; On May 5, 2016, at 4:18 PM, Sangjin Han via swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; 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>
&gt;<br>
&gt; 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 &#39;print(&quot;Hello&quot;)&#39;.<br>
&gt;<br>
&gt; 1) SWIFT_RUNTIME_EXPORT was not enough for dllexport.<br>
&gt;   Hello.obj needed defined in libswift*.dll<br>
&gt;     _swift_getExistentialTypeMetadata,<br>
&gt;     _TFs5printFTGSaP__9separatorSS10terminatorSS_T_,<br>
&gt;     _TMSS,<br>
&gt;     _TZvOs7Process5_argcVs5Int32,<br>
&gt;     swift_bufferAllocate, ....<br>
&gt;   Some of above are dllexported by the macro, but _T* are not. Maybe, it generated by swiftc.exe.<br>
&gt;   I used the utility &#39;dlltool.exe&#39; from Cygwin/MinGW world. It extracts all symbols and generates &#39;allsymbol.def&#39;.<br>
&gt;   With that .def, I could build the all-symbol-dllexported libswiftCore.dll.<br>
&gt;   (I&#39;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&#39;s IRGen to generate public symbols with LLVM&#39;s &quot;dllexport&quot; 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><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><div><br></div>-- <br><div>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>