swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.74k stars 1.34k forks source link

`--triple` option doesn't take installed Swift SDKs into account #7330

Open MaxDesiatov opened 9 months ago

MaxDesiatov commented 9 months ago

Description

It's confusing that the existing --triple option doesn't look at target triples of installed SDKs and seems to be completely detached from the Swift SDK infrastructure. We should be able to look at the list of installed SDKs and their supported target triples and select the SDK based on that. Probably for multiple Swift SDKs supporting the same target triple the CLI invocation should fail with an error message.

Expected behavior

swift build --triple wasm32-unknown-wasi picks up installed Swift SDK that supports triple.

Actual behavior

swift build --triple wasm32-unknown-wasi doesn't find the installed Swift SDK.

Steps to reproduce

  1. Install a Swift SDK that supports wasm32-unknown-wasi target triple
  2. Change current directory to the root directory of a package that you'd like to build.
  3. Run swift build --triple wasm32-unknown-wasi

Swift Package Manager version/commit hash

Swift Package Manager - Swift 5.11.0-dev

Swift & OS version (output of swift --version ; uname -a)

Swift version 5.11-dev (LLVM 87ace14daa2139a, Swift 8bb684628593220) Target: aarch64-unknown-linux-gnu

kateinoigakukun commented 9 months ago

I think we can filter non-compatible SDKs that contain swiftmodules compiled by different compiler version than the host one and don't contain compiler tools. If we apply such filter, we can get single SDK for most senario