1+ commit aca24f2813298778421bd0f2fdb59b0ac860fd8c
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+
17diff --git a/Makefile.pre.in b/Makefile.pre.in
2- index 6c9cba59e27..39fc2e911d0 100644
8+ index 6c9cba59e27..ac6fbc46f09 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,22 @@ 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+ + lib_basename=$$(basename $^); \
18+ + echo "INPUT(\$$ORIGIN/$$lib_basename)" > .libpython3.so.ld; \
19+ + $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ .libpython3.so.ld; \
20+ + rm -f .libpython3.so.ld; \
21+ + else \
22+ + $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^; \
23+ + fi
724
825 libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
926- $(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 +34,7 @@ index 6c9cba59e27..39fc2e911d0 100644
1734
1835 libpython$(VERSION).sl: $(LIBRARY_OBJS)
1936diff --git a/configure b/configure
20- index 38f2d4dfbf2..153add6ac12 100755
37+ index 38f2d4dfbf2..9991932680e 100755
2138--- a/configure
2239+++ b/configure
2340@@ -13749,7 +13749,13 @@ then
@@ -35,19 +52,8 @@ index 38f2d4dfbf2..153add6ac12 100755
3552 # -u libsys_s pulls in all symbols in libsys
3653 Darwin/*|iOS/*)
3754 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)'
4955diff --git a/configure.ac b/configure.ac
50- index b1c859071f4..a40d279ebab 100644
56+ index b1c859071f4..f75f41441e2 100644
5157--- a/configure.ac
5258+++ b/configure.ac
5359@@ -3613,7 +3613,13 @@ then
@@ -65,14 +71,3 @@ index b1c859071f4..a40d279ebab 100644
6571 # -u libsys_s pulls in all symbols in libsys
6672 Darwin/*|iOS/*)
6773 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