summaryrefslogtreecommitdiff
path: root/dev-libs/libdex/files/libdex-0.8.1-libucontext-musl.patch
blob: 38eb2be9a8287515f466642c989c384df92df977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
https://bugs.gentoo.org/928892
https://gitlab.gnome.org/GNOME/libdex/-/commit/fc0ef0544dd61ff6d825c53323d4b4cba4481a03
https://gitlab.gnome.org/GNOME/libdex/-/merge_requests/17

From fc0ef0544dd61ff6d825c53323d4b4cba4481a03 Mon Sep 17 00:00:00 2001
From: Alfred Wingate <parona@protonmail.com>
Date: Wed, 29 Jan 2025 07:16:41 +0200
Subject: [PATCH] build: try libucontext if symbols are not present

Musl includes uncontext.h but doesn't implement the symbols. This means
that HAVE_CONTEXT_H will be set and linking will fail due to missing
symbols.

https://wiki.musl-libc.org/open-issues.html#ucontext.h

If the symbols are missing depend on libucontext which is an implementation
of these functions for musl.

https://github.com/kaniini/libucontext

Bug: https://bugs.gentoo.org/928892
Signed-off-by: Alfred Wingate <parona@protonmail.com>
--- a/meson.build
+++ b/meson.build
@@ -44,14 +44,14 @@ if get_option('sysprof')
   config_h.set10('HAVE_SYSPROF', true)
 endif
 
-check_headers = [
-  'ucontext.h',
-]
-foreach h : check_headers
-  if cc.has_header(h)
-    config_h.set('HAVE_' + h.underscorify().to_upper(), 1)
+if cc.has_header('ucontext.h')
+  if not cc.has_function('makecontext', prefix : '#include <ucontext.h>')
+    libucontext_dep = dependency('libucontext', required: false)
+  else
+    libucontext_dep = disabler()
   endif
-endforeach
+  config_h.set('HAVE_UCONTEXT_H', 1)
+endif
 
 if host_machine.system() == 'darwin'
   # known alignment for darwin where we're using helpers
--- a/src/meson.build
+++ b/src/meson.build
@@ -95,6 +95,9 @@ if host_machine.system() != 'windows'
     'dex-unix-signal.c',
     'dex-ucontext.c',
   ]
+  if libucontext_dep.found()
+    libdex_deps += [libucontext_dep]
+  endif
 
   # If we're on Linux and mips we might still need asm.S.
   # But otherwise linux can do it all without any custom
-- 
GitLab