Files
nixpkgs/pkgs/by-name/ca/capnproto/fix-libucontext.patch
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

75 lines
2.7 KiB
Diff

From f26dd335c8650a2f8ab7d6e4fb5dfc40ee6af618 Mon Sep 17 00:00:00 2001
From: Jade Lovelace <software@lfcode.ca>
Date: Sun, 10 Aug 2025 10:54:14 +0000
Subject: [PATCH] fix: include libucontext in Requires.private in cmake builds
This is required so that static musl actually links to libucontext
correctly to get setcontext/etc for fibers.
---
c++/CMakeLists.txt | 4 ++++
c++/configure.ac | 4 ++++
c++/pkgconfig/kj-async.pc.in | 1 +
3 files changed, 9 insertions(+)
diff --git a/c++/CMakeLists.txt b/c++/CMakeLists.txt
index f335f12f7c..b2a24e40e0 100644
--- a/c++/CMakeLists.txt
+++ b/c++/CMakeLists.txt
@@ -96,6 +96,9 @@ set_property(CACHE WITH_FIBERS PROPERTY STRINGS AUTO ON OFF)
# CapnProtoConfig.cmake.in needs this variable.
set(_WITH_LIBUCONTEXT OFF)
+# Used by pkg-config files
+set(ASYNC_REQUIRES_PRIVATE "")
+
if (WITH_FIBERS OR WITH_FIBERS STREQUAL "AUTO")
set(_capnp_fibers_found OFF)
if (WIN32 OR CYGWIN)
@@ -116,6 +119,7 @@ if (WITH_FIBERS OR WITH_FIBERS STREQUAL "AUTO")
if (libucontext_FOUND)
set(_WITH_LIBUCONTEXT ON)
set(_capnp_fibers_found ON)
+ set(ASYNC_REQUIRES_PRIVATE "${ASYNC_REQUIRES_PRIVATE} libucontext")
endif()
else()
set(_capnp_fibers_found OFF)
diff --git a/c++/configure.ac b/c++/configure.ac
index a2de7aac80..ce3c632e8c 100644
--- a/c++/configure.ac
+++ b/c++/configure.ac
@@ -216,6 +216,8 @@ AS_IF([test "$with_fibers" != no], [
])
])
+ASYNC_REQUIRES_PRIVATE=""
+
# Check for library support necessary for fibers.
AS_IF([test "$with_fibers" != no], [
case "${host_os}" in
@@ -241,6 +243,7 @@ AS_IF([test "$with_fibers" != no], [
])
AS_IF([test "$ucontext_supports_fibers" = yes], [
ASYNC_LIBS="$ASYNC_LIBS -lucontext"
+ ASYNC_REQUIRES_PRIVATE="$ASYNC_REQUIRES_PRIVATE libucontext"
with_fibers=yes
], [
AS_IF([test "$with_fibers" = yes], [
@@ -259,6 +262,7 @@ AS_IF([test "$with_fibers" = yes], [
], [
CXXFLAGS="$CXXFLAGS -DKJ_USE_FIBERS=0"
])
+AC_SUBST(ASYNC_REQUIRES_PRIVATE, $ASYNC_REQUIRES_PRIVATE)
# CapnProtoConfig.cmake.in needs these variables,
# we force them to NO because we don't need the CMake dependency for them,
diff --git a/c++/pkgconfig/kj-async.pc.in b/c++/pkgconfig/kj-async.pc.in
index 49d5ff6996..41aae28555 100644
--- a/c++/pkgconfig/kj-async.pc.in
+++ b/c++/pkgconfig/kj-async.pc.in
@@ -8,4 +8,5 @@ Description: Basic utility library called KJ (async part)
Version: @VERSION@
Libs: -L${libdir} -lkj-async @ASYNC_LIBS@ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ @STDLIB_FLAG@
Requires: kj = @VERSION@
+Requires.private: @ASYNC_REQUIRES_PRIVATE@
Cflags: -I${includedir} @ASYNC_LIBS@ @PTHREAD_CFLAGS@ @STDLIB_FLAG@ @CAPNP_LITE_FLAG@