From 8fefaad242f45b3bd97e000a00f2aac16d935315 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 9 Nov 2021 10:06:41 +0200 Subject: [PATCH] bpo-45743: -Wl,-search_paths_first is no longer needed (GH-29464) --- .../2021-11-08-08-58-06.bpo-45743.fZ8CTi.rst | 2 + configure | 16 -------- configure.ac | 26 ------------ setup.py | 41 ++----------------- 4 files changed, 5 insertions(+), 80 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2021-11-08-08-58-06.bpo-45743.fZ8CTi.rst diff --git a/Misc/NEWS.d/next/Build/2021-11-08-08-58-06.bpo-45743.fZ8CTi.rst b/Misc/NEWS.d/next/Build/2021-11-08-08-58-06.bpo-45743.fZ8CTi.rst new file mode 100644 index 00000000000..7241bd96371 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-08-08-58-06.bpo-45743.fZ8CTi.rst @@ -0,0 +1,2 @@ +On macOS, the build system no longer passes ``search_paths_first`` to the +linker. The flag has been the default since Xcode 4 / macOS 10.6. diff --git a/configure b/configure index cd25c1d68e1..76d9c499361 100755 --- a/configure +++ b/configure @@ -12886,15 +12886,6 @@ $as_echo "#define HAVE_LCHFLAGS 1" >>confdefs.h fi # Check for compression libraries -case $ac_sys_system/$ac_sys_release in -Darwin/*) - _CUR_CFLAGS="${CFLAGS}" - _CUR_LDFLAGS="${LDFLAGS}" - CFLAGS="${CFLAGS} -Wl,-search_paths_first" - LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 $as_echo_n "checking for inflateCopy in -lz... " >&6; } if ${ac_cv_lib_z_inflateCopy+:} false; then : @@ -12938,13 +12929,6 @@ $as_echo "#define HAVE_ZLIB_COPY 1" >>confdefs.h fi -case $ac_sys_system/$ac_sys_release in -Darwin/*) - CFLAGS="${_CUR_CFLAGS}" - LDFLAGS="${_CUR_LDFLAGS}" - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hstrerror" >&5 diff --git a/configure.ac b/configure.ac index 87cf10251b2..8ea5d491a96 100644 --- a/configure.ac +++ b/configure.ac @@ -3833,34 +3833,8 @@ fi # Check for compression libraries dnl Check if system zlib has *Copy() functions -dnl -dnl On MacOSX the linker will search for dylibs on the entire linker path -dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first -dnl to revert to a more traditional unix behaviour and make it possible to -dnl override the system libz with a local static library of libz. Temporarily -dnl add that flag to our CFLAGS as well to ensure that we check the version -dnl of libz that will be used by setup.py. -dnl The -L/usr/local/lib is needed as wel to get the same compilation -dnl environment as setup.py (and leaving it out can cause configure to use the -dnl wrong version of the library) -case $ac_sys_system/$ac_sys_release in -Darwin/*) - _CUR_CFLAGS="${CFLAGS}" - _CUR_LDFLAGS="${LDFLAGS}" - CFLAGS="${CFLAGS} -Wl,-search_paths_first" - LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" - ;; -esac - AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])) -case $ac_sys_system/$ac_sys_release in -Darwin/*) - CFLAGS="${_CUR_CFLAGS}" - LDFLAGS="${_CUR_LDFLAGS}" - ;; -esac - PY_CHECK_FUNC([hstrerror], [#include ]) PY_CHECK_FUNC([inet_aton], [ diff --git a/setup.py b/setup.py index fb641bd57d0..fa7abef95b0 100644 --- a/setup.py +++ b/setup.py @@ -1118,16 +1118,6 @@ class PyBuildExt(build_ext): if find_file('readline/rlconf.h', self.inc_dirs, []) is None: do_readline = False if do_readline: - if MACOS and os_release < 9: - # In every directory on the search path search for a dynamic - # library and then a static library, instead of first looking - # for dynamic libraries on the entire path. - # This way a statically linked custom readline gets picked up - # before the (possibly broken) dynamic library in /usr/lib. - readline_extra_link_args = ('-Wl,-search_paths_first',) - else: - readline_extra_link_args = () - readline_libs = [readline_lib] if readline_termcap_library: pass # Issue 7384: Already linked against curses or tinfo. @@ -1139,7 +1129,6 @@ class PyBuildExt(build_ext): readline_libs.append('termcap') self.add(Extension('readline', ['readline.c'], library_dirs=['/usr/lib/termcap'], - extra_link_args=readline_extra_link_args, libraries=readline_libs)) else: self.missing.append('readline') @@ -1603,16 +1592,6 @@ class PyBuildExt(build_ext): ): raise DistutilsError("System version of SQLite does not support loadable extensions") - if MACOS: - # In every directory on the search path search for a dynamic - # library and then a static library, instead of first looking - # for dynamic libraries on the entire path. - # This way a statically linked custom sqlite gets picked up - # before the dynamic library in /usr/lib. - sqlite_extra_link_args = ('-Wl,-search_paths_first',) - else: - sqlite_extra_link_args = () - include_dirs = ["Modules/_sqlite"] # Only include the directory where sqlite was found if it does # not already exist in set include directories, otherwise you @@ -1626,7 +1605,6 @@ class PyBuildExt(build_ext): define_macros=sqlite_defines, include_dirs=include_dirs, library_dirs=sqlite_libdir, - extra_link_args=sqlite_extra_link_args, libraries=["sqlite3",])) else: self.missing.append('_sqlite3') @@ -1685,13 +1663,8 @@ class PyBuildExt(build_ext): break if version >= version_req: if (self.compiler.find_library_file(self.lib_dirs, 'z')): - if MACOS: - zlib_extra_link_args = ('-Wl,-search_paths_first',) - else: - zlib_extra_link_args = () self.add(Extension('zlib', ['zlibmodule.c'], - libraries=['z'], - extra_link_args=zlib_extra_link_args)) + libraries=['z'])) have_zlib = True else: self.missing.append('zlib') @@ -1706,24 +1679,16 @@ class PyBuildExt(build_ext): if have_zlib: extra_compile_args.append('-DUSE_ZLIB_CRC32') libraries = ['z'] - extra_link_args = zlib_extra_link_args else: libraries = [] - extra_link_args = [] self.add(Extension('binascii', ['binascii.c'], extra_compile_args=extra_compile_args, - libraries=libraries, - extra_link_args=extra_link_args)) + libraries=libraries)) # Gustavo Niemeyer's bz2 module. if (self.compiler.find_library_file(self.lib_dirs, 'bz2')): - if MACOS: - bz2_extra_link_args = ('-Wl,-search_paths_first',) - else: - bz2_extra_link_args = () self.add(Extension('_bz2', ['_bz2module.c'], - libraries=['bz2'], - extra_link_args=bz2_extra_link_args)) + libraries=['bz2'])) else: self.missing.append('_bz2')