-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (106 loc) · 5.25 KB
/
cross-unix.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
name: Unix Cross Compile
on:
push:
branches:
- 'main'
- 'next'
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- name: "[macOS] arm64 on [macOS] x86_64"
hostabi: darwin_x86_64
os: macos-latest
targetabi: darwin_arm64
targetbits: 64
ocamlconfigure: vendor/dkml-compiler/env/standard-compiler-env-to-ocaml-configure-env.sh
expectfile: Mach-O 64-bit executable arm64
- name: "[android] aarch64 on [linux] x86_64"
hostabi: linux_x86_64
os: ubuntu-latest
targetabi: android_arm64v8a
targetbits: 64
ocamlconfigure: vendor/dkml-compiler/env/github-actions-ci-to-ocaml-configure-env.sh
expectfile: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
- name: "[android] armv7a on [linux] x86"
hostabi: linux_x86
os: ubuntu-latest
targetabi: android_arm32v7a
targetbits: 32
ocamlconfigure: vendor/dkml-compiler/env/github-actions-ci-to-ocaml-configure-env.sh
expectfile: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, with debug_info, not stripped
- name: "[android] x86_64 on [linux] x86_64"
hostabi: linux_x86_64
os: ubuntu-latest
targetabi: android_x86_64
targetbits: 64
ocamlconfigure: vendor/dkml-compiler/env/github-actions-ci-to-ocaml-configure-env.sh
expectfile: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
name: ${{ matrix.name }}
env:
BUILD_TYPE: Debug
# OCaml 4.12.1
OCAML_GIT_REV: 46c947827ec2f6d6da7fe5e195ae5dda1d2ad0c5
DKML_BUILD_TRACE: ON
DIST_DIR: dist/${{ matrix.targetabi }}-on-${{ matrix.hostabi }}
runs-on: ${{ matrix.os }}
steps:
# =============== Checkout ===============
- uses: actions/checkout@v2
with:
submodules: recursive
# =============== Cache ===============
- name: Cache builds
uses: actions/cache@v2
env:
cache-name: cache-${{ matrix.hostabi }}-${{ matrix.targetabi }}
with:
path: |
dist/${{ matrix.targetabi }}-on-${{ matrix.hostabi }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('version.cmake') }}
restore-keys: |
${{ runner.os }}-dist-${{ env.cache-name }}-
# ================ Setup ================
- name: Install compiler on Debian/Ubuntu
if: ${{ startsWith(matrix.os, 'debian-') || startsWith(matrix.os, 'ubuntu-') }}
run: sudo env DEBIAN_FRONTEND="noninteractive" apt-get -q install -y --no-install-recommends build-essential
- name: Install bubblewrap for Opam sandboxing on Debian/Ubuntu
if: ${{ startsWith(matrix.os, 'debian-') || startsWith(matrix.os, 'ubuntu-') }}
run: sudo env DEBIAN_FRONTEND="noninteractive" apt-get -q install -y --no-install-recommends bubblewrap
- name: Install 32-bit GCC on Debian/Ubuntu for 32-bit target ABIs
if: ${{ (startsWith(matrix.os, 'debian-') || startsWith(matrix.os, 'ubuntu-')) && matrix.targetbits == 32 }}
run: sudo env DEBIAN_FRONTEND="noninteractive" apt-get -q install -y --no-install-recommends gcc-multilib g++-multilib
# ================ Build ================
- name: Setup ${{ env.BUILD_TYPE }} OCaml
run: |
vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh \
-d . \
-t "${{ env.DIST_DIR }}" \
-v "${{ env.OCAML_GIT_REV }}" \
-e "${{ matrix.hostabi }}" \
-a "${{ matrix.targetabi }}=${{ matrix.ocamlconfigure }}" \
-k vendor/dkml-compiler/env/standard-compiler-env-to-ocaml-configure-env.sh
- name: Build ${{ env.BUILD_TYPE }} OCaml for host ${{ matrix.hostabi }} ABI
run: cd "${{ env.DIST_DIR }}" && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-2-build_host-noargs.sh
- name: Build ${{ env.BUILD_TYPE }} OCaml for host cross onto target ${{ matrix.targetabi }} ABI
run: cd "${{ env.DIST_DIR }}" && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-3-build_cross-noargs.sh
- name: Audit file structure
# Use stderr since `set -x` goes to stderr and GitHub does not interleave stdout/stderr nicely
run: |
set "-x"
cd "${{ env.DIST_DIR }}"
find . -maxdepth 2 -type d >&2
file bin/* >&2
find opt/mlcross/ -maxdepth 2 -type d >&2
file opt/mlcross/${{ matrix.targetabi }}/bin/* >&2
- name: Test cross-compiling OCaml
run: |
echo 'let () = print_endline "Hello World!"' > hello_world.ml
"${{ env.DIST_DIR }}"/opt/mlcross/${{ matrix.targetabi }}/bin/ocamlopt.opt hello_world.ml -o hello_world.opt.exe -verbose
file hello_world.opt.exe
if [ ! "$(file hello_world.opt.exe)" = "hello_world.opt.exe: ${{ matrix.expectfile }}" ]; then
printf "FATAL: The archictecture of the OCaml compiled executable does not match the expected architecture: ${{ matrix.expectfile }}\n"
exit 1
fi