Skip to content

Add support for compressed output files, whether gzip (supported by Pe… #884

Add support for compressed output files, whether gzip (supported by Pe…

Add support for compressed output files, whether gzip (supported by Pe… #884

Workflow file for this run

name: build
on:
- push
- pull_request
jobs:
build:
strategy:
matrix:
os:
- ubuntu-latest
ocaml-version:
- 4.14.0
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.opam
key: ${{ matrix.os }}-opam-${{ matrix.ocaml-version }}-flambda-musl-v6
- name: Install musl-compatible kernel headers
run: |
mkdir musl-kernel
curl -L https://github.com/sabotage-linux/kernel-headers/archive/refs/tags/v4.19.88-1.tar.gz | \
tar -xz -C musl-kernel --strip-components=1
echo "C_INCLUDE_PATH=$(pwd)/musl-kernel/x86/include" >> "$GITHUB_ENV"
- name: Install upx
run: |
# The version that comes with focal is broken for musl binaries, so we have to download
# from another location.
wget http://ftp.debian.org/debian/pool/main/u/upx-ucl/upx-ucl_3.96-2_amd64.deb
sudo dpkg -i upx-ucl_3.96-2_amd64.deb
- name: "Install apt packages"
run: |
sudo apt-get update
sudo apt-get install bubblewrap musl-tools
- name: Build zlib with musl
run: |
mkdir musl-zlib
curl -L https://zlib.net/zlib-1.3.1.tar.gz | tar -xz -C musl-zlib --strip-components=1
cd musl-zlib
CC=musl-gcc ./configure --libdir=/usr/lib/x86_64-linux-musl --includedir=/usr/include/x86_64-linux-musl
make
sudo make install
- name: Build zstd with musl
run: |
mkdir musl-zstd
curl -L https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz | \
tar -xz -C musl-zstd --strip-components=1
cd musl-zstd
INCLUDEDIR=/usr/include/x86_64-linux-musl LIBDIR=/usr/lib/x86_64-linux-musl CC=musl-gcc make
sudo make install
- name: Use OCaml ${{ matrix.ocaml-version }}
run: |
sudo wget -O /usr/local/bin/opam https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux
sudo chmod a+x /usr/local/bin/opam
export OPAMYES=1
export OPAMJOBS=$(($(nproc) + 2))
echo "OPAMYES=1" >> "$GITHUB_ENV"
echo "OPAMJOBS=$OPAMJOBS" >> "$GITHUB_ENV"
opam init --bare -yav https://github.com/ocaml/opam-repository.git
opam switch set ${{ matrix.ocaml-version }}-flambda-musl 2>/dev/null || \
opam switch create ${{ matrix.ocaml-version }}-flambda-musl \
--packages=ocaml-variants.${{ matrix.ocaml-version }}+options,ocaml-option-flambda,ocaml-option-musl
echo "*************"
echo '#include <stdio.h>' | musl-gcc -xc -E -v - 2>&1 >/dev/null
echo "*************"
echo '#include <stdio.h>' | gcc -xc -E -v - 2>&1 >/dev/null
echo "*************"
readlink -f /usr/lib/gcc/x86_64-linux-gnu/11/include
readlink -f /usr/include/x86_64-linux-musl
#sudo ln -s /usr/include/zlib.h /usr/include/x86_64-linux-musl/zlib.h
#sudo ln -s /usr/lib/x86_64-linux-gnu/libz.a /usr/lib/x86_64-linux-musl/libz.a
#sudo ln -s /usr/include/zstd.h /usr/include/x86_64-linux-musl/zstd.h
#sudo ln -s /usr/include/zdict.h /usr/include/x86_64-linux-musl/zdict.h
#sudo ln -s /usr/lib/x86_64-linux-gnu/libzstd.a /usr/lib/x86_64-linux-musl/libzstd.a
echo "????"
gcc -print-search-dirs | grep libraries
echo "????"
ls /usr/lib/x86_64-linux-gnu | grep libz
- run: opam install ./magic-trace.opam --deps-only
- run: opam install ocamlformat
- run: opam exec -- dune build @fmt
- run: opam exec -- make PROFILE=static
- run: opam exec -- dune runtest
- name: Compress magic-trace executable
run: |
cp _build/install/default/bin/magic-trace .
ls -l magic-trace
strip magic-trace
upx -9 magic-trace
- uses: actions/upload-artifact@v3
with:
name: magic-trace
path: magic-trace
if-no-files-found: error
- name: Upload to GitHub releases
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: magic-trace
asset_name: magic-trace
tag: ${{ github.ref }}
overwrite: true