commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

Re #6531 Allow cross-OS use of `release.hs` #6535

Closed mpilgrem closed 3 months ago

mpilgrem commented 3 months ago

This pull request folds the idea of #6533 into etc/scripts/release.hs itself, and extends it.

Currently, the Linux/AArch64 job in integration-tests.yml makes use of:

/usr/local/bin/stack etc/scripts/release.hs build --alpine --build-args --docker-stack-exe=image

You can't use a Docker container on GitHub's macOS/M1-based macos-14, but the idea is that you could use on macOS/AArch64 locally:

stack etc/scripts/release.hs build --alpine --stack-args --docker-stack-exe=image

It also seeks to do the same with release.hs check, so that you can use on macOS/AArch64 locally:

stack etc/scripts/release.hs check --alpine --stack-args --docker-stack-exe=image

The pull request introduces --stack-args, as --docker-stack-exe is a global flag, not a stack build flag. As before, when --alpine is passed the global flags --docker, --system-ghc and --no-install-ghc are specified.

The pull request distinguishes the target OS from the platform OS. When --alpine is passed, the target OS is set to Linux.

In the case of release.hs check, the commands are run by the platform's Stack (with stack exec) so that they can be run in a Docker container, if necessary. This is also done when stack --version is examined.

With:

stack --docker --docker-stack-exe-image --system-ghc --no-install-ghc exec stack -- ...

the second Stack (the one provided by the Docker image) needs its own --system-ghc --no-install-ghc, so those flags are added to gCheckStackArgs when --alpine is passed.

The deprecated putNormal is replaced by putInfo.

This is being tested locally on a Mac mini/M1. The 4095-utf8-pure-nix was failing because Nix can't be used in a Docker container. So, a guard has been added.

One other test was failing: 4783-doctest-deps. That is still being investigated and so this pull request is still draft.

Please include the following checklist in your pull request:

Please also shortly describe how you tested your change. Bonus points for added tests! Local testing and also relying on CI.

mpilgrem commented 3 months ago

The 4783-doctest-deps failure comes at the linking stage for the doctest executable (extract):

doctest  > Preprocessing executable 'doctest' for doctest-0.22.2..
doctest  > Building executable 'doctest' for doctest-0.22.2..
doctest  > [1 of 2] Compiling Main
doctest  > [2 of 2] Compiling Paths_doctest
doctest  > [3 of 3] Linking .stack-work/dist/aarch64-linux-dkc042e302e26590e0ec6157676b3df5ee/ghc-9.6.4/build/doctest/doctest
doctest  > collect2: fatal error: ld terminated with signal 9 [Killed]
doctest  > compilation terminated.
doctest  > ghc-9.6.4: `gcc' failed in phase `Linker'. (Exit code: 1)

EDIT: That error is due to memory exhaustion. It is fixed by giving colima more memory than its default 2 GB.