Skip to content

[Driver/Frontend] Add -print-target-triple #28602

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
Dec 7, 2019

Conversation

DougGregor
Copy link
Member

Add a -print-target-triple command line option to the Swift frontend
and driver to allow other tools (e.g., SwiftPM) to query the host
triple as it is understood by the Swift compiler. This follows the
precedent set by Clang. Implements rdar://problem/57434967.

Add a -print-target-triple command line option to the Swift frontend
and driver to allow other tools (e.g., SwiftPM) to query the host
triple as it is understood by the Swift compiler. This follows the
precedent set by Clang. Implements rdar://problem/57434967.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@brentdax has requested that I also emit a second line containing the normalized triple used for modules (e.g., the result of calling getTargetSpecificModuleTriple). I'll do that before merging.

@DougGregor
Copy link
Member Author

getSwiftRuntimeCompatibilityVersionForTarget would also make sense. I should just emit some JSON from this

@beccadax beccadax self-requested a review December 6, 2019 21:32
…re info.

Rather than only emitting the target triple, provide additional
information about that particular target, including the module triple
(i.e., what file names will be used for Swift modules for that
triple), the runtime compatibility version if there is one, and
whether linking with rpaths is required for the standard library and
other libraries shipped with Swift. Encode this as JSON so we can
extend it in the future. For now, it looks like this:

```
{
  "target": {
    "triple": "arm64-apple-ios12.0",
    "moduleTriple": "arm64-apple-ios",
    "swiftRuntimeCompatibilityVersion": "5.0",
    "librariesRequireRPath": true
  }
}
```

Which you can deserialize into a TargetInfo instance as defined below:

```
struct Target: Codable {
  /// The target triple.
  var triple: String
  /// The triple used for module file names.
  var moduleTriple: String
  /// If this platform provides the Swift runtime, the Swift language
  version
  /// with which that runtime is compatible.
  var swiftRuntimeCompatibilityVersion: String?
  /// Whether linking against the Swift libraries requires the use of
  rpaths.
  var librariesRequireRPath: Bool
}

struct TargetInfo: Codable {
  var target: Target
}
```

Implements rdar://problem/47095159.
@DougGregor
Copy link
Member Author

For now, it looks like this:

{
  "target": {
    "triple": "arm64-apple-ios12.0",
    "moduleTriple": "arm64-apple-ios",
    "swiftRuntimeCompatibilityVersion": "5.0",
    "librariesRequireRPath": true
  }
}

Which you can deserialize into a TargetInfo instance as defined below:

struct Target: Codable {
  /// The target triple.
  var triple: String
  /// The triple used for module file names.
  var moduleTriple: String
  /// If this platform provides the Swift runtime, the Swift language
  version
  /// with which that runtime is compatible.
  var swiftRuntimeCompatibilityVersion: String?
  /// Whether linking against the Swift libraries requires the use of
  rpaths.
  var librariesRequireRPath: Bool
}

struct TargetInfo: Codable {
  var target: Target
}

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

I’ll start by merging this. I might add some more info afterward

@DougGregor DougGregor merged commit 179e3c2 into swiftlang:master Dec 7, 2019
@DougGregor DougGregor deleted the print-target-triple branch December 7, 2019 20:58
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.

1 participant