Skip to content

Commit cfe7cf8

Browse files
committed
GH-128469: set RPATH on the builddir Python executable
Signed-off-by: Filipe Laíns <[email protected]
1 parent f157485 commit cfe7cf8

File tree

4 files changed

+114
-104
lines changed

4 files changed

+114
-104
lines changed

Makefile.pre.in

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ MACHDEP_OBJS= @MACHDEP_OBJS@
301301
LIBOBJDIR= Python/
302302
LIBOBJS= @LIBOBJS@
303303

304+
BUILDPYTHON_LDFLAGS= @BUILDPYTHON_LDFLAGS@
305+
304306
PYTHON= python$(EXE)
305307
BUILDPYTHON= python$(BUILDEXE)
306308

@@ -727,7 +729,7 @@ list-targets:
727729
@grep -E '^[A-Za-z][-A-Za-z0-9]+:' Makefile | awk -F : '{print $$1}'
728730

729731
.PHONY: build_all
730-
build_all: check-clean-src check-app-store-compliance $(BUILDPYTHON) platform sharedmods \
732+
build_all: check-clean-src check-app-store-compliance $(BUILDPYTHON) python-bin platform sharedmods \
731733
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
732734

733735
.PHONY: build_wasm
@@ -911,9 +913,14 @@ clinic: check-clean-src
911913
clinic-tests: check-clean-src $(srcdir)/Lib/test/clinic.test.c
912914
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $(srcdir)/Lib/test/clinic.test.c
913915

914-
# Build the interpreter
916+
# Build the builddir interpreter (with RPATH to the local libpython)
915917
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS)
916-
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
918+
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) $(BUILDPYTHON_LDFLAGS) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
919+
920+
# Build the interpreter binary to install
921+
.PHONY: python-bin
922+
python-bin: Programs/python.o $(LINK_PYTHON_DEPS) pybuilddir.txt
923+
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o `cat pybuilddir.txt`/$(PYTHON) Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
917924

918925
platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
919926
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
@@ -2264,7 +2271,7 @@ sharedinstall: all
22642271
# Install the interpreter with $(VERSION) affixed
22652272
# This goes into $(exec_prefix)
22662273
.PHONY: altbininstall
2267-
altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
2274+
altbininstall: python-bin $(BUILDPYTHON) @FRAMEWORKPYTHONW@
22682275
@for i in $(BINDIR) $(LIBDIR); \
22692276
do \
22702277
if test ! -d $(DESTDIR)$$i; then \
@@ -2274,7 +2281,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
22742281
fi; \
22752282
done
22762283
if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
2277-
$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
2284+
$(INSTALL_PROGRAM) `cat pybuilddir.txt`/$(PYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
22782285
else \
22792286
$(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
22802287
fi

config.sub

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#! /bin/sh
22
# Configuration validation subroutine script.
3-
# Copyright 1992-2024 Free Software Foundation, Inc.
3+
# Copyright 1992-2023 Free Software Foundation, Inc.
44

55
# shellcheck disable=SC2006,SC2268 # see below for rationale
66

7-
# Patched 2024-02-03 to include support for arm64_32 and iOS/tvOS/watchOS simulators
8-
timestamp='2024-01-01'
7+
timestamp='2023-09-19'
98

109
# This file is free software; you can redistribute it and/or modify it
1110
# under the terms of the GNU General Public License as published by
@@ -77,7 +76,7 @@ Report bugs and patches to <[email protected]>."
7776
version="\
7877
GNU config.sub ($timestamp)
7978
80-
Copyright 1992-2024 Free Software Foundation, Inc.
79+
Copyright 1992-2023 Free Software Foundation, Inc.
8180
8281
This is free software; see the source for copying conditions. There is NO
8382
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -1128,7 +1127,7 @@ case $cpu-$vendor in
11281127
xscale-* | xscalee[bl]-*)
11291128
cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11301129
;;
1131-
arm64-* | aarch64le-* | arm64_32-*)
1130+
arm64-* | aarch64le-*)
11321131
cpu=aarch64
11331132
;;
11341133

@@ -1223,7 +1222,6 @@ case $cpu-$vendor in
12231222
| moxie \
12241223
| mt \
12251224
| msp430 \
1226-
| nanomips* \
12271225
| nds32 | nds32le | nds32be \
12281226
| nfp \
12291227
| nios | nios2 | nios2eb | nios2el \
@@ -1255,7 +1253,6 @@ case $cpu-$vendor in
12551253
| ubicom32 \
12561254
| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12571255
| vax \
1258-
| vc4 \
12591256
| visium \
12601257
| w65 \
12611258
| wasm32 | wasm64 \
@@ -1600,7 +1597,7 @@ case $cpu-$vendor in
16001597
os=
16011598
obj=elf
16021599
;;
1603-
mips*-*|nanomips*-*)
1600+
mips*-*)
16041601
os=
16051602
obj=elf
16061603
;;
@@ -1724,7 +1721,7 @@ fi
17241721

17251722
case $os in
17261723
# Sometimes we do "kernel-libc", so those need to count as OSes.
1727-
llvm* | musl* | newlib* | relibc* | uclibc*)
1724+
musl* | newlib* | relibc* | uclibc*)
17281725
;;
17291726
# Likewise for "kernel-abi"
17301727
eabi* | gnueabi*)
@@ -1769,19 +1766,12 @@ case $os in
17691766
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17701767
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17711768
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1772-
| fiwix* | mlibc* | cos* | mbr* | ironclad* )
1769+
| fiwix* | mlibc* | cos* | mbr* )
17731770
;;
17741771
# This one is extra strict with allowed versions
17751772
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17761773
# Don't forget version if it is 3.2v4 or newer.
17771774
;;
1778-
# This refers to builds using the UEFI calling convention
1779-
# (which depends on the architecture) and PE file format.
1780-
# Note that this is both a different calling convention and
1781-
# different file format than that of GNU-EFI
1782-
# (x86_64-w64-mingw32).
1783-
uefi)
1784-
;;
17851775
none)
17861776
;;
17871777
kernel* | msvc* )
@@ -1828,18 +1818,16 @@ esac
18281818
# As a final step for OS-related things, validate the OS-kernel combination
18291819
# (given a valid OS), if there is a kernel.
18301820
case $kernel-$os-$obj in
1831-
linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
1832-
| linux-mlibc*- | linux-musl*- | linux-newlib*- \
1833-
| linux-relibc*- | linux-uclibc*- )
1821+
linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \
1822+
| linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- )
18341823
;;
18351824
uclinux-uclibc*- )
18361825
;;
18371826
managarm-mlibc*- | managarm-kernel*- )
18381827
;;
18391828
windows*-msvc*-)
18401829
;;
1841-
-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
1842-
| -uclibc*- )
1830+
-dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- )
18431831
# These are just libc implementations, not actual OSes, and thus
18441832
# require a kernel.
18451833
echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
@@ -1867,8 +1855,6 @@ case $kernel-$os-$obj in
18671855
;;
18681856
*-eabi*- | *-gnueabi*-)
18691857
;;
1870-
ios*-simulator- | tvos*-simulator- | watchos*-simulator- )
1871-
;;
18721858
none--*)
18731859
# None (no kernel, i.e. freestanding / bare metal),
18741860
# can be paired with an machine code file format

configure

Lines changed: 51 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)