Skip to content

Missing --target triple validation on make-linux-sdk command #239

@xtremekforever

Description

@xtremekforever

I found that it's totally possible to create an invalid Swift SDK by passing an incomplete triple to --target, like this:

swift run swift-sdk-generator make-linux-sdk --target aarch64

This generates a swift-sdk.json file with an invalid triple:

{
  "schemaVersion" : "4.0",
  "targetTriples" : {
    "aarch64" : {
      "sdkRootPath" : "ubuntu-jammy.sdk",
      "swiftResourcesPath" : "ubuntu-jammy.sdk/usr/lib/swift",
      "swiftStaticResourcesPath" : "ubuntu-jammy.sdk/usr/lib/swift_static",
      "toolsetPaths" : [
        "toolset.json"
      ]
    }
  }
}

No warning is thrown and it takes the invalid triple like a champ. This Swift SDK fails to cross-compile properly as the compiler doesn't quite know what platform we're trying to use. At a minimum the triple should contain:

  • arch: aarch64
  • platform: linux- this should be enforced for make-linux-sdk.
  • abi: gnu, gnueabihf, etc

We should validate the triple that is passed to ensure we have the right fields, and throw an error if an incomplete triple is passed at the CLI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions