[swift-dev] New global constructor warnings in runtime GlobalObjects.cpp

John McCall rjmccall at apple.com
Tue May 2 11:36:51 CDT 2017


> On May 2, 2017, at 12:02 PM, Joe Groff via swift-dev <swift-dev at swift.org> wrote:
> After updating clang recently, I'm seeing these warnings:
> 
> /Users/jgroff/src/s/swift/stdlib/public/stubs/GlobalObjects.cpp:40:39: warning: declaration requires a global constructor [-Wglobal-constructors]
> swift::_SwiftEmptyArrayStorage swift::_swiftEmptyArrayStorage = {
>                                      ^                         ~
> /Users/jgroff/src/s/swift/stdlib/public/stubs/GlobalObjects.cpp:55:44: warning: declaration requires a global constructor [-Wglobal-constructors]
> swift::_SwiftEmptyDictionaryStorage swift::_swiftEmptyDictionaryStorage = {
>                                           ^                              ~
> /Users/jgroff/src/s/swift/stdlib/public/stubs/GlobalObjects.cpp:83:37: warning: declaration requires a global constructor [-Wglobal-constructors]
> swift::_SwiftEmptySetStorage swift::_swiftEmptySetStorage = {
>                                    ^                       ~
> 
> Looking at the definitions of those objects, it isn't clear to me why they would require global constructors. The types are POD, and their initializers only contain pointers to other globals, which ought to be resolvable by the linker. I also didn't see any recent change to the runtime that seems like it would trigger a change here. Is this a clang bug?

Can you tell from the object file whether a global constructor is needed?

John.


More information about the swift-dev mailing list