-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 18e4414
Showing
6 changed files
with
139 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.swp |
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,54 @@ | ||
# Instructions | ||
|
||
## stage1 | ||
|
||
Download [Raspian](https://www.raspberrypi.org/downloads/raspbian/), unzip it, | ||
and use the `file` command to determine the start sector of the root partition: | ||
|
||
``` | ||
2017-01-11-raspbian-jessie-lite.img: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x0,130,3), end-CHS (0x8,138,2), startsector 8192, 129024 sectors; partition 2 : ID=0x83, start-CHS (0x8,138,3), end-CHS (0xa9,10,33), startsector 137216, 2578432 sectors | ||
``` | ||
|
||
Multiply the start sector by the sector size: | ||
``` | ||
37216 * 512 = 70254592 | ||
``` | ||
|
||
Mount it: | ||
``` | ||
sudo mount -o loop,offset=70254592 2017-01-11-raspbian-jessie-lite.img /mnt | ||
``` | ||
|
||
Install `qemu-user-static`, copy the arm emulator to the rootfs, and comment | ||
out the entry in `/etc/ld.so.preload`: | ||
``` | ||
sudo apt install binfmt-support qemu-user-static | ||
sudo cp `which qemu-arm-static` /mnt/usr/bin | ||
sudo chmod 755 /mnt/usr/bin/qemu-arm-static | ||
sudo vim /mnt/etc/ld.so.preload | ||
``` | ||
|
||
Tar it up in a way suitable for docker: | ||
``` | ||
sudo tar --numeric-owner --create --file rootfs.tar --directory /mnt --transform='s,^./,,' . | ||
mv rootfs.tar /location/of/stage1 | ||
``` | ||
|
||
Build the image: | ||
``` | ||
cd /location/of/stage1 | ||
docker build -t ghc-arm-stage1 . | ||
``` | ||
|
||
Extract the installed contents: | ||
``` | ||
docker run --rm ghc-arm-stage1 cat /tmp/ghc-arm.tar > /location/of/stage2/ghc-arm.tar | ||
``` | ||
|
||
## stage2 | ||
Build the image: | ||
``` | ||
cd /location/of/stage2 | ||
mv ../stage1/rootfs.tar . | ||
docker build -t ghc-arm . | ||
``` |
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,49 @@ | ||
FROM scratch | ||
ADD rootfs.tar / | ||
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
USER root | ||
RUN apt update && \ | ||
apt -y dist-upgrade && \ | ||
apt -y --no-install-recommends install bison llvm-3.7 libgmp-dev libncurses5-dev autoconf && \ | ||
rm -rf /usr/local/* && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /tmp | ||
ADD http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.bz2 . | ||
RUN tar -vxjf binutils-2.27.tar.bz2 && \ | ||
mkdir binutils-2.27-build | ||
WORKDIR /tmp/binutils-2.27-build | ||
RUN ../binutils-2.27/configure --prefix=/usr/local --enable-plugins --enable-gold --disable-nls --disable-werror --with-sysroot=/ && \ | ||
make -j && \ | ||
make install | ||
|
||
WORKDIR /tmp | ||
ADD http://downloads.haskell.org/~ghc/8.0.2/ghc-8.0.2-armv7-deb8-linux.tar.xz . | ||
RUN mkdir ghc-8.0.2-bin && \ | ||
tar -vxf ghc-8.0.2-armv7-deb8-linux.tar.xz --strip-components=1 -C ghc-8.0.2-bin | ||
WORKDIR /tmp/ghc-8.0.2-bin | ||
RUN ./configure --with-llc=llc-3.7 --with-opt=opt-3.7 --prefix=/usr && \ | ||
make install | ||
|
||
WORKDIR /tmp | ||
ADD http://downloads.haskell.org/~ghc/8.0.2/ghc-8.0.2-src.tar.xz . | ||
RUN tar -vxf ghc-8.0.2-src.tar.xz | ||
WORKDIR /tmp/ghc-8.0.2 | ||
ADD aclocal.m4.patch . | ||
ADD build.mk mk | ||
RUN patch -p0 < aclocal.m4.patch && \ | ||
autoreconf -i && \ | ||
./configure --with-llc=llc-3.7 --with-opt=opt-3.7 --prefix=/usr/local && \ | ||
until make -j; do :; done && \ | ||
make install | ||
|
||
USER pi | ||
WORKDIR /tmp | ||
ADD https://www.haskell.org/cabal/release/cabal-install-1.24.0.2/cabal-install-1.24.0.2.tar.gz . | ||
RUN tar -vxzf cabal-install-1.24.0.2.tar.gz | ||
WORKDIR /tmp/cabal-install-1.24.0.2 | ||
RUN EXTRA_CONFIGURE_OPTS="" ./bootstrap.sh --no-doc | ||
|
||
USER root | ||
WORKDIR /tmp | ||
RUN tar --numeric-owner --create --file ghc-arm.tar --transform='s,^./,,' /usr/local /home/pi/.cabal /home/pi/.ghc |
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,13 @@ | ||
--- aclocal.m4.orig 2017-02-13 10:13:37.667003000 -0500 | ||
+++ aclocal.m4 2017-02-13 10:14:19.368446000 -0500 | ||
@@ -582,8 +582,8 @@ | ||
# On arm/linux and arm/android, tell gcc to generate Arm | ||
# instructions (ie not Thumb) and to link using the gold linker. | ||
# Forcing LD to be ld.gold is done in FIND_LD m4 macro. | ||
- $2="$$2 -marm" | ||
- $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack" | ||
+ $2="$$2 -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" | ||
+ $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack -pthread" | ||
$4="$$4 -z noexecstack" | ||
;; | ||
|
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,10 @@ | ||
SRC_HC_OPTS = -O -H64m -fllvm | ||
GhcStage1HcOpts = -O | ||
GhcStage2HcOpts = -O2 | ||
GhcLibHcOpts = -O2 | ||
BUILD_PROF_LIBS = NO | ||
SplitObjs = NO | ||
HADDOCK_DOCS = NO | ||
BUILD_SPHINX_HTML = NO | ||
BUILD_SPHINX_PDF = NO | ||
BUILD_MAN = NO |
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,12 @@ | ||
FROM scratch | ||
ADD rootfs.tar / | ||
ADD ghc-arm.tar / | ||
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
RUN apt update && \ | ||
apt -y dist-upgrade && \ | ||
apt -y --no-install-recommends install llvm-3.7 libgmp-dev libncursesw5 && \ | ||
rm -rf /var/lib/apt/lists/* | ||
USER pi | ||
ENV PATH /home/pi/.cabal/bin:$PATH | ||
WORKDIR /home/pi | ||
CMD bash |
18e4414
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.
قيد التدقيق
18e4414
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.
تحت التدقيق