Skip to content

Update sdkRootPath to be optional in swift-sdk.json #2888

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcprux
Copy link
Contributor

In swiftlang/swift-package-manager#8687 we make sdkRootPath an optional field of swift-sdk.json.

@finagolfin
Copy link
Member

Maybe mention the new sdk configure option you're adding in swiftlang/swift-package-manager#8856 too?

MaxDesiatov added a commit to swiftlang/swift-package-manager that referenced this pull request Jul 13, 2025
You can now run `swift sdk configure --sdk-root-path /some/sdk/root
sdk-id` without needing to specify the target triple

### Motivation:

The Android SDK
(swiftlang/swift#80788 (comment))
needs to have its `sdkRootPath` configured to point to an external NDK
sysroot. But it contains many different target triples, like
`armv7-unknown-linux-androideabi33` and
`x86_64-unknown-linux-android29`, all of which need to be configured to
point to the same sysroot. Following on to
#8687 and
swiftlang/swift-evolution#2888, this PR enables
running a single command to configure the entire SDK, like so:

```
swift run swift-sdk configure --sdk-root-path ~/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot swift-6.1-RELEASE-android-24-0.1
```

This will result in configurations being created for each of the target
triples for the SDK ID.

<details>

```
% swift run swift-sdk configure --sdk-root-path ~/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot swift-6.1-RELEASE-android-24-0.1
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi29` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android29` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android29` were successfully updated: sdkRootPath.

% ls ~/Library/org.swift.swiftpm/swift-sdks/configuration/
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android24.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android25.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android26.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android27.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android28.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android29.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android30.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android31.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android32.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android33.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android34.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android35.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi24.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi25.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi26.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi27.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi28.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi29.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi30.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi31.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi32.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi33.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi34.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi35.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android24.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android25.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android26.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android27.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android28.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android29.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android30.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android31.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android32.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android33.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android34.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android35.json

% cat ~/Library/org.swift.swiftpm/swift-sdks/configuration/swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android31.json
{
  "sdkRootPath" : "/Users/marc/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot",
  "swiftResourcesPath" : "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/android-27c-sysroot/usr/lib/swift",
  "swiftStaticResourcesPath" : "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/android-27c-sysroot/usr/lib/swift_static-x86_64",
  "toolsetPaths" : [
    "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/swift-toolset.json"
  ]
}
```
</details>

In addition, this fixes
#8584, where
`swift sdk configure` with a specified target triple didn't work at all,
and instead would configure some random target triple for the specified
SDK.

### Modifications:

Make the `targetTriple` flag for `ConfigureSwiftSDK` optional and, when
nil, apply the command to all triples included in the specified SDK.

### Result:

Fixes #8584 and
enables configuring multiple target triples with a single `swift sdk
configure` command.

---------

Co-authored-by: Max Desiatov <[email protected]>
@finagolfin
Copy link
Member

finagolfin commented Jul 16, 2025

@MaxDesiatov, now that the pull has been merged, do you know who has to sign off on this accompanying proposal change?

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Jul 17, 2025

Would you be able to announce these changes in "Evolution | Discussion" category on Swift Forums so that interested parties could look into it?

marcprux added a commit to swift-everywhere/swift-package-manager that referenced this pull request Jul 18, 2025
…#8856)

You can now run `swift sdk configure --sdk-root-path /some/sdk/root
sdk-id` without needing to specify the target triple

The Android SDK
(swiftlang/swift#80788 (comment))
needs to have its `sdkRootPath` configured to point to an external NDK
sysroot. But it contains many different target triples, like
`armv7-unknown-linux-androideabi33` and
`x86_64-unknown-linux-android29`, all of which need to be configured to
point to the same sysroot. Following on to
swiftlang#8687 and
swiftlang/swift-evolution#2888, this PR enables
running a single command to configure the entire SDK, like so:

```
swift run swift-sdk configure --sdk-root-path ~/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot swift-6.1-RELEASE-android-24-0.1
```

This will result in configurations being created for each of the target
triples for the SDK ID.

<details>

```
% swift run swift-sdk configure --sdk-root-path ~/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot swift-6.1-RELEASE-android-24-0.1
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi29` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android29` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android29` were successfully updated: sdkRootPath.

% ls ~/Library/org.swift.swiftpm/swift-sdks/configuration/
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android24.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android25.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android26.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android27.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android28.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android29.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android30.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android31.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android32.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android33.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android34.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android35.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi24.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi25.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi26.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi27.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi28.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi29.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi30.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi31.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi32.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi33.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi34.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi35.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android24.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android25.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android26.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android27.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android28.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android29.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android30.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android31.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android32.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android33.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android34.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android35.json

% cat ~/Library/org.swift.swiftpm/swift-sdks/configuration/swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android31.json
{
  "sdkRootPath" : "/Users/marc/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot",
  "swiftResourcesPath" : "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/android-27c-sysroot/usr/lib/swift",
  "swiftStaticResourcesPath" : "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/android-27c-sysroot/usr/lib/swift_static-x86_64",
  "toolsetPaths" : [
    "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/swift-toolset.json"
  ]
}
```
</details>

In addition, this fixes
swiftlang#8584, where
`swift sdk configure` with a specified target triple didn't work at all,
and instead would configure some random target triple for the specified
SDK.

Make the `targetTriple` flag for `ConfigureSwiftSDK` optional and, when
nil, apply the command to all triples included in the specified SDK.

Fixes swiftlang#8584 and
enables configuring multiple target triples with a single `swift sdk
configure` command.

---------

Co-authored-by: Max Desiatov <[email protected]>
(cherry picked from commit 69f851d)
@marcprux
Copy link
Contributor Author

Would you be able to announce these changes in "Evolution | Discussion" category on Swift Forums so that interested parties could look into it?

I've stated a thread about it at https://forums.swift.org/t/change-in-optionality-of-sdkrootpath-property-of-swift-sdk-json-for-cross-compilation-sdks/81175

finagolfin pushed a commit to swiftlang/swift-package-manager that referenced this pull request Jul 19, 2025
You can now run `swift sdk configure --sdk-root-path /some/sdk/root
sdk-id` without needing to specify the target triple

The Android SDK
(swiftlang/swift#80788 (comment))
needs to have its `sdkRootPath` configured to point to an external NDK
sysroot. But it contains many different target triples, like
`armv7-unknown-linux-androideabi33` and
`x86_64-unknown-linux-android29`, all of which need to be configured to
point to the same sysroot. Following on to
#8687 and
swiftlang/swift-evolution#2888, this PR enables
running a single command to configure the entire SDK, like so:

```
swift run swift-sdk configure --sdk-root-path ~/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot swift-6.1-RELEASE-android-24-0.1
```

This will result in configurations being created for each of the target
triples for the SDK ID.

<details>

```
% swift run swift-sdk configure --sdk-root-path ~/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot swift-6.1-RELEASE-android-24-0.1
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi29` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android29` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android25` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android26` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android33` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi32` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android35` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android24` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `x86_64-unknown-linux-android28` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi27` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android30` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi34` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `armv7-unknown-linux-androideabi31` were successfully updated: sdkRootPath.
info: These properties of Swift SDK `swift-6.1-RELEASE-android-24-0.1` for target triple `aarch64-unknown-linux-android29` were successfully updated: sdkRootPath.

% ls ~/Library/org.swift.swiftpm/swift-sdks/configuration/
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android24.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android25.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android26.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android27.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android28.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android29.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android30.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android31.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android32.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android33.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android34.json
swift-6.1-RELEASE-android-24-0.1_aarch64-unknown-linux-android35.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi24.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi25.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi26.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi27.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi28.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi29.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi30.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi31.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi32.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi33.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi34.json
swift-6.1-RELEASE-android-24-0.1_armv7-unknown-linux-androideabi35.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android24.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android25.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android26.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android27.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android28.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android29.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android30.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android31.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android32.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android33.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android34.json
swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android35.json

% cat ~/Library/org.swift.swiftpm/swift-sdks/configuration/swift-6.1-RELEASE-android-24-0.1_x86_64-unknown-linux-android31.json
{
  "sdkRootPath" : "/Users/marc/Library/Android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/darwin-x86_64/sysroot",
  "swiftResourcesPath" : "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/android-27c-sysroot/usr/lib/swift",
  "swiftStaticResourcesPath" : "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/android-27c-sysroot/usr/lib/swift_static-x86_64",
  "toolsetPaths" : [
    "/Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1-RELEASE-android-24-0.1.artifactbundle/swift-6.1-release-android-24-sdk/swift-toolset.json"
  ]
}
```
</details>

In addition, this fixes
#8584, where
`swift sdk configure` with a specified target triple didn't work at all,
and instead would configure some random target triple for the specified
SDK.

Make the `targetTriple` flag for `ConfigureSwiftSDK` optional and, when
nil, apply the command to all triples included in the specified SDK.

Fixes #8584 and
enables configuring multiple target triples with a single `swift sdk
configure` command.

---------

Co-authored-by: Max Desiatov <[email protected]>
(cherry picked from commit 69f851d)
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.

3 participants