-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Unable to build static executable on Linux #3974
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
I am unable to build a fully static / standalone executable of SwiftLint for Linux. SwiftLint works fine on Linux for me as long as Swift is installed, but I need a version that works on Linux even if Swift is not installed.
There are previously opened issues that pertain to standalone versions of SwiftLint (#302 and #731), but they are quite old at this point. This comment mentions that the blocker to supporting this was having SourceKit included in Linux versions of Swift - which is now resolved according to this ticket: swiftlang/swift#8189.
Yet I still get an error every time I try to build a statically executable binary. The below output shows me using swift build on a Linux machine with the standard build flags --configuration release -Xlinker -dead_strip, adding -Xswiftc -static-executable to ensure it's a static binary. The error shows up at the bottom. I'm using the latest versions of Swift and SwiftLint - see environment details at the bottom.
Is some additional step needed to get this to work or is it simply not possible as things currently are? Thanks in advance.
~/SwiftLint$ swift build --configuration release -Xlinker -dead_strip -Xswiftc -static-executable
Fetching https://github.com/jpsim/Yams.git
Fetching https://github.com/apple/swift-syntax.git
Fetching https://github.com/jpsim/SourceKitten.git
[28924/28924] Fetching objects
Fetched https://github.com/apple/swift-syntax.git (0.90s)
Fetching https://github.com/apple/swift-argument-parser.git
Fetched https://github.com/jpsim/SourceKitten.git (0.91s)
Fetching https://github.com/scottrhoyt/SwiftyTextTable.git
Fetched https://github.com/jpsim/Yams.git (0.92s)
Fetching https://github.com/drmohundro/SWXMLHash.git
[2903/3567] Fetching objectsFetched https://github.com/scottrhoyt/SwiftyTextTable.git (0.18s)
[2957/3567] Fetching objectsFetching https://github.com/krzyzanowskim/CryptoSwift.git
[3567/3567] Fetching objects
Fetched https://github.com/drmohundro/SWXMLHash.git (0.25s)
[11878/19984] Fetching objectsFetched https://github.com/apple/swift-argument-parser.git (0.60s)
[19984/19984] Fetching objects
Fetched https://github.com/krzyzanowskim/CryptoSwift.git (0.96s)
Computing version for https://github.com/krzyzanowskim/CryptoSwift.git
Computed https://github.com/krzyzanowskim/CryptoSwift.git at 1.4.3 (0.17s)
Computing version for https://github.com/scottrhoyt/SwiftyTextTable.git
Computed https://github.com/scottrhoyt/SwiftyTextTable.git at 0.9.0 (0.57s)
Computing version for https://github.com/jpsim/Yams.git
Computed https://github.com/jpsim/Yams.git at 4.0.6 (0.16s)
Computing version for https://github.com/jpsim/SourceKitten.git
Computed https://github.com/jpsim/SourceKitten.git at 0.32.0 (0.17s)
Computing version for https://github.com/apple/swift-syntax.git
Computed https://github.com/apple/swift-syntax.git at 0.50600.1 (0.36s)
Computing version for https://github.com/apple/swift-argument-parser.git
Computed https://github.com/apple/swift-argument-parser.git at 1.0.3 (0.17s)
Computing version for https://github.com/drmohundro/SWXMLHash.git
Computed https://github.com/drmohundro/SWXMLHash.git at 6.0.0 (0.16s)
Creating working copy for https://github.com/scottrhoyt/SwiftyTextTable.git
Working copy of https://github.com/scottrhoyt/SwiftyTextTable.git resolved at 0.9.0
Creating working copy for https://github.com/drmohundro/SWXMLHash.git
Working copy of https://github.com/drmohundro/SWXMLHash.git resolved at 6.0.0
Creating working copy for https://github.com/apple/swift-syntax.git
Working copy of https://github.com/apple/swift-syntax.git resolved at 0.50600.1
Creating working copy for https://github.com/jpsim/Yams.git
Working copy of https://github.com/jpsim/Yams.git resolved at 4.0.6
Creating working copy for https://github.com/jpsim/SourceKitten.git
Working copy of https://github.com/jpsim/SourceKitten.git resolved at 0.32.0
Creating working copy for https://github.com/krzyzanowskim/CryptoSwift.git
Working copy of https://github.com/krzyzanowskim/CryptoSwift.git resolved at 1.4.3
Creating working copy for https://github.com/apple/swift-argument-parser.git
Working copy of https://github.com/apple/swift-argument-parser.git resolved at 1.0.3
Building for production...
/home/ubuntu/SwiftLint/.build/checkouts/swift-syntax/Sources/SwiftSyntaxParser/CNodes.swift:13:29: error: no such module '_InternalSwiftSyntaxParser'
@_implementationOnly import _InternalSwiftSyntaxParser
^
[27/29] Archiving libSwiftSyntax.aEnvironment
- SwiftLint version - Current (0.47.1)
- Installation method used - build from source
- Swift version - Current (5.6.1)
- Ubuntu version - 20.04
- Architecture - x86