Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-4032: Cygwin: Add .dll.a to UnixCCompiler for searching libraries
Allow the UnixCCompiler.find_library_file to correctly find DLL import
libs (.dll.a).
  • Loading branch information
ma8ma authored and embray committed Jun 12, 2019
commit 22061578c5e17c58d4f18716ddc17d8916ebb3b1
7 changes: 4 additions & 3 deletions Lib/distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,10 @@ def executable_filename(self, basename, strip_dir=0, output_dir=''):
def library_filename(self, libname, lib_type='static', # or 'shared'
strip_dir=0, output_dir=''):
assert output_dir is not None
if lib_type not in ("static", "shared", "dylib", "xcode_stub"):
raise ValueError(
"'lib_type' must be \"static\", \"shared\", \"dylib\", or \"xcode_stub\"")
if lib_type not in ("static", "shared", "dylib", "xcode_stub",
"implib"):
raise ValueError("'lib_type' must be \"static\", \"shared\", "
"\"dylib\", \"xcode_stub\", or \"implib\"")
fmt = getattr(self, lib_type + "_lib_format")
ext = getattr(self, lib_type + "_lib_extension")

Expand Down
8 changes: 7 additions & 1 deletion Lib/distutils/unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class UnixCCompiler(CCompiler):
shared_lib_extension = ".so"
dylib_lib_extension = ".dylib"
xcode_stub_lib_extension = ".tbd"
implib_lib_extension = ".dll.a"
static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
xcode_stub_lib_format = dylib_lib_format
implib_lib_format = xcode_stub_lib_format = dylib_lib_format
if sys.platform == "cygwin":
exe_extension = ".exe"

Expand Down Expand Up @@ -266,6 +267,7 @@ def find_library_file(self, dirs, lib, debug=0):
shared_f = self.library_filename(lib, lib_type='shared')
dylib_f = self.library_filename(lib, lib_type='dylib')
xcode_stub_f = self.library_filename(lib, lib_type='xcode_stub')
implib_f = self.library_filename(lib, lib_type='implib')
static_f = self.library_filename(lib, lib_type='static')

if sys.platform == 'darwin':
Expand Down Expand Up @@ -301,6 +303,7 @@ def find_library_file(self, dirs, lib, debug=0):
dylib = os.path.join(dir, dylib_f)
static = os.path.join(dir, static_f)
xcode_stub = os.path.join(dir, xcode_stub_f)
implib = os.path.join(dir, implib_f)

if sys.platform == 'darwin' and (
dir.startswith('/System/') or (
Expand All @@ -310,6 +313,7 @@ def find_library_file(self, dirs, lib, debug=0):
dylib = os.path.join(sysroot, dir[1:], dylib_f)
static = os.path.join(sysroot, dir[1:], static_f)
xcode_stub = os.path.join(sysroot, dir[1:], xcode_stub_f)
implib = os.path.join(sysroot, dir[1:], implib_f)

# We're second-guessing the linker here, with not much hard
# data to go on: GCC seems to prefer the shared library, so I'm
Expand All @@ -319,6 +323,8 @@ def find_library_file(self, dirs, lib, debug=0):
return dylib
elif os.path.exists(xcode_stub):
return xcode_stub
elif os.path.exists(implib):
return implib
elif os.path.exists(shared):
return shared
elif os.path.exists(static):
Expand Down