Skip to content

Commit

Permalink
Merge pull request #85206 from bruvzg/mac_clang_version_check_update
Browse files Browse the repository at this point in the history
[macOS] Check Apple specific version instead of generic clang version.
  • Loading branch information
akien-mga committed Jan 18, 2024
2 parents d3003c4 + 5201475 commit 4db2a68
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
31 changes: 30 additions & 1 deletion methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,11 @@ def get_compiler_version(env):
"metadata1": None,
"metadata2": None,
"date": None,
"apple_major": -1,
"apple_minor": -1,
"apple_patch1": -1,
"apple_patch2": -1,
"apple_patch3": -1,
}

if not env.msvc:
Expand Down Expand Up @@ -1049,8 +1054,32 @@ def get_compiler_version(env):
for key, value in match.groupdict().items():
if value is not None:
ret[key] = value

match_apple = re.search(
r"(?:(?<=clang-)|(?<=\) )|(?<=^))"
r"(?P<apple_major>\d+)"
r"(?:\.(?P<apple_minor>\d*))?"
r"(?:\.(?P<apple_patch1>\d*))?"
r"(?:\.(?P<apple_patch2>\d*))?"
r"(?:\.(?P<apple_patch3>\d*))?",
version,
)
if match_apple is not None:
for key, value in match_apple.groupdict().items():
if value is not None:
ret[key] = value

# Transform semantic versioning to integers
for key in ["major", "minor", "patch"]:
for key in [
"major",
"minor",
"patch",
"apple_major",
"apple_minor",
"apple_patch1",
"apple_patch2",
"apple_patch3",
]:
ret[key] = int(ret[key] or -1)
return ret

Expand Down
6 changes: 3 additions & 3 deletions platform/macos/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def configure(env: "Environment"):
env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.13"])

cc_version = get_compiler_version(env)
cc_version_major = cc_version["major"]
cc_version_minor = cc_version["minor"]
cc_version_major = cc_version["apple_major"]
cc_version_minor = cc_version["apple_minor"]
vanilla = is_vanilla_clang(env)

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

env.Append(CCFLAGS=["-fobjc-arc"])
Expand Down

0 comments on commit 4db2a68

Please sign in to comment.