Skip to content

[TBDGen] Capture segment symbols are defined in & emit tbd-v5 format #69779

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 3 commits into from
Nov 14, 2023

Conversation

cyndyishida
Copy link
Contributor

TBD-v5 is the new json format for TBD files. One can view the format spec by running man tapi-tbd on any >=Xcode15 install. Because it captures the segment the symbols are defined in, to restore back information lost compared to binary dylibs, it is also now recorded for TBDGen in the compiler. This is a best effort, as there is no way to definitively know where the symbol ends up until after the linker has assembled the binary.

This patch also updates tests to

  1. add flags for required information to emit the tbd (install name)
  2. Use llvm tools that capture relevant information out of TBD files where possible (llvm-readtapi & llvm-nm)

Resolves: rdar://117604275

@cyndyishida
Copy link
Contributor Author

I expect some tests that invoke the Xcode toolchain linker to fail as Xcode14 is too old to read tbdv5. They should be resolved by: #69485

I can temporarily disable them, but I figure its better to get feedback first.

// RUN: %target-swift-frontend -typecheck %s -emit-tbd-path - -tbd-current-version 20.10 | %FileCheck %s --check-prefix TWENTYPOINTTEN
// RUN: %target-swift-frontend -typecheck %s -tbd-install_name some_dylib -emit-tbd-path - -tbd-current-version 2.0 | %FileCheck %s --check-prefix TWOPOINTZERO
// RUN: %target-swift-frontend -typecheck %s -tbd-install_name some_dylib -emit-tbd-path - -tbd-current-version 2 | %FileCheck %s --check-prefix TWOPOINTZERO
// RUN: %target-swift-frontend -typecheck %s -tbd-install_name some_dylib -emit-tbd-path - -tbd-current-version 20.10 | %FileCheck %s --check-prefix TWENTYPOINTTEN
Copy link
Contributor

Choose a reason for hiding this comment

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

I notice you're adding many -tbd-install_name to tests, is it a requirement to set it explicitly now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

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

LGTM!

@cyndyishida
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

Thank you, Cyndy!

@cyndyishida
Copy link
Contributor Author

@swift-ci please test

* Fixup tests to handle new json based output.
* Use llvm-nm & readtapi to verify tbd file outputs.

resolves: rdar://117604275
@cyndyishida
Copy link
Contributor Author

@swift-ci please test

@cyndyishida cyndyishida merged commit 831b098 into swiftlang:main Nov 14, 2023
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.

4 participants