Sporadically undefined symbols during linking

Hey swift-users,

I'm experiencing a linking issue that causes builds to sometimes complete
and sometimes fail, without code changes. I'm not sure if the problem is
with Swift, Xcode, or my usage of either.

My Xcode 7.3 project target is a Swift framework with no dependencies other
than Foundation. Compiling always succeeds, but linking fails about 75% of
the time with errors like the following:

Undefined symbols for architecture x86_64:
"__TWPuRx16ostrichframework11OperandTypexS_8ReadablexS_9WriteablewxPS1_8ReadTypezVs6UInt16wxPS2_9WriteTypezS4_ERRzS4_ERRzS4_ERRzSiERRzSiERRzSiERRzSirGVS_5DEC16x_S_11InstructionS_",
referenced from:
      ostrichframework.Z80.getInstruction () ->
ostrichframework.Instruction? in Z80.o
ld: symbol(s) not found for architecture x86_64

The other 25% of the time, the framework will be built fine, with its user
application working as expected.

Has anyone experienced issues like this, or does anyone have advice on
troubleshooting it? I've tried cleaning, deleting DerivedData, and building
on a different machine, to no avail.

If it helps, the failing project is "ostrichframework" found in the Xcode
workspace here: GitHub - PumpMagic/ostrich: A Game Boy Sound System player for macOS, written in Swift

Any help is greatly appreciated.

Ryan

Are you saying that it fails about 75% of the time even when building from clean, or it fails overall 75% of the time and you have to build from clean to fix? In my experiments it always fails when building just ostrichframework. My guess is that if you build in the IDE you are seeing it sometimes stop based on one failure and other times stop based on another failure.

Can you open a bug on bugreporter.apple.com about this (and let me know the #), I do see some surprising behavior on your project.

- Daniel

···

On Apr 1, 2016, at 7:19 PM, Ryan Conway via swift-users <swift-users@swift.org> wrote:

Hey swift-users,

I'm experiencing a linking issue that causes builds to sometimes complete and sometimes fail, without code changes. I'm not sure if the problem is with Swift, Xcode, or my usage of either.

My Xcode 7.3 project target is a Swift framework with no dependencies other than Foundation. Compiling always succeeds, but linking fails about 75% of the time with errors like the following:

Undefined symbols for architecture x86_64: "__TWPuRx16ostrichframework11OperandTypexS_8ReadablexS_9WriteablewxPS1_8ReadTypezVs6UInt16wxPS2_9WriteTypezS4_ERRzS4_ERRzS4_ERRzSiERRzSiERRzSiERRzSirGVS_5DEC16x_S_11InstructionS_", referenced from:
      ostrichframework.Z80.getInstruction () -> ostrichframework.Instruction? in Z80.o
ld: symbol(s) not found for architecture x86_64

The other 25% of the time, the framework will be built fine, with its user application working as expected.

Has anyone experienced issues like this, or does anyone have advice on troubleshooting it? I've tried cleaning, deleting DerivedData, and building on a different machine, to no avail.

If it helps, the failing project is "ostrichframework" found in the Xcode workspace here: GitHub - PumpMagic/ostrich: A Game Boy Sound System player for macOS, written in Swift

Any help is greatly appreciated.

Ryan
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Daniel, thank you for taking the time to clone the repository and reproduce
the issue yourself.

I was a bit unclear in my last email. The 75% failure chance and 25%
success chance are strictly from clean builds. Once a build fails or
succeeds, it will continue to do so 100% of the time until a clean. (All of
this is assuming no source changes.) I have only experienced this one mode
of failure, as far as I can tell, and when builds succeed, the framework is
generated and code that uses it builds and runs as expected.

I've opened a bug at bugreporter.apple.com with ID 25511119 and clearer
information.

By the way - I didn't mention it in the ticket because I'm not confident it
has anything to do with this issue - but when building previous iterations
of this code with previous versions of Xcode that used Swift 2.1, I saw
reliable compilation failures in which the order of generic type
constraints' members mattered. That is, given the following two protocols:

protocol Foo { typealias Bar }
protocol Baz { typealias Buzz }

This would work:
struct MyGoodStruct<T: protocol<Baz, Foo> where T.Bar == T.Buzz, T.Bar:

{}

And this would not:
struct MyBadStruct<T: protocol<Baz, Foo> where T.Buzz == T.Bar, T.Bar:

{}

As far as I could tell, this had been fixed in Swift 2.2. I bring this up
only because these new linking failures seem to be related to
ostrichframework's Instruction protocol and its implementors.

Thanks again,
Ryan

···

On Sat, Apr 2, 2016 at 9:41 AM, Daniel Dunbar <daniel_dunbar@apple.com> wrote:

Are you saying that it fails about 75% of the time even when building from
clean, or it fails overall 75% of the time and you have to build from clean
to fix? In my experiments it always fails when building just
ostrichframework. My guess is that if you build in the IDE you are seeing
it sometimes stop based on one failure and other times stop based on
another failure.

Can you open a bug on bugreporter.apple.com about this (and let me know
the #), I do see some surprising behavior on your project.

- Daniel

On Apr 1, 2016, at 7:19 PM, Ryan Conway via swift-users < > swift-users@swift.org> wrote:

Hey swift-users,

I'm experiencing a linking issue that causes builds to sometimes complete
and sometimes fail, without code changes. I'm not sure if the problem is
with Swift, Xcode, or my usage of either.

My Xcode 7.3 project target is a Swift framework with no dependencies
other than Foundation. Compiling always succeeds, but linking fails about
75% of the time with errors like the following:

Undefined symbols for architecture x86_64:
"__TWPuRx16ostrichframework11OperandTypexS_8ReadablexS_9WriteablewxPS1_8ReadTypezVs6UInt16wxPS2_9WriteTypezS4_ERRzS4_ERRzS4_ERRzSiERRzSiERRzSiERRzSirGVS_5DEC16x_S_11InstructionS_",
referenced from:
      ostrichframework.Z80.getInstruction () ->
ostrichframework.Instruction? in Z80.o
ld: symbol(s) not found for architecture x86_64

The other 25% of the time, the framework will be built fine, with its user
application working as expected.

Has anyone experienced issues like this, or does anyone have advice on
troubleshooting it? I've tried cleaning, deleting DerivedData, and building
on a different machine, to no avail.

If it helps, the failing project is "ostrichframework" found in the Xcode
workspace here: GitHub - PumpMagic/ostrich: A Game Boy Sound System player for macOS, written in Swift

Any help is greatly appreciated.

Ryan
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users