-
Notifications
You must be signed in to change notification settings - Fork 1
285 lines (260 loc) · 11.4 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: build
run-name: ${{ inputs.name }}
on:
workflow_dispatch:
inputs:
name:
description: 'name'
type: string
repo:
description: 'repo'
required: true
default: 'MLton'
type: string
ref:
description: 'git ref'
required: true
type: string
jobs:
build:
strategy:
fail-fast: false
matrix:
#arch:
# - { name: i686, alt: x86 }
# - { name: x86_64, alt: amd64 }
# - { name: aarch64, alt: arm64 }
# - { name: powerpc, alt: powerpc }
- { name: powerpc64, alt: powerpc64 }
# - { name: riscv32, alt: riscv }
# - { name: riscv64, alt: riscv }
# - { name: mips, alt: mips }
# - { name: m68k, alt: m68k }
libc: [ gnu, musl ]
#include:
# - { arch: { name: mips64, alt: mips }, libc: gnuabi64 }
# - { arch: { name: mips64, alt: mips }, libc: musl }
# - { arch: { name: arm, alt: arm }, libc: gnueabihf }
# - { arch: { name: arm, alt: arm }, libc: musleabihf }
# - { arch: { name: armv7l, alt: arm }, libc: musleabihf }
#exclude:
# - { arch: { name: riscv32, alt: riscv }, libc: gnu }
runs-on: ubuntu-latest
steps:
- name: Checkout MLton
uses: actions/checkout@v4
with:
repository: ${{ inputs.repo }}/mlton
ref: ${{ inputs.ref }}
path: mlton
- name: Checkout musl-cross-make
if: startsWith(matrix.libc, 'musl') && false
uses: actions/checkout@v4
with:
repository: richfelker/musl-cross-make
ref: master
path: musl-cross-make
- name: Install qemu
run: |
sudo apt-get update
sudo apt-get install qemu-user-static
- name: Install toolchain (musl.cc)
if: startsWith(matrix.libc, 'musl')
run: |
curl -sOL https://more.musl.cc/x86_64-linux-musl/${{ matrix.arch.name }}-linux-${{ matrix.libc }}-cross.tgz
tar -xf ${{ matrix.arch.name }}-linux-${{ matrix.libc }}-cross.tgz
sudo cp -fpr ${{ matrix.arch.name }}-linux-${{ matrix.libc }}-cross/* /usr/local/
rm -r ${{ matrix.arch.name }}-linux-${{ matrix.libc }}-cross \
${{ matrix.arch.name }}-linux-${{ matrix.libc }}-cross.tgz
- name: Install toolchain (musl-cross-make)
if: startsWith(matrix.libc, 'musl') && false
run: |
cd musl-cross-make
cat <<EOF > config.mak
TARGET=${{ matrix.arch.name }}-linux-${{ matrix.libc }}
OUTPUT=/usr/local
COMMON_CONFIG += --disable-nls
GCC_CONFIG += --disable-libquadmath --disable-decimal-float
GCC_CONFIG += --disable-libitm
GCC_CONFIG += --disable-fixed-point
GCC_CONFIG += --disable-lto
GCC_CONFIG += --enable-languages=c
EOF
make
sudo make install
- name: Install toolchain (crosstool-ng)
if: startsWith(matrix.libc, 'musl') && false
run: |
curl -sOL http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.9.3.tar.bz2
cat <<EOF > checksum
699ac002ca24c93b526562b324bd6c039ae2603172e0480d7d0a05a3224249596b06a6d70041527b1b99753311c3878fd93419723150f4e6e0673499516427bf crosstool-ng-1.9.3.tar.bz2
EOF
sha512sum -c checksum
tar -xf crosstool-ng-1.9.3.tar.bz2
cd crosstool-ng-1.9.3.tar.bz2
./configure --prefix=/usr/local
make
sudo make install
cd ..
rm -r crosstool-ng-1.9.3 crosstool-ng-1.9.3.tar.bz2
mkdir cross && cd cross
cat <<EOF > .config
CT_CONFIG_VERSION="4"
CT_ARCH_ARM=y
CT_ARCH_ARCH="armv7-a"
CT_ARCH_SUFFIX="v7"
CT_ARCH_FPU="vfpv3"
CT_ARCH_FLOAT="hard"
CT_ARCH_FLOAT_HW=y
CT_OMIT_TARGET_VENDOR=y
CT_KERNEL_LINUX=y
CT_BINUTILS_LINKER_LD_GOLD=y
CT_BINUTILS_GOLD_THREADS=y
CT_BINUTILS_LD_WRAPPER=y
CT_BINUTILS_PLUGINS=y
CT_CROSS=y
CT_LIBC_MUSL=y
EOF
ct-ng build
- name: Install toolchain (glibc)
if: startsWith(matrix.libc, 'gnu') && matrix.arch.name != 'x86_64'
run: |
sudo apt-get install gcc-${{ matrix.arch.name }}-linux-${{ matrix.libc }} \
binutils-${{ matrix.arch.name }}-linux-${{ matrix.libc }}
- name: Link cc to gcc
if: startsWith(matrix.libc, 'gnu')
run: |
sudo ln -s /usr/bin/${{ matrix.arch.name }}-linux-${{ matrix.libc }}-gcc \
/usr/bin/${{ matrix.arch.name }}-linux-${{ matrix.libc }}-cc
- name: Install gmp
run: |
curl -sOL https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
tar -xf gmp-6.3.0.tar.xz
cd gmp-6.3.0
./configure --disable-shared \
${{ matrix.arch.name == 'i686' && '--with-pic' || '' }} \
${{ matrix.arch.name == 'armv7l' && '--with-pic CFLAGS="-march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -O2 -pedantic"' || '' }} \
${{ startsWith(matrix.arch.name, 'powerpc') && '--disable-assembly' || '' }} \
--build=x86_64-linux-gnu \
--host=${{ matrix.arch.name }}-linux-${{ matrix.libc }}
make
# make check
sudo make install
cd ${{ github.workspace }}
rm -r gmp-6.3.0 gmp-6.3.0.tar.xz
- name: Install bootstrap mlton (release)
if: false
run: |
curl -sOL https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz
tar -xf mlton-20210117-1.amd64-linux-glibc2.31.tgz --exclude='*/share'
rm mlton-20210117-1.amd64-linux-glibc2.31.tgz
sudo mv mlton-20210117-1.amd64-linux-glibc2.31 /opt/boot
# Backport fixes
sudo cp -p mlton/runtime/platform/linux.h /opt/boot/lib/mlton/include/platform/linux.h
- name: Install bootstrap mlton (git)
if: true
run: |
curl -sOL https://github.com/ii8/mlton-builds/releases/download/20210117/mlton-20231109.223645-g04d7690-1.amd64-linux.ubuntu-latest_gcc_amd64.tgz
tar -xf mlton-20231109.223645-g04d7690-1.amd64-linux.ubuntu-latest_gcc_amd64.tgz
rm mlton-20231109.223645-g04d7690-1.amd64-linux.ubuntu-latest_gcc_amd64.tgz
sudo mv mlton-20231109.223645-g04d7690-1.amd64-linux.ubuntu-latest_gcc_amd64 /opt/boot
- name: Build target runtime (release)
if: false
run: |
curl -sOL https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117.src.tgz
tar xzf mlton-20210117.src.tgz
rm mlton-20210117.src.tgz
mv mlton-20210117 src
cp runtime/platform/linux.h src/runtime/platform/linux.h
cd src
PATH="/opt/boot/bin:$PATH" make \
LDFLAGS=-static BOOTSTRAP_STYLE=0 \
TARGET=${{ matrix.arch.name }}-linux-${{ matrix.libc }} TARGET_ARCH=${{ matrix.arch.alt }} TARGET_OS=linux \
WITH_GMP_DIR=/usr/local \
dirs runtime
sudo cp -fpR src/build/lib/mlton/targets/${{ matrix.arch.name }}-linux-${{ matrix.libc }} /opt/boot/lib/mlton/targets/
- name: Build target runtime (git)
if: true
run: |
cd mlton
PATH="/opt/boot/bin:$PATH" make \
LDFLAGS=-static BOOTSTRAP_STYLE=0 \
${{ matrix.arch.name == 'armv7l' && 'CFLAGS="-march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard"' || '' }} \
TARGET=${{ matrix.arch.name }}-linux-${{ matrix.libc }} TARGET_ARCH=${{ matrix.arch.alt }} TARGET_OS=linux \
WITH_GMP_DIR=/usr/local \
dirs runtime
sudo cp -fpR build/lib/mlton/targets/${{ matrix.arch.name }}-linux-${{ matrix.libc }} /opt/boot/lib/mlton/targets/
- name: Build Hello World
run: |
mkdir hello && cd hello
echo 'print "hi\n";' > hello.sml
PATH="/opt/boot/bin:$PATH" mlton -verbose 2 -debug true -keep g -target ${{ matrix.arch.name }}-linux-${{ matrix.libc }} -cc-opt -I/usr/local/include -link-opt -L/usr/local/lib -link-opt -static
./hello
- name: Build MLton
run: |
cd mlton
PATH="/opt/boot/bin:$PATH" make \
BOOTSTRAP_STYLE=0 \
TARGET=${{ matrix.arch.name }}-linux-${{ matrix.libc }} TARGET_ARCH=${{ matrix.arch.alt }} TARGET_OS=linux \
OLD_MLTON_COMPILE_ARGS="-debug true -keep g -cc-opt -I/usr/local/include -link-opt -L/usr/local/lib -link-opt -static ${{ matrix.arch.name == 'armv7l' && '-cc-opt -march=armv7-a -cc-opt -mfpu=vfpv3 -cc-opt -mfloat-abi=hard' || '' }}" \
dirs runtime compiler script basis-no-check libraries-no-check tools
mv build/lib/mlton/targets/${{ matrix.arch.name }}-linux-${{ matrix.libc }} build/lib/mlton/targets/self
- name: Status
run: |
cd mlton
ulimit -c unlimited
file build/lib/mlton/mlton-compile
build/bin/mlton -show path-map
- name: Limit tests
if: true
run: |
cd mlton
mv regression/Makefile Makefile.regression
mv regression/whitelist .
mv regression/real.* .
mv regression/real-basic.* .
rm -r regression/*
mv Makefile.regression regression/Makefile
mv whitelist regression/
mv real.* regression/
mv real-basic.* regression/
mv benchmark/tests/Makefile Makefile.benchmark.tests
mv benchmark/tests/raytrace.sml .
rm -r benchmark/tests/*
mv Makefile.benchmark.tests benchmark/tests/Makefile
mv raytrace.sml benchmark/tests/
- name: Test
run: |
cd mlton
ulimit -c unlimited
./bin/regression -verbose 1 \
-cc ${{ matrix.arch.name }}-linux-${{ matrix.libc }}-gcc \
-cc-opt -I/usr/local/include \
-link-opt -L/usr/local/lib \
-link-opt -static
- name: Debug
if: failure()
uses: actions/upload-artifact@v3
with:
name: debug-${{ matrix.arch.name }}-${{ matrix.libc }}
path: hello/*
- name: Package
if: ${{ !cancelled() }}
run: |
cd mlton
mv build mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}
tar czvf mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}.tar.gz \
mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}
sha256sum mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}.tar.gz \
> mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}.tar.gz.sha256sum
- name: Upload Artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v3
with:
name: mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}
path: mlton/mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}.tar.gz
- name: Upload Checksum
uses: actions/upload-artifact@v3
with:
name: mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}.sha256sum
path: mlton/mlton-${{ inputs.ref }}.${{ matrix.arch.name }}-linux-${{ matrix.libc }}.tar.gz.sha256sum