Skip to content

Add ocaml-common-4_14-a09-debuggasx86 patch #56

Add ocaml-common-4_14-a09-debuggasx86 patch

Add ocaml-common-4_14-a09-debuggasx86 patch #56

Workflow file for this run

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: 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: env/android-ndk-env-to-ocaml-configure-env.sh
expectfile: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
- name: "[android] armv7a on [linux] x86. default minimum API level"
hostabi: linux_x86
os: ubuntu-latest
targetabi: android_arm32v7a
targetbits: 32
ocamlconfigure: env/android-ndk-env-to-ocaml-configure-env.sh
expectfile: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, with debug_info, not stripped
- name: "[android] armv7a on [linux] x86. minimum API level 26"
hostabi: linux_x86
os: ubuntu-latest
targetabi: android_arm32v7a
targetbits: 32
ocamlconfigure: env/android-ndk-env-to-ocaml-configure-env.sh
expectfile: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, with debug_info, not stripped
ANDROID_PLATFORM: android-26
- name: "[android] x86_64 on [linux] x86_64"
hostabi: linux_x86_64
os: ubuntu-latest
targetabi: android_x86_64
targetbits: 64
ocamlconfigure: env/android-ndk-env-to-ocaml-configure-env.sh
expectfile: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
name: ${{ matrix.name }}
env:
BUILD_TYPE: Debug
DKML_BUILD_TRACE: ON
DIST_DIR: dist/${{ matrix.targetabi }}-on-${{ matrix.hostabi }}
runs-on: ${{ matrix.os }}
steps:
# =============== Checkout ===============
- uses: actions/checkout@v4
with:
submodules: recursive
# =============== Cache ===============
- name: Cache builds
uses: actions/cache@v4
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 }}-
# ================ Diagnostics ==========
- name: Set ANDROID_NDK and ANDROID_PLATFORM
env:
ANDROID_PLATFORM: '${{ matrix.ANDROID_PLATFORM }}'
run: |
set -x
if [ -d "$ANDROID_NDK_LATEST_HOME" ]; then ls "$ANDROID_NDK_LATEST_HOME"; fi
if [ -d "$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/" ]; then ls "$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/"; fi
if [ -d "$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/" ]; then ls "$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/"; fi
echo "ANDROID_NDK=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV"
echo "ANDROID_PLATFORM=${ANDROID_PLATFORM:-}" >> "$GITHUB_ENV"
# ================ 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: |
OCAMLVER=$(cat src/version.ocaml.txt | tr -d '\r')
SEMVER=$(cat src/version.semver.txt | tr -d '\r')
# Create a DKMLDIR
printf 'dkml_root_version=%s\\n' "$SEMVER" | sed 's/[0-9.]*~v//; s/~/-/' > .dkmlroot
install -d vendor && git -C vendor clone https://github.com/diskuv/dkml-runtime-common.git drc
install -d vendor/dkml-compiler && cp -rp src vendor/dkml-compiler/
set -x
src/r-c-ocaml-1-setup.sh \
-d . \
-t "${{ env.DIST_DIR }}" \
-v "$OCAMLVER" \
-e "${{ matrix.hostabi }}" \
-a "${{ matrix.targetabi }}=${{ matrix.ocamlconfigure }}" \
-k env/standard-compiler-env-to-ocaml-configure-env.sh
set +x
- 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