Skip to content

Commit

Permalink
Issue #569: Use old linker when building with Xcode 15
Browse files Browse the repository at this point in the history
A known issue with Xcode 15 is that weak symbols don't work
when targetting earlier macOS versions (before macOS 12). Switch
to using the old linker until that issue is fixed.
  • Loading branch information
ronaldoussoren committed Sep 16, 2023
1 parent b578f75 commit 966ddd0
Show file tree
Hide file tree
Showing 155 changed files with 1,392 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ Version 10.0
* ``dispatch.dispatch_source_t`` is renamed to ``dispatch.dispatch_source_type_t``
to match the type name in C code.

* :issue:`569`: Xcode 15 has a bug when using weak symbols and targeting older macOS
versions. Switch to the old linker when detecting Xcode 15.

Version 9.2.1
-------------

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-core/Tools/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
14 changes: 12 additions & 2 deletions pyobjc-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def get_sdk_level(sdk):
# "-O0",
"-g",
# "-O0",
# "-O3",
# "-flto=thin",
"-O3",
"-flto=thin",
# XXX: Use object_path_lto (during linking?)
"-UNDEBUG",
]
Expand Down Expand Up @@ -576,6 +576,16 @@ def finalize_options(self):
CFLAGS.append("-DNO_OBJC2_RUNTIME")
EXT_CFLAGS.append("-DNO_OBJC2_RUNTIME")

lines = subprocess.check_output(
["xcodebuild", "-version"], text=True
).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
for var in (OBJC_LDFLAGS,):
print("Use old linker with Xcode 15 or later")
var.append("-Wl,-ld_classic")

def run(self):
verify_platform()

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AVFoundation/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AVKit/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AVRouting/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-Accessibility/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-Accounts/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AdServices/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AdSupport/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AddressBook/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AppTrackingTransparency/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AppleScriptKit/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AppleScriptObjC/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-ApplicationServices/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AudioVideoBridging/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-AuthenticationServices/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-Automator/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-BackgroundAssets/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-BusinessChat/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-CFNetwork/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-CalendarStore/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
9 changes: 9 additions & 0 deletions pyobjc-framework-CallKit/pyobjc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

# XCode 15 has a bug w.r.t. weak linking for older macOS versions,
# fall back to older linker when using that compiler.
# XXX: This should be in _fixup_compiler but doesn't work there...
lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
if lines[0].startswith("Xcode"):
xcode_vers = int(lines[0].split()[-1].split(".")[0])
if xcode_vers >= 15:
ldflags.append("-Wl,-ld_classic")

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

Expand Down
Loading

0 comments on commit 966ddd0

Please sign in to comment.