realm / realm/SwiftLint

Unable to build static executable on Linux

Open
#3,974 5 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

integration resolved
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
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: https://github.com/apple/swift/pull/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.a
Environment
  • SwiftLint version - Current (0.47.1)
  • Installation method used - build from source
  • Swift version - Current (5.6.1)
  • Ubuntu version - 20.04
  • Architecture - x86

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported command with Swift 5.6.1 on Ubuntu 20.04 and inspect the failure in .build/checkouts/swift-syntax/Sources/SwiftSyntaxParser/CNodes.swift. Trace the static-build dependency setup, especially the missing _InternalSwiftSyntaxParser module. Done means SwiftLint builds as a standalone Linux executable without Swift installed.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, swift
Domain
build-system, devtools, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.