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

Statically Linked Binary #1951

Merged
merged 11 commits into from
Nov 20, 2017
Merged

Statically Linked Binary #1951

merged 11 commits into from
Nov 20, 2017

Conversation

norio-nomura
Copy link
Collaborator

Use swift build --configuration release --static-swift-stdlib for building swiftlint

@jpsim
Copy link
Collaborator

jpsim commented Nov 17, 2017

You have to run swift build -c release -Xswiftc -static-stdlib because --static-swift-stdlib is broken in current 4.x releases of Swift.

Should be fixed in future releases that include apple/swift-package-manager#1320 though.

@codecov-io
Copy link

codecov-io commented Nov 17, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@a03f8f8). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1951   +/-   ##
=========================================
  Coverage          ?   88.79%           
=========================================
  Files             ?      245           
  Lines             ?    11920           
  Branches          ?        0           
=========================================
  Hits              ?    10584           
  Misses            ?     1336           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a03f8f8...7d1b401. Read the comment docs.

@jpsim
Copy link
Collaborator

jpsim commented Nov 17, 2017

Can you explain why this is marked as WIP?

@norio-nomura
Copy link
Collaborator Author

I expected to be able to install with make install on Linux, but make install is still failing on Linux:

Linking ./.build/x86_64-unknown-linux/release/swiftlint
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/usr/bin/ld.gold: error: cannot find -ldispatch
/SwiftLint/.build/x86_64-unknown-linux/release/SourceKittenFramework.build/Request.swift.o:/SwiftLint/.build/x86_64-unknown-linux/release/SourceKittenFramework.build/Xcode.swift.o:function globalinit_33_B1AC82A8F682C055F79D1482C920A189_func75: error: undefined reference to '_NSConcreteStackBlock'
/SwiftLint/.build/x86_64-unknown-linux/release/SourceKittenFramework.build/Request.swift.o:/SwiftLint/.build/x86_64-unknown-linux/release/SourceKittenFramework.build/Xcode.swift.o:function globalinit_33_B1AC82A8F682C055F79D1482C920A189_func75: error: undefined reference to '_Block_copy'
/SwiftLint/.build/x86_64-unknown-linux/release/SourceKittenFramework.build/Request.swift.o:/SwiftLint/.build/x86_64-unknown-linux/release/SourceKittenFramework.build/Xcode.swift.o:function globalinit_33_B1AC82A8F682C055F79D1482C920A189_func75: error: undefined reference to '_Block_release'
…

@norio-nomura
Copy link
Collaborator Author

Can you explain why this is marked as WIP?

It also changed to using /usr/bin/install instead of cp, and I'm still testing this for Homebrew.

@norio-nomura
Copy link
Collaborator Author

Using following patch for Formula/swiftlint.rb:

diff --git a/Formula/swiftlint.rb b/Formula/swiftlint.rb
index 867b09adc..f4d426cb7 100644
--- a/Formula/swiftlint.rb
+++ b/Formula/swiftlint.rb
@@ -4,7 +4,7 @@ class Swiftlint < Formula
   url "https://github.com/realm/SwiftLint.git",
       :tag => "0.24.0",
       :revision => "06ece1ea8dbeb3bc421e54f907e906cac32038d5"
-  head "https://github.com/realm/SwiftLint.git"
+  head "https://github.com/realm/SwiftLint.git", :branch => "nn-single-binary"
 
   bottle do
     cellar :any

Installing by Homebrew:

$ brew install --HEAD swiftlint
==> Cloning https://github.com/realm/SwiftLint.git
Updating /Users/norio/Library/Caches/Homebrew/swiftlint--git
==> Checking out branch nn-single-binary
Synchronizing submodule url for 'Carthage/Checkouts/Nimble'
Synchronizing submodule url for 'Carthage/Checkouts/Quick'
Synchronizing submodule url for 'Carthage/Checkouts/Result'
Synchronizing submodule url for 'Carthage/Checkouts/xcconfigs'
Synchronizing submodule url for 'Externals/Nimble'
Synchronizing submodule url for 'Carthage/Checkouts/Commandant'
Synchronizing submodule url for 'Carthage/Checkouts/Result'
Synchronizing submodule url for 'Carthage/Checkouts/SWXMLHash'
Synchronizing submodule url for 'Carthage/Checkouts/Yams'
Synchronizing submodule url for 'Carthage/Checkouts/xcconfigs'
Synchronizing submodule url for 'Carthage/Checkouts/Nimble'
Synchronizing submodule url for 'Carthage/Checkouts/Quick'
Synchronizing submodule url for 'Carthage/Checkouts/Result'
Synchronizing submodule url for 'Carthage/Checkouts/xcconfigs'
Synchronizing submodule url for 'Externals/Nimble'
==> make prefix_install PREFIX=/usr/local/Cellar/swiftlint/HEAD-745fc95 TEMPORARY_FOLDER=/private/tmp/swiftlint-20171117-4617-12638j/SwiftLint.dst
🍺  /usr/local/Cellar/swiftlint/HEAD-745fc95: 6 files, 15.4MB, built in 3 minutes 33 seconds
brew install --HEAD swiftlint  238.22s user 43.45s system 129% cpu 3:38.13 total

@norio-nomura norio-nomura changed the title [WIP] Single Binary Single Binary Nov 17, 2017
@norio-nomura
Copy link
Collaborator Author

For now, I am giving up make install on Linux and removing WIP.

Makefile Outdated
install: uninstall package
sudo installer -pkg SwiftLint.pkg -target /
install:
swift package clean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go in clean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, clean was triggered by install > package > installables > clean.
I deleted those dependencies considering make install executing on Linux.
I put swift package clean here to get closer to the previous behavior, but that may not be necessary here. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only use test as a target that uses xcodebuild, we can change it to somewhat simpler one.

Change `all` target to execute `swift build` instead of `xcodebuild`.
@norio-nomura
Copy link
Collaborator Author

Updated.

@norio-nomura norio-nomura changed the title Single Binary Statically Linked Binary Nov 18, 2017
This makes `make install` possible on Linux.
@norio-nomura
Copy link
Collaborator Author

Added workaround for SR-6434 on Linux.

norio-nomura added a commit to jpsim/SourceKitten that referenced this pull request Nov 19, 2017
Copy link
Collaborator

@jpsim jpsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 excellent

@jpsim jpsim merged commit 9f3154e into master Nov 20, 2017
@jpsim jpsim deleted the nn-single-binary branch November 20, 2017 19:00
@norio-nomura
Copy link
Collaborator Author

Thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants