Skip to content

Commit 1d6e208

Browse files
SvetlitskiXyene
authored andcommitted
Migrate GitHub CI to OxCaml
Signed-off-by: Kevin Svetlitski <ksvetlitski@janestreet.com>
1 parent 1f28c8a commit 1d6e208

File tree

4 files changed

+152
-9
lines changed

4 files changed

+152
-9
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
os:
1212
- ubuntu_x64_8_cores
1313
ocaml-version:
14-
- 4.14.0
14+
- '5.2.0+ox'
1515

1616
runs-on: ${{ matrix.os }}
1717
steps:
@@ -21,19 +21,20 @@ jobs:
2121
- uses: actions/cache@v4
2222
with:
2323
path: ~/.opam
24-
key: ${{ matrix.os }}-opam-${{ matrix.ocaml-version }}-flambda-musl-v6
24+
key: ${{ matrix.os }}-opam-${{ matrix.ocaml-version }}-1
2525

2626
- name: Install musl-compatible kernel headers
2727
run: |
2828
mkdir musl-kernel
2929
curl -L https://github.com/sabotage-linux/kernel-headers/archive/refs/tags/v4.19.88-1.tar.gz | \
3030
tar -xz -C musl-kernel --strip-components=1
3131
echo "C_INCLUDE_PATH=$(pwd)/musl-kernel/x86/include" >> "$GITHUB_ENV"
32+
echo "CC=musl-gcc" >> "$GITHUB_ENV"
3233
3334
- name: "Install apt packages"
3435
run: |
3536
sudo apt-get update
36-
sudo apt-get install bubblewrap musl-tools libucl1
37+
sudo apt-get install -y bubblewrap musl musl-tools libucl1 rsync
3738
3839
- name: Install upx
3940
run: |
@@ -50,7 +51,7 @@ jobs:
5051
CC=musl-gcc ./configure --libdir=/usr/lib/x86_64-linux-musl --includedir=/usr/include/x86_64-linux-musl
5152
make -j$(nproc)
5253
sudo make install
53-
54+
5455
- name: Build zstd with musl
5556
run: |
5657
mkdir musl-zstd
@@ -62,7 +63,7 @@ jobs:
6263
6364
- name: Use OCaml ${{ matrix.ocaml-version }}
6465
run: |
65-
sudo wget -O /usr/local/bin/opam https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux
66+
sudo wget -O /usr/local/bin/opam https://github.com/ocaml/opam/releases/download/2.5.0/opam-2.5.0-x86_64-linux
6667
sudo chmod a+x /usr/local/bin/opam
6768
6869
export OPAMYES=1
@@ -71,13 +72,28 @@ jobs:
7172
echo "OPAMJOBS=$OPAMJOBS" >> "$GITHUB_ENV"
7273
7374
opam init --bare -yav https://github.com/ocaml/opam-repository.git
74-
opam switch set ${{ matrix.ocaml-version }}-flambda-musl 2>/dev/null || \
75-
opam switch create ${{ matrix.ocaml-version }}-flambda-musl \
76-
--packages=ocaml-variants.${{ matrix.ocaml-version }}+options,ocaml-option-flambda,ocaml-option-musl
75+
opam switch set ${{ matrix.ocaml-version }} 2>/dev/null || \
76+
opam switch create ${{ matrix.ocaml-version }} --repos ox=git+https://github.com/oxcaml/opam-repository.git,default
77+
78+
- name: Vendor Basement
79+
run: |
80+
mkdir ../basement
81+
curl -L 'https://github.com/janestreet/basement/archive/c657898128a97dcdfbe4b25d79fd0de2e1e5218f.tar.gz' | \
82+
tar -C ../basement -xz --strip-components=1
83+
git -C ../basement apply $PWD/vendor/basement-semaphore-bug-fix.patch
84+
opam pin basement ../basement
85+
86+
- name: Vendor Core_unix
87+
run: |
88+
mkdir ../core_unix
89+
curl -L 'https://github.com/janestreet/core_unix/archive/63390a3f75376156e77ed49d6cc07ca48a90dd53.tar.gz' | \
90+
tar -C ../core_unix -xz --strip-components=1
91+
git -C ../core_unix apply $PWD/vendor/core-unix-musl-compatibility.patch
92+
opam pin core_unix ../core_unix
7793
7894
- run: opam install ./magic-trace.opam --deps-only
7995

