On Monday, May 9, 2016, Joe Groff <<a href="mailto:jgroff@apple.com">jgroff@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On May 9, 2016, at 7:19 PM, Saleem Abdulrasool <<a href="javascript:;" onclick="_e(event, 'cvml', 'compnerd@compnerd.org')">compnerd@compnerd.org</a>> wrote:<br>
><br>
> On Sat, May 7, 2016 at 7:55 PM, Sangjin Han <<a href="javascript:;" onclick="_e(event, 'cvml', 'tinysun.net@gmail.com')">tinysun.net@gmail.com</a>> wrote:<br>
> One more,<br>
><br>
> I couldn't build the libswiftCore.dll which can be used for Hello.swift. At least one symbol _TMSS is not dllexported.<br>
> (But I could build the dll with dlltool.exe which make all symbols to be dllexported)<br>
><br>
> 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.<br>
><br>
> In that file, I could find many dllexport symbols, like<br>
> @_TZvOs7Process5_argcVs5Int32 = dllexport global %Vs5Int32 zeroinitializer, align 4<br>
> and Hello.ll uses them,<br>
> @_TZvOs7Process5_argcVs5Int32 = external dllimport global %Vs5Int32, align 4<br>
><br>
> In the case of _TMSS, Hello.ll uses the same way,<br>
> @_TMSS = external dllimport global %swift.type, align 8<br>
> But, Swift.ll did not declared with dllexport.<br>
> @_TMSS = alias %swift.type, bitcast (i64* getelementptr inbounds (<{ i8**, i64, i64, %swift.type*, i64 }>, <{ i8**, i64, i64, %swift.type*, i64 }>* @_TMfSS, i32 0, i32 1) to %swift.type*)<br>
><br>
> How we can make @_TMSS also has the dllexport? Or any other solution ?<br>
><br>
> Interesting. Does changing the string type from struct to class help? Ill try to have a look at this.<br>
<br>
Did you handle the path that creates these llvm::GlobalAlias objects for type metadata when adding the dllimport/export attributes?</blockquote><div><br></div><div>Ah, awesome, thanks for that hint. That was indeed missing. I suppose I should audit a few more things. I'll upload a new version shortly that should take care of the dll storage on metadata.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Joe<br>
<br>
><br>
><br>
> -Han Sangjin<br>
><br>
><br>
><br>
><br>
> 2016-05-08 8:01 GMT+09:00 Sangjin Han <<a href="javascript:;" onclick="_e(event, 'cvml', 'tinysun.net@gmail.com')">tinysun.net@gmail.com</a>>:<br>
> Hi all,<br>
><br>
> I merged Saleem's #2080 to my working branch, and did some experiment.<br>
><br>
> I could compile easily Hello.swift with #2080 merged one.<br>
><br>
> swiftc -c -o Hello.obj Hello.swift<br>
> clang -o Hello.exe Hello.obj -llibswiftCore -llibswiftSwiftOnoneSupport -Wl,<some link options><br>
><br>
> Without #2080, I should use the *.ll-modifying-trick. It is perfect in this example.<br>
><br>
> But, we need the way to disable dllimport. The immediate mode did not work.<br>
><br>
> swift Hello.swift<br>
> LLVM ERROR: Program used external function '__imp_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_func3' which could not be resolved!<br>
><br>
> swift -O Hello.swift<br>
> LLVM ERROR: Program used external function '__imp__swift_getExistentialTypeMetadata' which could not be resolved!<br>
><br>
> It seems swift.exe call directly the function in the DLL without import library.<br>
><br>
> The feature also needed when we link to static library.<br>
><br>
> I don't know about the SIL, IR, so it is thankful someone tell me how to approach this problem.<br>
><br>
><br>
> 2016-05-07 5:01 GMT+09:00 Saleem Abdulrasool <<a href="javascript:;" onclick="_e(event, 'cvml', 'compnerd@compnerd.org')">compnerd@compnerd.org</a>>:<br>
> On Thu, May 5, 2016 at 5:26 PM, Joe Groff via swift-dev <<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-dev@swift.org')">swift-dev@swift.org</a>> wrote:<br>
><br>
> > On May 5, 2016, at 4:18 PM, Sangjin Han via swift-dev <<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-dev@swift.org')">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>
> 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.<br>
><br>
> <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>
><br>
><br>
> -Joe<br>
> _______________________________________________<br>
> swift-dev mailing list<br>
> <a href="javascript:;" onclick="_e(event, 'cvml', 'swift-dev@swift.org')">swift-dev@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
><br>
><br>
><br>
> --<br>
> Saleem Abdulrasool<br>
> compnerd (at) compnerd (dot) org<br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Saleem Abdulrasool<br>
> compnerd (at) compnerd (dot) org<br>
<br>
</blockquote><br><br>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org<br>