Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Build fully static compiler binary using ghc-musl#4573

Merged
purefunctor merged 24 commits intomasterpurescript/purescript:masterfrom
justin/ghc-muslpurescript/purescript:justin/ghc-muslCopy head branch name to clipboard
Jun 27, 2025
Merged

Build fully static compiler binary using ghc-musl#4573
purefunctor merged 24 commits intomasterpurescript/purescript:masterfrom
justin/ghc-muslpurescript/purescript:justin/ghc-muslCopy head branch name to clipboard

Conversation

@purefunctor
Copy link
Member

@purefunctor purefunctor commented Apr 9, 2025

Description of the change

Closes #4572.


Checklist:

  • Added a file to CHANGELOG.d for this PR (see CHANGELOG.d/README.md)
  • Added myself to CONTRIBUTORS.md (if this is my first contribution)
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@purefunctor
Copy link
Member Author

purefunctor commented Apr 16, 2025

Next task to do on my end is to verify the licenses of the various dependencies that we're using to make sure that we can statically link against them. I'm on a Mac at the moment so I can't test the static build of the compiler on the daily but it passing all tests and building the package set is very promising.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@benz0li
Copy link

benz0li commented Apr 23, 2025

@purefunctor Regarding statically linked Linux binaries:

GMP licensing restrictions

The regular GHC musl images produce binaries linked against the GNU Multiple Precision Arithmetic Library (GMP), which is used by default by the integer-gmp library to provide a big-integer implementation for Haskell.

Unlike most Haskell code, which is licensed under the permissive BSD3 license, the GMP library is licensed under LGPL. This means resulting statically linked binaries must be provided with source code or object files.

If that is not acceptable for your situation, use images with the int-native subtag. These images provide a GHC that links against the Haskell-native big-integer backend and produces statically linked binaries that and are not
subject to GMP's licensing restrictions.
ℹ️ Available for versions 9.6.7, 9.8.4, 9.10.1, 9.12.2 and later.

https://github.com/benz0li/ghc-musl#gmp-licensing-restrictions

Cross reference:

  • FAQ - The Haskell Tool Stack > What is licensing restrictions on Windows?

  • https://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynamic

    Does the LGPL have different requirements for statically vs dynamically linked modules with a covered work?
    For the purpose of complying with the LGPL (any extant version: v2, v2.1 or v3):

    (1) If you statically link against an LGPLed library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.

    (2) If you dynamically link against an LGPLed library already present on the user's computer, you need not convey the library's source. [...]

@purefunctor
Copy link
Member Author

Hi @benz0li, many thanks for the information about licensing and apologies for the late response.

Following suit from stack and pandoc, I believe the next steps would be:

  • to specify that Linux builds may statically link against GMP
  • to add a copy of LGPL/GPL to the LICENSE file
  • to specify links for the compiler's and GMP's source code

After which we should be ready to distribute statically-linked binaries.

Thoughts on this @rhendric @f-f ?

@f-f
Copy link
Member

f-f commented Jun 8, 2025

@purefunctor very happy to have static binaries 😄

@purefunctor
Copy link
Member Author

This PR is now ready for review! I'm also happy to take on updating https://github.com/purescript/npm-installer (and other distributions) to point to the new static binaries.

Copy link
Member Author

@purefunctor purefunctor left a comment

Choose a reason for hiding this comment

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

Added comments on a few points of discussion

build --fast --ghc-options -fwrite-ide-info

- run: "ci/fix-home stack exec weeder"
- run: "ci/fix-home stack exec weeder -- --hie-directory .stack-work"
Copy link
Member Author

Choose a reason for hiding this comment

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

weeder-2.8.0 seemed to have been reliant on a bug that matched . directories by default. See context here

# We test with --haddock because haddock generation can fail if there is invalid doc-comment syntax,
# and these failures are very easy to miss otherwise.
STACK="stack --no-terminal --haddock --jobs=2"
STACK="stack --no-terminal --haddock --jobs=4"
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +398 to +399
build-tool-depends:
happy:happy ==2.0.2
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was declared before in the purescript-cst library—not having it makes cabal builds fail on my machine though!

filepath >=1.4.301.0 && <1.5,
Glob >=0.10.2 && <0.11,
haskeline ==0.8.2,
haskeline >=0.8.2.1 && <0.9,
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes cabal builds but also introduces libtinfo to dynamically-linked executables.

Copy link
Member

Choose a reason for hiding this comment

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

This is fine for local builds if we only build the static one in CI

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
filepath >=1.4.301.0 && <1.5,
Glob >=0.10.2 && <0.11,
haskeline ==0.8.2,
haskeline >=0.8.2.1 && <0.9,
Copy link
Member

Choose a reason for hiding this comment

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

This is fine for local builds if we only build the static one in CI

@purefunctor
Copy link
Member Author

It works!

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

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

Looks great now - thanks @purefunctor!

@f-f
Copy link
Member

f-f commented Jun 25, 2025

@purefunctor I have updated the CI requirements to include the new jobs, so the path ahead is all green - are we good to merge?

@purefunctor
Copy link
Member Author

purefunctor commented Jun 25, 2025 via email

@purefunctor purefunctor merged commit 9dd761a into master Jun 27, 2025
13 of 14 checks passed
@purefunctor purefunctor deleted the justin/ghc-musl branch June 27, 2025 05:21
noisyscanner pushed a commit to OxfordAbstracts/purescript that referenced this pull request Dec 1, 2025
* Build statically-linked binaries with ghc-musl

* Compliance for LGPL terms

* Add changelog entry

* Update dependencies

* Update LICENSE

* Update weeder

* Fix weeder

* Add more changelog entries

* Argument passthrough

* Update license

* Update license

* Build images for ARM

* Checkout after Node installation

* Only mount volumes for static

* Drop static prefix for now

* Force purge cache

* Remove builds against ubuntu

* Use matrix.os for cache key

* Fix linux only

* Set CI_STATIC to true

* CI_STATIC on Linux only

* Fix more linux only checks
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.

Consider ghc-musl for building fully static binaries

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.