summaryrefslogtreecommitdiff
blob: 357274c491df315d74d90839555aa76dc8c1884c (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
# HG changeset patch
# User Martin v. Löwis <martin@v.loewis.de>
# Date 1304919465 -7200
# Node ID 749686064642118c5ccc8ad28105472321931353
# Parent  4f3f67a595fb05f04d89ed906df911b743e47463
Use --as-needed when linking libpython3.so. Closes #11347.
Patch by Arfrever Frehtes Taifersar Arahesis.

diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -76,6 +76,7 @@ PY_CFLAGS=	$(BASECFLAGS) $(OPT) $(CONFIG
 # environment variables
 PY_CPPFLAGS=	-I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
 PY_LDFLAGS=	$(CONFIGURE_LDFLAGS) $(LDFLAGS)
+NO_AS_NEEDED=	@NO_AS_NEEDED@
 LDLAST=		@LDLAST@
 SGI_ABI=	@SGI_ABI@
 CCSHARED=	@CCSHARED@
@@ -459,7 +460,7 @@ libpython$(LDVERSION).so: $(LIBRARY_OBJS
 	fi
 
 libpython3.so:	libpython$(LDVERSION).so
-	$(BLDSHARED) -o $@ -Wl,-hl$@ $^
+	$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
 
 libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
 	 $(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -525,6 +525,18 @@ then
 fi
 
 
+AC_MSG_CHECKING([for -Wl,--no-as-needed])
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+  [NO_AS_NEEDED="-Wl,--no-as-needed"
+   AC_MSG_RESULT([yes])],
+  [NO_AS_NEEDED=""
+   AC_MSG_RESULT([no])])
+LDFLAGS="$save_LDFLAGS"
+AC_SUBST(NO_AS_NEEDED)
+
+
 # checks for UNIX variants that set C preprocessor variables
 AC_USE_SYSTEM_EXTENSIONS