swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
713 stars 47 forks source link

Cross compiling on linux #733

Closed santalvarez closed 3 months ago

santalvarez commented 3 months ago

Hi, Im trying to compile a swift project for the armv7-none-none-eabi target. The problem Im having is that I'm on linux and the extension keeps compiling for x86_64-unknown-linux-gnu target. I have tried setting the -target flag but I doesn't seem to have an effect.

Maybe Im missing something but is there a way to prevent the extension from defaulting to the current target or is cross compiling not supported yet?

adam-fowler commented 3 months ago

How are you adding the --target argument?

santalvarez commented 3 months ago

Like this :

    "swift.sourcekit-lsp.serverArguments": [
        "-Xswiftc", "-target", "-Xswiftc", "armv7-none-none-eabi"
    ]

I can compile with no problems from the command line with:

swift build --triple armv7-none-none-eabi

I tried using --triple and --target but it always defaults to the host's target.

adam-fowler commented 3 months ago

Go to the settings and add to the Swift: Build Arguments.