Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS, 3.x] Workaround Xcode 15 linker bug. #82009

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,17 @@ def get_compiler_version(env):
return None


def is_vanilla_clang(env):
if not using_clang(env):
return False
try:
version = decode_utf8(subprocess.check_output([env.subst(env["CXX"]), "--version"]).strip())
except (subprocess.CalledProcessError, OSError):
print("Couldn't parse CXX environment variable to infer compiler version.")
return False
return not version.startswith("Apple")


def using_gcc(env):
return "gcc" in os.path.basename(env["CC"])

Expand Down
9 changes: 8 additions & 1 deletion platform/osx/detect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
from methods import detect_darwin_sdk_path
from methods import detect_darwin_sdk_path, get_compiler_version, is_vanilla_clang


def is_active():
Expand Down Expand Up @@ -88,6 +88,13 @@ def configure(env):
env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.13"])
env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.13"])

cc_version = get_compiler_version(env) or [-1, -1]
vanilla = is_vanilla_clang(env)

# Workaround for Xcode 15 linker bug.
if not vanilla and cc_version[0] == 15 and cc_version[1] == 0:
env.Prepend(LINKFLAGS=["-ld_classic"])

if not "osxcross" in env: # regular native build
if env["macports_clang"] != "no":
mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
Expand Down
Loading