-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of an ARM64 macOS build
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM ghcr.io/shepherdjerred/macos-cross-compiler:latest | ||
|
||
ENV TARGET aarch64-apple-darwin22 | ||
ENV TARGETNAME darwin.aarch64 | ||
|
||
# Build dependencies | ||
USER root | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV LC_ALL C.utf8 | ||
|
||
# Install basic deps | ||
RUN apt-get update && apt-get install -y automake autoconf build-essential curl xz-utils qemu-user-static | ||
|
||
# Install a more suitable host compiler | ||
WORKDIR /host-ghc | ||
RUN curl -L "https://downloads.haskell.org/~cabal/cabal-install-3.9.0.0/cabal-install-3.9-x86_64-linux-alpine.tar.xz" | tar xJv -C /usr/local/bin | ||
RUN curl -L 'https://downloads.haskell.org/~ghc/8.10.7/ghc-8.10.7-x86_64-deb10-linux.tar.xz' | tar xJ --strip-components=1 | ||
RUN ./configure && make install | ||
|
||
# Build GHC. We have to use an old version because cross-compilation across OS has since broken. | ||
WORKDIR /ghc | ||
RUN curl -L "https://downloads.haskell.org/~ghc/8.10.7/ghc-8.10.7-src.tar.xz" | tar xJ --strip-components=1 | ||
RUN apt-get install -y llvm-12 | ||
RUN ./boot && ./configure --host x86_64-linux-gnu --build x86_64-linux-gnu --target "$TARGET" | ||
RUN cp mk/flavours/quick-cross.mk mk/build.mk && make -j "$(nproc)" | ||
RUN make install | ||
|
||
# Due to an apparent cabal bug, we specify our options directly to cabal | ||
# It won't reuse caches if ghc-options are specified in ~/.cabal/config | ||
ENV CABALOPTS "--ghc-options;-optc-Os -optc-fPIC;--with-ghc=$TARGET-ghc;--with-hc-pkg=$TARGET-ghc-pkg;--constraint=hashable==1.3.5.0" | ||
|
||
# Prebuild the dependencies | ||
RUN cabal update | ||
RUN IFS=';' && cabal install --dependencies-only $CABALOPTS ShellCheck | ||
|
||
# Copy the build script | ||
COPY build /usr/bin | ||
|
||
WORKDIR /scratch | ||
ENTRYPOINT ["/usr/bin/build"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
set -xe | ||
{ | ||
tar xzv --strip-components=1 | ||
chmod +x striptests && ./striptests | ||
mkdir "$TARGETNAME" | ||
cabal update | ||
( IFS=';'; cabal build $CABALOPTS ) | ||
find . -name shellcheck -type f -exec mv {} "$TARGETNAME/" \; | ||
ls -l "$TARGETNAME" | ||
"$TARGET-strip" "$TARGETNAME/shellcheck" | ||
ls -l "$TARGETNAME" | ||
file "$TARGETNAME/shellcheck" | grep "Mach-O 64-bit arm64 executable" | ||
} >&2 | ||
tar czv "$TARGETNAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
koalaman/scbuilder-darwin-aarch64 |
8c4c112
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shell check