Skip to content

[Runtime] Look up Error bridging symbols indirectly through special symbols that won't be stripped in static builds. #16677

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

Merged
merged 2 commits into from
May 18, 2018

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented May 17, 2018

This fixes a problem where error bridging didn't work in stripped executables using the static versions of the Swift libraries. ErrorObject.mm looks up some symbols with dlsym, but stripping makes it so it can't find those. This change makes a separate set of symbols explicitly made for ErrorObject.mm to look up, and marks them as dynamically referenced so stripping won't remove them. Longer term, we'd like a better solution for looking up these symbols, but this will do for now.

rdar://problem/39810532

…ymbols that won't be stripped in static builds.

This fixes a problem where error bridging didn't work in stripped executables using the static versions of the Swift libraries. ErrorObject.mm looks up some symbols with dlsym, but stripping makes it so it can't find those. This change makes a separate set of symbols explicitly made for ErrorObject.mm to look up, and marks them as dynamically referenced so stripping won't remove them. Longer term, we'd like a better solution for looking up these symbols, but this will do for now.

rdar://problem/39810532
@mikeash mikeash requested a review from jckarter May 17, 2018 16:11
@mikeash
Copy link
Contributor Author

mikeash commented May 17, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3cc86eb

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Mike!

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3cc86eb

@mikeash
Copy link
Contributor Author

mikeash commented May 17, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3cc86eb

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3cc86eb

@mikeash
Copy link
Contributor Author

mikeash commented May 17, 2018

@swift-ci Please test OS X platform

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an end-to-end test that actually strips a binary and checks the test.

@mikeash
Copy link
Contributor Author

mikeash commented May 17, 2018

@gottesmm ErrorBridgedStatic.swift does this. The previous test didn't quite exercise the machinery enough to catch the problem, but I added another test that does.

@gottesmm
Copy link
Contributor

I.e. we have functionality that actually strips the binary and then runs the test?

@mikeash
Copy link
Contributor Author

mikeash commented May 17, 2018

That's right. It doesn't show up in the diffs because it was already there from before, but ErrorBridgedStatic.swift strips the test executable before running it. You can see it here:

https://github.com/mikeash/swift/blob/177f34cd0edfa8583a608cf084f3e95c9a9ddf1d/test/stdlib/ErrorBridgedStatic.swift#L4

I also confirmed that the test fails without my fix.

@gottesmm
Copy link
Contributor

k SGTM.

@mikeash
Copy link
Contributor Author

mikeash commented May 18, 2018

Cheers, thanks for the double check.

@mikeash mikeash merged commit 55fc2b0 into swiftlang:master May 18, 2018
@benlangmuir
Copy link
Contributor

This has appears to be crashing some tests (rdar://problem/40378113) I'm going to revert.

lorentey added a commit to lorentey/swift that referenced this pull request Dec 10, 2019
To implement swift_errorBridgingInfo, the Foundation overlay needs to import private runtime headers. Now that we cannot statically link the Foundation overlay, there is no point to keeping this workaround in the overlay any more.

This effectively reverts swiftlang#16677.

rdar://problem/57809306
millenomi pushed a commit to swiftlang/swift-corelibs-foundation that referenced this pull request Nov 11, 2020
To implement swift_errorBridgingInfo, the Foundation overlay needs to import private runtime headers. Now that we cannot statically link the Foundation overlay, there is no point to keeping this workaround in the overlay any more.

This effectively reverts swiftlang/swift#16677.

rdar://problem/57809306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants