summarylogtreecommitdiffstats
path: root/unbound-1.13.2-fix_libpython_linking.patch
blob: 450b114b81c662244653126d70d1e7dfbac38c24 (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
62
63
64
65
66
67
68
From 98087a051e657c4604050c3d1e6735950b9ea76f Mon Sep 17 00:00:00 2001
From: Chih-Hsuan Yen <yan12125@gmail.com>
Date: Fri, 23 Jul 2021 13:23:05 +0800
Subject: [PATCH] - Reduce unnecessary linking

- Link to libpython only when needed, fixes #242

When pyunbound is enabled while pythonmodule is not (i.e., ./configure
--without-pythonmodule --with-pyunbound), only the Python library
_unbound.so uses Python functions, and main programs (unbound,
unbound-anchor, ...) and libunbound.so do not. This patch removes
unneeded linking.

- Link the Python library _unbound.so to Python only. _unbound.so does
  not directly use libraries used by libunbound. This patch removes
  unneeded linking mentioned in [1]

[1] https://github.com/NLnetLabs/unbound/pull/511#issuecomment-886072003
---
 Makefile.in  |  3 ++-
 configure.ac | 12 ++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index ff5dc8fae..58413d7a5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -61,6 +61,7 @@ PYTHON_CPPFLAGS=-I. @PYTHON_CPPFLAGS@
 CFLAGS=-DSRCDIR=$(srcdir) @CFLAGS@
 LDFLAGS=@LDFLAGS@
 LIBS=@LIBS@
+PYTHON_LIBS=@PYTHON_LIBS@
 LIBOBJS=@LIBOBJS@
 # filter out ctime_r from compat obj.
 LIBOBJ_WITHOUT_CTIME=@LIBOBJ_WITHOUT_CTIME@
@@ -476,7 +477,7 @@ libunbound/python/libunbound_wrap.c:	$(srcdir)/libunbound/python/libunbound.i un
 
 # Pyunbound python unbound wrapper
 _unbound.la:	libunbound_wrap.lo libunbound.la
-	$(LIBTOOL) --tag=CC --mode=link $(CC) $(RUNTIME_PATH) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -module -avoid-version -no-undefined -shared -o $@ libunbound_wrap.lo -rpath $(PYTHON_SITE_PKG) -L. -L.libs libunbound.la $(LIBS)
+	$(LIBTOOL) --tag=CC --mode=link $(CC) $(RUNTIME_PATH) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -module -avoid-version -no-undefined -shared -o $@ libunbound_wrap.lo -rpath $(PYTHON_SITE_PKG) -L. -L.libs libunbound.la $(PYTHON_LIBS)
 
 util/config_file.c:	util/configparser.h
 util/configlexer.c:  $(srcdir)/util/configlexer.lex util/configparser.h
diff --git a/configure.ac b/configure.ac
index fe911723c..0fc1e00a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -699,11 +699,15 @@ if test x_$ub_test_python != x_no; then
       AC_SUBST(PY_MAJOR_VERSION)
       # Have Python
       AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
-      if test -n "$LIBS"; then
-        LIBS="$PYTHON_LDFLAGS $LIBS"
-      else
-        LIBS="$PYTHON_LDFLAGS"
+      if test x_$ub_with_pythonmod != x_no; then
+        if test -n "$LIBS"; then
+          LIBS="$PYTHON_LDFLAGS $LIBS"
+        else
+          LIBS="$PYTHON_LDFLAGS"
+        fi
       fi
+      PYTHON_LIBS="$PYTHON_LDFLAGS"
+      AC_SUBST(PYTHON_LIBS)
       if test -n "$CPPFLAGS"; then
         CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
       else