diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index 0ea9cfe..1a24d5b 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -1098,6 +1098,8 @@ def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries): else: lib_opts.append(opt) + lib_opts.append("-Wl,-Bdynamic") + # XXX it's important that we *not* remove redundant library mentions! # sometimes you really do have to say "-lfoo -lbar -lfoo" in order to # resolve all symbols. I just hope we never have to say "-lfoo obj.o @@ -1115,4 +1117,6 @@ def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries): "'%s' found (skipping)" % lib) else: lib_opts.append(compiler.library_option (lib)) + + lib_opts.append("-Wl,-Bstatic") return lib_opts diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py index dddf412..3edccb6 100644 --- a/Lib/distutils/cygwinccompiler.py +++ b/Lib/distutils/cygwinccompiler.py @@ -413,6 +413,9 @@ def _find_exe_version(cmd): out_string = out.read() finally: out.close() + out_string = out_string.split(b'\n',1)[0].replace(b'-win32',b'') + if out_string.isdigit(): + return out_string.decode() result = RE_VERSION.search(out_string) if result is None: return None diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py index f159586..004e89f 100644 --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -200,6 +200,9 @@ class UnixCCompiler(CCompiler): if sys.platform == 'darwin': linker = _osx_support.compiler_fixup(linker, ld_args) + else: + ld_args += linker[i+offset+1:] + linker = [linker[i+offset]] self.spawn(linker + ld_args) except DistutilsExecError as msg: diff --git a/Misc/python.pc.in b/Misc/python.pc.in index 3900190..a14e42b 100644 --- a/Misc/python.pc.in +++ b/Misc/python.pc.in @@ -9,5 +9,5 @@ Description: Build a C extension for Python Requires: Version: @VERSION@ Libs.private: @LIBS@ -Libs: -L${libdir} -lpython@VERSION@@ABIFLAGS@ +Libs: -L${libdir} -L${prefix}/bin -Wl,-Bdynamic -lpython@VERSION@@ABIFLAGS@ -Wl,-Bstatic Cflags: -I${includedir}/python@VERSION@@ABIFLAGS@ diff --git a/configure.ac b/configure.ac index 6210e41..51432a8 100644 --- a/configure.ac +++ b/configure.ac @@ -1297,7 +1297,7 @@ if test $enable_shared = "yes"; then *-*-mingw*) LDLIBRARY='libpython$(LDVERSION).dll.a' DLLLIBRARY='libpython$(LDVERSION).dll' - BLDLIBRARY='-L. -lpython$(LDVERSION)' + BLDLIBRARY='-L. -Wl,-Bdynamic -lpython$(LDVERSION) -Wl,-Bstatic' ;; esac else # shared is disabled diff --git a/setup.py b/setup.py index 3a7a2e7..88e116a 100644 --- a/setup.py +++ b/setup.py @@ -2289,7 +2289,7 @@ class PyBuildExt(build_ext): # poor man's shlex, the re module is not available yet. value = config_vars.get(name) if not value: - return () + return [] # This trick works because ax_check_openssl uses --libs-only-L, # --libs-only-l, and --cflags-only-I. value = ' ' + value