Skip to content
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-1901] Linker error "hidden symbol" on subclassing Thread #4133

Closed
ankitspd opened this issue Jun 25, 2016 · 13 comments
Closed

[SR-1901] Linker error "hidden symbol" on subclassing Thread #4133

ankitspd opened this issue Jun 25, 2016 · 13 comments

Comments

@ankitspd
Copy link
Member

Previous ID SR-1901
Radar None
Original Reporter @aciidb0mb3r
Type Bug
Status Resolved
Resolution Done
Environment

Linux

Additional Detail from JIRA
Votes 1
Component/s Foundation, XCTest
Labels Bug
Assignee @eeckstein
Priority Medium

md5: b317e664abb519336896529a6617e8d9

relates to:

  • SR-1129 Linker step fails when subclassing a class with a 'public private(set) var'
  • SR-2170 Linux Linker error when deriving a class from NSURL

Issue Description:

This code produces a linker error on Linux:

import class Foundation.Thread

class Thread: Foundation.Thread {
}
$ swiftc Thread.swift
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadg5_mainFT_T_' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threads5_mainFT_T_' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadm5_mainFT_T_' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6ThreadgP33_513815EE0AA0753AFF631398622CF9397_threadSu' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6ThreadsP33_513815EE0AA0753AFF631398622CF9397_threadSu' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6ThreadmP33_513815EE0AA0753AFF631398622CF9397_threadSu' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadg5_attrVSC14pthread_attr_t' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threads5_attrVSC14pthread_attr_t' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadm5_attrVSC14pthread_attr_t' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadg7_statusOS_15_NSThreadStatus' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threads7_statusOS_15_NSThreadStatus' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadm7_statusOS_15_NSThreadStatus' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadg10_cancelledSb' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threads10_cancelledSb' is not defined locally
/usr/bin/ld.gold: error: hidden symbol '_TFC10Foundation6Threadm10_cancelledSb' is not defined locally
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

However no error if ran as a script:
$ swift Thread.swift
<no error>

@ddunbar
Copy link
Member

ddunbar commented Jun 25, 2016

I'm not sure what is happening here – I think this could be a compiler issue or an issue with how Foundation is building itself.

/cc @jckarter @rjmccall

@modocache
Copy link
Mannequin

modocache mannequin commented Jun 27, 2016

Thanks for linking https://bugs.swift.org/browse/SR-1129 to this report. I'd love to see this issue resolved – swift-corelibs-xctest is unable to deliver on its promise of API parity with Apple XCTest due to this.

Be sure to check out apple/swift#2039 for a failing test demonstrating the problem.

@rjmccall
Copy link
Member

Looks like some code is getting the SIL linkage wrong for the getters and setters in the v-table.

@modocache
Copy link
Mannequin

modocache mannequin commented Sep 21, 2016

Another example of this affecting corelibs API: #651

@jckarter
Copy link
Member

@rjmccall At least some of those symbols include private discriminators. It looks like we try to directly reference inherited private/internal vtable entries from the parent class in the subclass's vtable, which is of course totally unworkable. Foundation might be able to work around this by making the affected properties final, if possible.

@modocache
Copy link
Mannequin

modocache mannequin commented Sep 21, 2016

Thanks for the workaround suggestion! I tried using it for XCTest here (still waiting on CI results): apple/swift-corelibs-xctest#173

The workaround doesn't cover all cases, unfortunately. For example, XCTest has properties that have public getters, private setters, and (for the sake of API parity of Objective-C XCTest) can be overridden: https://github.com/apple/swift-corelibs-xctest/blob/3b6c476eccee86b92f215257147a5f8d0aed3ba4/Sources/XCTest/Public/XCAbstractTest.swift#L37-L42. Since these are open, they cannot also be marked final.

@eeckstein
Copy link
Member

I'm working on it.

@eeckstein
Copy link
Member

fixed in fd61338444ac42d8715fd9e637b238e035f17f8d

@modocache
Copy link
Mannequin

modocache mannequin commented Sep 23, 2016

Awesome![]( Thanks for the quick turnaround) Submitting a fix for the public symbols in XCTest now.

@parkera
Copy link
Member

parkera commented Sep 23, 2016

Thanks Erik!

@swift-ci
Copy link
Contributor

Comment by David Grove (JIRA)

Hi Erik

Can we get this fix into the Swift3 branch as well? I just tried against swift-3.0.1-PREVIEW-3-ubuntu16.04 and the bug is still there.

@eeckstein
Copy link
Member

I cherry picked it into swift 3 a few days ago, so it should be on the way.
(Sorry for not doing it earlier)

@swift-ci
Copy link
Contributor

Comment by David Grove (JIRA)

Great, thanks! Sorry for not looking more closely at the Swift3 branch; missed that it was done already.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants