Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build static executable on Linux #3974

Open
2 tasks done
asponring opened this issue May 10, 2022 · 4 comments
Open
2 tasks done

Unable to build static executable on Linux #3974

asponring opened this issue May 10, 2022 · 4 comments
Labels
integration Issues related to integration of SwiftLint into toolchains.

Comments

@asponring
Copy link

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: 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.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
@dpatz
Copy link

dpatz commented Jul 6, 2022

I'm having the same issue, were you ever able to get this resolved?

@asponring
Copy link
Author

Thanks for asking, @dpatz. Unfortunately I'm still having the same issue.

@SimplyDanny SimplyDanny added the integration Issues related to integration of SwiftLint into toolchains. label Jul 31, 2023
@bradleymackey
Copy link
Contributor

I'm looking into creating a static binary as part of creating an arm64 linux build. We appear to currently be blocked on jpsim/Yams#429

@bradleymackey
Copy link
Contributor

Reproduction: produces the following build error on this branch when running: docker buildx build -t myswiftlint --platform=linux/arm64 .

 > [builder 5/5] RUN --mount=type=cache,target=/workspace/.build,id=build-linux/arm64   ./tools/build-linux-release.sh &&       cp /workspace/.build/release/swiftlint /workspace:
1.435 Building for production...
2.939 [0/5] Write swift-version-24593BA9C3E375BF.txt
3.624 [2/11] Compiling Yams Constructor.swift
3.624 /workspace/.build/checkouts/Yams/Sources/Yams/Representer.swift:23:8: error: no such module 'Glibc'
3.624  21 | #else
3.624  22 | import CoreFoundation
3.624  23 | import Glibc
3.624     |        `- error: no such module 'Glibc'
3.624  24 | private let cpow: (_: Double, _: Double) -> Double = Glibc.pow
3.624  25 | #endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration Issues related to integration of SwiftLint into toolchains.
Projects
None yet
Development

No branches or pull requests

4 participants