[swift-dev] swift (ABI) and Windows

Joe Groff jgroff at apple.com
Tue May 10 16:29:25 CDT 2016


> On May 10, 2016, at 2:25 PM, Saleem Abdulrasool <compnerd at compnerd.org> wrote:
> 
> On Monday, May 9, 2016, Joe Groff <jgroff at apple.com> wrote:
> 
> > On May 9, 2016, at 7:19 PM, Saleem Abdulrasool <compnerd at compnerd.org> wrote:
> >
> > On Sat, May 7, 2016 at 7:55 PM, Sangjin Han <tinysun.net at gmail.com> wrote:
> > One more,
> >
> > I couldn't build the libswiftCore.dll which can be used for Hello.swift. At least one symbol _TMSS is not dllexported.
> > (But I could build the dll with dlltool.exe which make all symbols to be dllexported)
> >
> > 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.
> >
> > In that file, I could find many dllexport symbols, like
> > @_TZvOs7Process5_argcVs5Int32 = dllexport global %Vs5Int32 zeroinitializer, align 4
> > and Hello.ll uses them,
> > @_TZvOs7Process5_argcVs5Int32 = external dllimport global %Vs5Int32, align 4
> >
> > In the case of _TMSS, Hello.ll uses the same way,
> > @_TMSS = external dllimport global %swift.type, align 8
> > But, Swift.ll did not declared with dllexport.
> > @_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*)
> >
> > How we can make @_TMSS also has the dllexport?  Or any other solution ?
> >
> > Interesting.  Does changing the string type from struct to class help?  Ill try to have a look at this.
> 
> Did you handle the path that creates these llvm::GlobalAlias objects for type metadata when adding the dllimport/export attributes?
> 
> 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.
>  

It might help to centralize the logic. In IRGen, there's a function getIRLinkage that decomposes a semantic SIL visibility into an LLVM linkage and visibility pair:

https://github.com/apple/swift/blob/master/lib/IRGen/GenDecl.cpp#L1201

It could be modified to produce a three-element tuple that includes the DLL storage class too.

-Joe


More information about the swift-dev mailing list