New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-272] Linker error: Undefined reference to _TFC10Foundation8NSObjectg9_cfTypeIDSu #42894
Comments
Sounds like a compiler bug; even though _cfTypeID is internal to Foundation, it still needs to be available for subclass vtables. |
Just FYI: works on Darwin. |
I am also seeing this with the current snapshot and Foundation built from source. |
we can change _cfTypeID to a function instead of a property if that helps. NSObject should not have any variables since it would screw up the NSCF type layouts |
This issue is no longer blocking me as I can test conforming to NSCoding without subclassing from NSObject (notwithstanding other issues). Edit: it is a blocker because it does appear you need to inherit from NSObject to be codeable. |
Changing _cfTypeID to a function does not help. hidden symbol `_TFC10Foundation8NSObject9_cfTypeIDfT_Su' isn't defined |
I think the workaround would be temporarily making it |
Pull request coming up. I assume changing the visibility won't add storage requirements that would break CF bridging? |
We should probably make an additional bug to track making this API internal |
Going ahead and closing this since the original issue has been fixed. Thanks! |
> I think the workaround would be temporarily making it Is there a task tracking the underlying bug? swift-corelibs-xctest now has several variables marked as I couldn't find any existing bugs after a few searches, so I'm going to create my own--please point me to any existing issues if you know of them, though! |
I filed https://bugs.swift.org/browse/SR-1129 to track fixing the underlying cause of these workarounds. |
swift-corelibs-xctest continues to work around this issue; several access modifiers included in apple/swift-corelibs-xctest#109 have been marked I'd love it if someone could have a closer look at https://bugs.swift.org/browse/SR-1129 – it doesn't seem to be prioritized, but it causes us a lot of pain. If someone could chime in on that issue, either with a fix or with some pointers on where to start looking in order to diagnose the issue, that'd be much appreciated!! I added a test that demonstrates this issue to the Swift test suite in #2039 – it is fairly easy to reproduce. 🙂 |
Environment
OS: Ubuntu 14.04
Swift version: Toolchain snapshot from December 10
Additional Detail from JIRA
md5: 3160ace0e7f5b64d6d2e37dcd2edff86
relates to:
Issue Description:
I am encountering an undefined symbol error when building an executable which contains an NSObject subclass. A minimal example is:
When that code is put into main.swift and an empty Package.swift, running the build tool creates the following output:
Note that the build succeeds if I only use NSObject subclasses that are defined in Foundation. The error only occurs when creating a new NSObject subclass in my code. The motivation for subclassing NSObject is to allow the code to compile unchanged on Mac and Linux.
It's not immediately obvious to me whether this is an bug with swift-package-manager generating an incorrect build command, a symbol visibility problem in swift-corelibs-foundation, or a linker issue.
The text was updated successfully, but these errors were encountered: