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

API for getting the full Swift version (as reported by swift --version) #75998

Open
grynspan opened this issue Aug 20, 2024 · 6 comments
Open
Labels
feature A feature request or implementation runtime The Swift Runtime standard library Area: Standard library umbrella triage needed This issue needs more specific labels

Comments

@grynspan
Copy link
Contributor

Motivation

Swift Testing needs to be able to report the full Swift version (as reported by swift --version) for diagnostic purposes, e.g. when reading logs produced by a CI job or another engineer or in a different configuration. This version information is immensely useful when filing bug reports because it allows us to immediately see "oh, it was the [e.g.] August 9th nightly main-branch toolchain where the bug occurred" and so on.

Proposed solution

I'd like to propose we add API to the Swift standard library that vends a "human-readable" string equivalent to the aforementioned one. Something like this would be sufficient:

/// The human-readable version of the standard library.
///
/// Rabble rabble details details nuances nuances.
public var standardLibraryVersion: String { get }

Alternatives considered

  • An internal-only, C/C++, or SPI function could also work, but as it wouldn't be API, developers not working on the Swift project wouldn't be able to use it.
  • A more complex interface with configuration options is probably overkill.

Additional information

No response

@grynspan grynspan added feature A feature request or implementation standard library Area: Standard library umbrella runtime The Swift Runtime triage needed This issue needs more specific labels labels Aug 20, 2024
@grynspan
Copy link
Contributor Author

Also, Swift Package Manager could adopt the same API so that it doesn't need to fake it for subcommands like swift test --version (which produce very different strings.)

@hassila
Copy link

hassila commented Aug 23, 2024

This would also be great of benchmarks to print out, we got this issue filed that we can't currently nicely solve without proper API:

ordo-one/package-benchmark#213

@JaapWijnen
Copy link
Contributor

Wouldn't it also be nice if this was available at compile time somehow? To be used in compiler directives like #if perhaps?

@grynspan
Copy link
Contributor Author

That would be feasible if it were exposed as a string literal macro, I think.

@Azoy
Copy link
Contributor

Azoy commented Dec 3, 2024

The version of the standard library is very independent from what the compiler's version is from e.g. swift --version.

@grynspan
Copy link
Contributor Author

grynspan commented Dec 4, 2024

That's fair enough. We're specifically interested in the more verbose version info here as it's very helpful for triaging bug reports down to specific commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation runtime The Swift Runtime standard library Area: Standard library umbrella triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

4 participants