From bd3280283a8288f4e4d95feb58d66765bda9ad90 Mon Sep 17 00:00:00 2001 From: Reno Dakota Date: Sun, 17 Nov 2024 08:42:09 -0800 Subject: [PATCH] ocamlPackages.luv: backport patch; fix clang build clang build fails with an incompatible pointer type error. Backport a patch from 0.5.14 which fixes this. Can not just update to 0.5.14 as it contains breaking changes and breaks most of luv's consumers. https://github.com/aantron/luv/commit/ad7f953fccb8732fe4eb9018556e8d4f82abf8f2 (cherry picked from commit 8330c77eab5d8aa4cc286e50e80db37febe463fa) --- .../development/ocaml-modules/luv/default.nix | 6 ++ .../luv/incompatible-pointer-type-fix.diff | 87 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 pkgs/development/ocaml-modules/luv/incompatible-pointer-type-fix.diff diff --git a/pkgs/development/ocaml-modules/luv/default.nix b/pkgs/development/ocaml-modules/luv/default.nix index 3f2d462fd15e..86b799e72fd6 100644 --- a/pkgs/development/ocaml-modules/luv/default.nix +++ b/pkgs/development/ocaml-modules/luv/default.nix @@ -15,6 +15,12 @@ buildDunePackage rec { sha256 = "sha256-dp9qCIYqSdROIAQ+Jw73F3vMe7hnkDe8BgZWImNMVsA="; }; + patches = [ + # backport of patch to fix incompatible pointer type. remove next update + # https://github.com/aantron/luv/commit/ad7f953fccb8732fe4eb9018556e8d4f82abf8f2 + ./incompatible-pointer-type-fix.diff + ]; + postConfigure = '' for f in src/c/vendor/configure/{ltmain.sh,configure}; do substituteInPlace "$f" --replace /usr/bin/file file diff --git a/pkgs/development/ocaml-modules/luv/incompatible-pointer-type-fix.diff b/pkgs/development/ocaml-modules/luv/incompatible-pointer-type-fix.diff new file mode 100644 index 000000000000..a949876f31c1 --- /dev/null +++ b/pkgs/development/ocaml-modules/luv/incompatible-pointer-type-fix.diff @@ -0,0 +1,87 @@ +addapted from https://github.com/aantron/luv/commit/ad7f953fccb8732fe4eb9018556e8d4f82abf8f2 +diff --git a/src/c/helpers.c b/src/c/helpers.c +index 7fcd8b6..bc1b926 100755 +--- a/src/c/helpers.c ++++ b/src/c/helpers.c +@@ -175,7 +175,8 @@ static void luv_getaddrinfo_trampoline( + } + + static void luv_getnameinfo_trampoline( +- uv_getnameinfo_t *c_request, int status, char *hostname, char *service) ++ uv_getnameinfo_t *c_request, int status, const char *hostname, ++ const char *service) + { + caml_acquire_runtime_system(); + value callback; +@@ -407,7 +408,7 @@ uv_getaddrinfo_cb luv_get_getaddrinfo_trampoline() + return luv_getaddrinfo_trampoline; + } + +-luv_getnameinfo_cb luv_get_getnameinfo_trampoline() ++uv_getnameinfo_cb luv_get_getnameinfo_trampoline() + { + return luv_getnameinfo_trampoline; + } +@@ -613,15 +614,6 @@ int luv_fs_poll_start( + return uv_fs_poll_start(handle, (uv_fs_poll_cb)poll_cb, path, interval); + } + +-int luv_getnameinfo( +- uv_loop_t *loop, uv_getnameinfo_t *req, luv_getnameinfo_cb getnameinfo_cb, +- const struct sockaddr *addr, int flags) +-{ +- return +- uv_getnameinfo( +- loop, req, (uv_getnameinfo_cb)getnameinfo_cb, addr, flags); +-} +- + int luv_read_start( + uv_stream_t *stream, uv_alloc_cb alloc_cb, luv_read_cb read_cb) + { +diff --git a/src/c/helpers.h b/src/c/helpers.h +index f73e32f..2cc1200 100755 +--- a/src/c/helpers.h ++++ b/src/c/helpers.h +@@ -55,9 +55,6 @@ typedef void (*luv_fs_event_cb)( + typedef void (*luv_fs_poll_cb)( + uv_fs_poll_t *handle, int status, uv_stat_t *prev, uv_stat_t *curr); + +-typedef void (*luv_getnameinfo_cb)( +- uv_getnameinfo_t *req, int status, char *hostname, char *service); +- + typedef void (*luv_read_cb)(uv_stream_t *stream, ssize_t nread, uv_buf_t *buf); + + typedef void (*luv_udp_recv_cb)( +@@ -78,7 +75,7 @@ uv_fs_cb luv_null_fs_callback_pointer(); + luv_fs_event_cb luv_get_fs_event_trampoline(); + luv_fs_poll_cb luv_get_fs_poll_trampoline(); + uv_getaddrinfo_cb luv_get_getaddrinfo_trampoline(); +-luv_getnameinfo_cb luv_get_getnameinfo_trampoline(); ++uv_getnameinfo_cb luv_get_getnameinfo_trampoline(); + uv_idle_cb luv_get_idle_trampoline(); + luv_once_cb luv_get_once_trampoline(); + uv_poll_cb luv_get_poll_trampoline(); +@@ -173,10 +170,6 @@ int luv_fs_poll_start( + uv_fs_poll_t *handle, luv_fs_poll_cb poll_cb, const char *path, + unsigned int interval); + +-int luv_getnameinfo( +- uv_loop_t *loop, uv_getnameinfo_t *req, luv_getnameinfo_cb getnameinfo_cb, +- const struct sockaddr *addr, int flags); +- + int luv_read_start( + uv_stream_t *stream, uv_alloc_cb alloc_cb, luv_read_cb read_cb); + +diff --git a/src/c/luv_c_function_descriptions.ml b/src/c/luv_c_function_descriptions.ml +index 684a46b..7ac1421 100755 +--- a/src/c/luv_c_function_descriptions.ml ++++ b/src/c/luv_c_function_descriptions.ml +@@ -1336,7 +1336,7 @@ struct + (void @-> returning trampoline) + + let getnameinfo = +- foreign "luv_getnameinfo" ++ foreign "uv_getnameinfo" + (ptr Loop.t @-> + ptr t @-> + trampoline @->