summaryrefslogtreecommitdiff
path: root/media-sound/reaper-bin/files/libSwell-makefile-lazy-binding.patch
blob: 9d9508071af82bc7cf725faf01ee0a110a363a90 (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
From d7fa7b22fdbc894a9986ab686b9c009d25f8cae7 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Tue, 2 Apr 2024 01:03:30 +0200
Subject: [PATCH] swell-linux: ensure LD lazily binds symbols

On newer toolchains that by default set `-Wl,-z,now`, such as Gentoo's
23.0 toolchain, setting PRELOAD_GDK causes swell's dlopen() to fail with
an error like:

    Error loading '/opt/REAPER/libSwell.so': /opt/REAPER/libSwell.so: undefined symbol: gdk_x11_window_get_xid

This is because -z,now, according to the man page, "When generating an
executable or shared library, mark it to tell the dynamic linker to
resolve all symbols when the program is started, or when the shared
library is loaded by dlopen, instead of deferring function call
resolution to the point when the function is first called." This is
basically the opposite of what swell's preloading feature wants.

This can be overridden by setting -z,lazy, which according to the man
page, "When generating an executable or shared library, mark it to tell
the dynamic linker to defer function call resolution to the point when
the function is called (lazy binding), rather than at load time."

So pass -Wl,-z,lazy in the preloading case, so that it works no matter
what the toolchain defaults are.
---
 WDL/swell/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/WDL/swell/Makefile b/WDL/swell/Makefile
index 9e7e2d87..8033fb30 100644
--- a/WDL/swell/Makefile
+++ b/WDL/swell/Makefile
@@ -140,6 +140,9 @@ ifndef NOGDK
     endif
   endif
   LINKEXTRA += -lGL
+  ifdef PRELOAD_GDK
+    CFLAGS += -Wl,-z,lazy
+  endif
 endif
 
 CXXFLAGS = $(CFLAGS)
-- 
2.44.0