Skip to content

Commit b8da1a4

Browse files
committed
Issue #25136: merge from 3.5
2 parents b118870 + 020250f commit b8da1a4

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

Lib/distutils/ccompiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,9 @@ def executable_filename(self, basename, strip_dir=0, output_dir=''):
875875
def library_filename(self, libname, lib_type='static', # or 'shared'
876876
strip_dir=0, output_dir=''):
877877
assert output_dir is not None
878-
if lib_type not in ("static", "shared", "dylib"):
878+
if lib_type not in ("static", "shared", "dylib", "xcode_stub"):
879879
raise ValueError(
880-
"'lib_type' must be \"static\", \"shared\" or \"dylib\"")
880+
"'lib_type' must be \"static\", \"shared\", \"dylib\", or \"xcode_stub\"")
881881
fmt = getattr(self, lib_type + "_lib_format")
882882
ext = getattr(self, lib_type + "_lib_extension")
883883

Lib/distutils/unixccompiler.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class UnixCCompiler(CCompiler):
7676
static_lib_extension = ".a"
7777
shared_lib_extension = ".so"
7878
dylib_lib_extension = ".dylib"
79+
xcode_stub_lib_extension = ".tbd"
7980
static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
81+
xcode_stub_lib_format = dylib_lib_format
8082
if sys.platform == "cygwin":
8183
exe_extension = ".exe"
8284

@@ -255,12 +257,28 @@ def library_option(self, lib):
255257
def find_library_file(self, dirs, lib, debug=0):
256258
shared_f = self.library_filename(lib, lib_type='shared')
257259
dylib_f = self.library_filename(lib, lib_type='dylib')
260+
xcode_stub_f = self.library_filename(lib, lib_type='xcode_stub')
258261
static_f = self.library_filename(lib, lib_type='static')
259262

260263
if sys.platform == 'darwin':
261264
# On OSX users can specify an alternate SDK using
262265
# '-isysroot', calculate the SDK root if it is specified
263266
# (and use it further on)
267+
#
268+
# Note that, as of Xcode 7, Apple SDKs may contain textual stub
269+
# libraries with .tbd extensions rather than the normal .dylib
270+
# shared libraries installed in /. The Apple compiler tool
271+
# chain handles this transparently but it can cause problems
272+
# for programs that are being built with an SDK and searching
273+
# for specific libraries. Callers of find_library_file need to
274+
# keep in mind that the base filename of the returned SDK library
275+
# file might have a different extension from that of the library
276+
# file installed on the running system, for example:
277+
# /Applications/Xcode.app/Contents/Developer/Platforms/
278+
# MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/
279+
# usr/lib/libedit.tbd
280+
# vs
281+
# /usr/lib/libedit.dylib
264282
cflags = sysconfig.get_config_var('CFLAGS')
265283
m = re.search(r'-isysroot\s+(\S+)', cflags)
266284
if m is None:
@@ -274,6 +292,7 @@ def find_library_file(self, dirs, lib, debug=0):
274292
shared = os.path.join(dir, shared_f)
275293
dylib = os.path.join(dir, dylib_f)
276294
static = os.path.join(dir, static_f)
295+
xcode_stub = os.path.join(dir, xcode_stub_f)
277296

278297
if sys.platform == 'darwin' and (
279298
dir.startswith('/System/') or (
@@ -282,13 +301,16 @@ def find_library_file(self, dirs, lib, debug=0):
282301
shared = os.path.join(sysroot, dir[1:], shared_f)
283302
dylib = os.path.join(sysroot, dir[1:], dylib_f)
284303
static = os.path.join(sysroot, dir[1:], static_f)
304+
xcode_stub = os.path.join(sysroot, dir[1:], xcode_stub_f)
285305

286306
# We're second-guessing the linker here, with not much hard
287307
# data to go on: GCC seems to prefer the shared library, so I'm
288308
# assuming that *all* Unix C compilers do. And of course I'm
289309
# ignoring even GCC's "-static" option. So sue me.
290310
if os.path.exists(dylib):
291311
return dylib
312+
elif os.path.exists(xcode_stub):
313+
return xcode_stub
292314
elif os.path.exists(shared):
293315
return shared
294316
elif os.path.exists(static):

Misc/NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ Build
763763
- Issue #26268: Update OS X 10.5 installer and Windows builds to use
764764
OpenSSL 1.0.2f.
765765

766+
- Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries.
766767

767768
Windows
768769
-------

setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ def find_library_file(compiler, libname, std_dirs, paths):
136136
p = p.rstrip(os.sep)
137137

138138
if host_platform == 'darwin' and is_macosx_sdk_path(p):
139+
# Note that, as of Xcode 7, Apple SDKs may contain textual stub
140+
# libraries with .tbd extensions rather than the normal .dylib
141+
# shared libraries installed in /. The Apple compiler tool
142+
# chain handles this transparently but it can cause problems
143+
# for programs that are being built with an SDK and searching
144+
# for specific libraries. Distutils find_library_file() now
145+
# knows to also search for and return .tbd files. But callers
146+
# of find_library_file need to keep in mind that the base filename
147+
# of the returned SDK library file might have a different extension
148+
# from that of the library file installed on the running system,
149+
# for example:
150+
# /Applications/Xcode.app/Contents/Developer/Platforms/
151+
# MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/
152+
# usr/lib/libedit.tbd
153+
# vs
154+
# /usr/lib/libedit.dylib
139155
if os.path.join(sysroot, p[1:]) == dirname:
140156
return [ ]
141157

0 commit comments

Comments
 (0)