Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 17 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,31 @@ jobs:
- '5.2.0+ox'

runs-on: ${{ matrix.os }}
container:
image: alpine:latest
steps:
# This has to come first because the `actions/*` GitHub Actions require `node`,
# which isn't installed by default on this container image.
- name: "Install apk packages"
run: |
apk add autoconf bash bubblewrap build-base clang coreutils git libstdc++ \
libstdc++-dev libunwind-static linux-headers lld llvm20 llvm20-dev llvm20-static \
nodejs opam rsync upx zlib-static zstd-static
echo "PATH=/usr/lib/llvm20/bin:$PATH" >> "$GITHUB_ENV"

- name: Checkout code
uses: actions/checkout@v6

# This is necessary to avoid an error of the form 'fatal: detected dubious ownership in repository ...'
- run: git config --global --add safe.directory $(pwd)

- uses: actions/cache@v5
with:
path: ~/.opam
key: ${{ matrix.os }}-opam-${{ matrix.ocaml-version }}-1

- name: Install musl-compatible kernel headers
run: |
mkdir musl-kernel
filename='v4.19.88-1.tar.gz'
wget "https://github.com/sabotage-linux/kernel-headers/archive/refs/tags/$filename"
shasum --check <(echo "44a07e9f18033cff7840dbb112fff2862c0fb8fc $filename")
tar -xzf "$filename" -C musl-kernel --strip-components=1
echo "C_INCLUDE_PATH=$(pwd)/musl-kernel/x86/include" >> "$GITHUB_ENV"
echo "CC=musl-gcc" >> "$GITHUB_ENV"

- name: "Install apt packages"
run: |
sudo apt-get update
sudo apt-get install -y bubblewrap musl musl-tools libucl1 rsync

- name: Install upx
run: |
# The version that comes with focal is broken for musl binaries, so we have to download
# from another location.
filename='upx-ucl_3.96-2_amd64.deb'
wget "http://ftp.debian.org/debian/pool/main/u/upx-ucl/$filename"
shasum --check <(echo "0b3c901a6ae8db264a0e58aad9bbed4ef3e925b9 $filename")
sudo dpkg -i upx-ucl_3.96-2_amd64.deb

- name: Build zlib with musl
run: |
mkdir musl-zlib
filename='zlib-1.3.2.tar.gz'
wget "https://zlib.net/$filename"
shasum -a 256 --check <(echo "bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 $filename")
tar -xzf "$filename" -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 -j$(nproc)
sudo make install

- name: Build zstd with musl
run: |
mkdir musl-zstd
filename='zstd-1.5.5.tar.gz'
wget "https://github.com/facebook/zstd/releases/download/v1.5.5/$filename"
shasum --check <(echo "4479ecc74300d23391d99fbebf2fddd47aed9b28 $filename")
tar -xzf "$filename" -C musl-zstd --strip-components=1
cd musl-zstd
CC=musl-gcc make -j$(nproc)
sudo make INCLUDEDIR=/usr/include/x86_64-linux-musl LIBDIR=/usr/lib/x86_64-linux-musl install
key: ${{ matrix.os }}-opam-${{ matrix.ocaml-version }}-2

- name: Use OCaml ${{ matrix.ocaml-version }}
run: |
filename='opam-2.5.0-x86_64-linux'
wget "https://github.com/ocaml/opam/releases/download/2.5.0/$filename"
shasum --check <(echo "67fb680a785f0bc7ceb57155f21786c0680ef5fe $filename")
sudo mv "$filename" /usr/local/bin/opam
sudo chmod a+x /usr/local/bin/opam

export OPAMYES=1
export OPAMJOBS=$(($(nproc) + 2))
echo "OPAMYES=1" >> "$GITHUB_ENV"
Expand All @@ -93,11 +54,12 @@ jobs:

- run: opam exec -- make PROFILE=static

- run: opam exec -- dune runtest
- run: opam exec -- dune runtest --profile=static

- name: Compress magic-trace executable
run: |
cp _build/install/default/bin/magic-trace .
chmod u+w magic-trace
ls -l magic-trace
strip magic-trace
upx -9 magic-trace
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ _build
_opam
.vscode/*
!.vscode/tasks.json
*.fxt
*.fxt.old
*.fxt.gz
*.fxt.gz.old
2 changes: 2 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
profile=janestreet
wrap-comments=false
parse-docstrings=false
1 change: 1 addition & 0 deletions direct_backend/cinaps/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(library
(name magic_trace_lib_cinaps_helpers)
(no_dynlink)
(libraries core)
(preprocess
(pps ppx_jane)))
4 changes: 3 additions & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(env
(static
(flags
(:standard -cclib -static))))
(:standard -cclib -static -cclib -no-pie))
(link_flags
(:standard -cclib -static -cclib -no-pie))))

(vendored_dirs vendor)
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(lang dune 2.0)
(lang dune 3.0)
1 change: 1 addition & 0 deletions lib/magic_trace/src/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(library
(name magic_trace)
(public_name magic-trace.magic_trace)
(no_dynlink)
(foreign_stubs
(language c)
(names stop_stubs))
Expand Down
1 change: 1 addition & 0 deletions lib/magic_trace/test/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(library
(name magic_trace_test)
(no_dynlink)
(libraries core expect_test_helpers_core magic_trace)
(preprocess
(pps ppx_jane)))
1 change: 1 addition & 0 deletions magic-trace.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ depends: [
"owee" {>= "0.8"}
"re" {>= "1.8.0"}
"zstandard"
"vec"
]
synopsis: "Collects and displays high-resolution traces of what a process is doing"
description: "https://github.com/janestreet/magic-trace"
Loading