80-
- run: opam install ocamlformat.0.26.2
96+
- run: opam install ocamlformat
8197
- run: opam exec -- dune build @fmt
8298

8399
- run: opam exec -- make PROFILE=static

magic-trace.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build: [
1111
]
1212
depends: [
1313
"ocaml" {>= "4.14"}
14+
"ocaml_intrinsics"
1415
"async"
1516
"camlzip"
1617
"cohttp"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
commit 16d35743d6b52bc0b38702a459025ba82bd8811f
2+
Author: Fake Name <fake@gmail.com>
3+
Date: Thu Dec 11 03:26:20 2025 +0000
4+
5+
Fix bug where `sem_close` was being called on an unnamed semaphore
6+
7+
diff --git a/src/blocking_mutex.h b/src/blocking_mutex.h
8+
index b1d01df..c4658e3 100644
9+
--- a/src/blocking_mutex.h
10+
+++ b/src/blocking_mutex.h
11+
@@ -106,7 +106,7 @@ Caml_inline int blocking_mutex_destroy(blocking_mutex mut) {
12+
caml_stat_free(mut);
13+
return MUTEX_SUCCESS;
14+
#else
15+
- if (sem_close(&mut->sem) == MUTEX_SUCCESS) {
16+
+ if (sem_destroy(&mut->sem) == MUTEX_SUCCESS) {
17+
caml_stat_free(mut);
18+
return MUTEX_SUCCESS;
19+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
commit 3254c4bb0793ab87c674ddd9f404cb21dd20e311
2+
Author: Fake Name <fake@gmail.com>
3+
Date: Thu Dec 11 01:21:19 2025 +0000
4+
5+
Make `Core_unix` compatible with `musl`
6+
7+
diff --git a/bigstring_unix/src/bigstring_unix_stubs.c b/bigstring_unix/src/bigstring_unix_stubs.c
8+
index 785ff10..009c2cb 100644
9+
--- a/bigstring_unix/src/bigstring_unix_stubs.c
10+
+++ b/bigstring_unix/src/bigstring_unix_stubs.c
11+
@@ -28,7 +28,7 @@
12+
#define bswap_16 OSSwapInt16
13+
#define bswap_32 OSSwapInt32
14+
#define bswap_64 OSSwapInt64
15+
-#elif __GLIBC__
16+
+#elif defined(__linux__)
17+
#include <byteswap.h>
18+
#include <malloc.h>
19+
#else
20+
diff --git a/core_unix/src/core_unix_stubs.c b/core_unix/src/core_unix_stubs.c
21+
index 216b5be..847d707 100644
22+
--- a/core_unix/src/core_unix_stubs.c
23+
+++ b/core_unix/src/core_unix_stubs.c
24+
@@ -378,7 +378,7 @@ CAMLprim value core_unix_fdatasync(value v_fd) {
25+
return Val_unit;
26+
}
27+
#else
28+
-#warning "_POSIX_SYNCHRONIZED_IO undefined or <= 0; aliasing unix_fdatasync to unix_fsync"
29+
+//#warning "_POSIX_SYNCHRONIZED_IO undefined or <= 0; aliasing unix_fdatasync to unix_fsync"
30+
CAMLprim value core_unix_fdatasync(value v_fd) { return core_unix_fsync(v_fd); }
31+
#endif
32+
33+
@@ -789,7 +789,7 @@ CAMLprim value core_unix_clock_thread_cputime_id_stub(value __unused v_unit) {
34+
#undef CLOCK
35+
36+
#else
37+
-#warning "posix timers not present; clock functions undefined"
38+
+//#warning "posix timers not present; clock functions undefined"
39+
#endif
40+
41+
/* Resource limits */
42+
@@ -1506,7 +1506,7 @@ CAMLprim value core_unix_sched_setscheduler(value v_pid, value v_policy,
43+
return Val_unit;
44+
}
45+
#else
46+
-#warning "_POSIX_PRIORITY_SCHEDULING not present; sched_setscheduler undefined"
47+
+//#warning "_POSIX_PRIORITY_SCHEDULING not present; sched_setscheduler undefined"
48+
CAMLprim value core_unix_sched_setscheduler(value __unused v_pid, value __unused v_policy,
49+
value __unused v_priority) {
50+
caml_invalid_argument("sched_setscheduler unimplemented");
51+
@@ -1599,7 +1599,7 @@ CAMLprim value core_unix_strptime_l(value v_locale, value v_allow_trailing_input
52+
value v_fmt, value v_s) {
53+
54+
locale_t locale = (locale_t)Nativeint_val(v_locale);
55+
- return core_unix_strptime_gen(locale, v_allow_trailing_input, v_fmt, v_s, strptime_l);
56+
+ return core_unix_strptime_gen(locale, v_allow_trailing_input, v_fmt, v_s, strptime_callback);
57+
}
58+
59+
CAMLprim value core_unix_remove(value v_path) {
60+
diff --git a/filename_unix/src/filename_unix_stubs.c b/filename_unix/src/filename_unix_stubs.c
61+
index e4826a1..c14cafa 100644
62+
--- a/filename_unix/src/filename_unix_stubs.c
63+
+++ b/filename_unix/src/filename_unix_stubs.c
64+
@@ -28,7 +28,7 @@ CAMLprim value core_unix_realpath(value v_path) {
65+
}
66+
#else
67+
CAMLprim value core_unix_realpath(value v_path) {
68+
- char *path = String_val(v_path);
69+
+ const char *path = String_val(v_path);
70+
/* [realpath] is inherently broken without GNU-extension, and this
71+
seems like a reasonable thing to do if we do not build against
72+
GLIBC. */
73+
diff --git a/linux_ext/src/linux_ext_stubs.c b/linux_ext/src/linux_ext_stubs.c
74+
index 3a948b7..6d9e7f0 100644
75+
--- a/linux_ext/src/linux_ext_stubs.c
76+
+++ b/linux_ext/src/linux_ext_stubs.c
77+
@@ -230,7 +230,7 @@ CAMLprim value core_linux_sendmsg_nonblocking_no_sigpipe_stub(value v_fd, value
78+
int count = Int_val(v_count);
79+
ssize_t ret;
80+
struct iovec *iovecs = caml_stat_alloc(sizeof(struct iovec) * count);
81+
- struct msghdr msghdr = {NULL, 0, NULL, 0, NULL, 0, 0};
82+
+ struct msghdr msghdr = {NULL, 0, NULL, 0, 0, 0, 0};
83+
msghdr.msg_iov = iovecs;
84+
msghdr.msg_iovlen = count;
85+
for (--count; count >= 0; --count) {
86+
diff --git a/time_float_unix/time_unix/dune b/time_float_unix/time_unix/dune
87+
deleted file mode 100644
88+
index 729e749..0000000
89+
--- a/time_float_unix/time_unix/dune
90+
+++ /dev/null
91+
@@ -1,6 +0,0 @@
92+
-(library
93+
- (name time_unix)
94+
- (public_name core_unix.time_unix)
95+
- (libraries time_float_unix)
96+
- (preprocess
97+
- (pps ppx_jane)))
98+
diff --git a/time_float_unix/time_unix/time_unix.ml b/time_float_unix/time_unix/time_unix.ml
99+
deleted file mode 100644
100+
index c1bdb7d..0000000
101+
--- a/time_float_unix/time_unix/time_unix.ml
102+
+++ /dev/null
103+
@@ -1,4 +0,0 @@
104+
-[@@@deprecated "[since 2022-04] Use [Time_float_unix] instead"]
105+
-(* In the immortal words of MC Hammer: "Stop ... (using) unix time!" *)
106+
-
107+
-include Time_float_unix

0 commit comments

Comments
 (0)