Skip to content

Commit d715fa3

Browse files
committed
Add rpath for libpython3.so
1 parent a30ce17 commit d715fa3

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed
Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
commit 34915211b42a64082e0470ebb9a8c4f2ebb20512
2+
Author: Zanie Blue <[email protected]>
3+
Date: Fri Nov 21 15:44:42 2025 -0600
4+
5+
Set linker arguments when `--enabled-relocatable` is used
6+
17
diff --git a/Makefile.pre.in b/Makefile.pre.in
2-
index 6c9cba59e27..39fc2e911d0 100644
8+
index 6c9cba59e27..6c89690c35e 100644
39
--- a/Makefile.pre.in
410
+++ b/Makefile.pre.in
5-
@@ -1028,7 +1028,12 @@ libpython3.so: libpython$(LDVERSION).so
6-
$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
11+
@@ -1025,10 +1025,19 @@ libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
12+
fi
13+
14+
libpython3.so: libpython$(LDVERSION).so
15+
- $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
16+
+ if [ "$(RELOCATABLE)" = "yes" ]; then \
17+
+ $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ -Wl,-rpath,'$$ORIGIN' $^; \
18+
+ else \
19+
+ $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^; \
20+
+ fi
721

822
libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
923
- $(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
@@ -17,7 +31,7 @@ index 6c9cba59e27..39fc2e911d0 100644
1731

1832
libpython$(VERSION).sl: $(LIBRARY_OBJS)
1933
diff --git a/configure b/configure
20-
index 38f2d4dfbf2..153add6ac12 100755
34+
index 38f2d4dfbf2..9991932680e 100755
2135
--- a/configure
2236
+++ b/configure
2337
@@ -13749,7 +13749,13 @@ then
@@ -35,19 +49,8 @@ index 38f2d4dfbf2..153add6ac12 100755
3549
# -u libsys_s pulls in all symbols in libsys
3650
Darwin/*|iOS/*)
3751
LINKFORSHARED="$extra_undefs -framework CoreFoundation"
38-
@@ -13774,6 +13780,10 @@ printf "%s\n" "#define THREAD_STACK_SIZE 0x$stack_size" >>confdefs.h
39-
if test "$enable_framework"; then
40-
LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
41-
fi
42-
+ # Add rpath for relocatable builds
43-
+ if test "x$enable_relocatable" = xyes; then
44-
+ LINKFORSHARED="$LINKFORSHARED -Wl,-rpath,@executable_path/../lib"
45-
+ fi
46-
LINKFORSHARED="$LINKFORSHARED"
47-
elif test $ac_sys_system = "iOS"; then
48-
LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)'
4952
diff --git a/configure.ac b/configure.ac
50-
index b1c859071f4..a40d279ebab 100644
53+
index b1c859071f4..f75f41441e2 100644
5154
--- a/configure.ac
5255
+++ b/configure.ac
5356
@@ -3613,7 +3613,13 @@ then
@@ -65,14 +68,3 @@ index b1c859071f4..a40d279ebab 100644
6568
# -u libsys_s pulls in all symbols in libsys
6669
Darwin/*|iOS/*)
6770
LINKFORSHARED="$extra_undefs -framework CoreFoundation"
68-
@@ -3638,6 +3644,10 @@ then
69-
if test "$enable_framework"; then
70-
LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
71-
fi
72-
+ # Add rpath for relocatable builds
73-
+ if test "x$enable_relocatable" = xyes; then
74-
+ LINKFORSHARED="$LINKFORSHARED -Wl,-rpath,@executable_path/../lib"
75-
+ fi
76-
LINKFORSHARED="$LINKFORSHARED"
77-
elif test $ac_sys_system = "iOS"; then
78-
LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)'

0 commit comments

Comments
 (0)