diff --git a/methods.py b/methods.py index 7a7758e24bc..288c34dc914 100644 --- a/methods.py +++ b/methods.py @@ -1012,6 +1012,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: @@ -1039,8 +1044,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\d+)" + r"(?:\.(?P\d*))?" + r"(?:\.(?P\d*))?" + r"(?:\.(?P\d*))?" + r"(?:\.(?P\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 diff --git a/platform/macos/detect.py b/platform/macos/detect.py index b41d2141fbf..33b6bbd6660 100644 --- a/platform/macos/detect.py +++ b/platform/macos/detect.py @@ -121,12 +121,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"])