[clang] [clang][darwin] macOS no longer infers a minimum deployment version from the OS version (PR #181958)
Ian Anderson via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 17 18:49:37 PST 2026
https://github.com/ian-twilightcoder created https://github.com/llvm/llvm-project/pull/181958
The recent createFromSDKInfo refactor lost the getSystemOrSDKMacOSVersion version adjustment on macOS, causing -arch builds to create binaries that can't run on the host that built them.
>From 92814000d773ea720b6b932ca7682b20459b1cda Mon Sep 17 00:00:00 2001
From: Ian Anderson <iana at apple.com>
Date: Tue, 17 Feb 2026 18:44:25 -0800
Subject: [PATCH] [clang][darwin] macOS no longer infers a minimum deployment
version from the OS version
The recent createFromSDKInfo refactor lost the getSystemOrSDKMacOSVersion version adjustment on macOS, causing -arch builds to create binaries that can't run on the host that built them.
---
clang/lib/Driver/ToolChains/Darwin.cpp | 10 +++++++---
clang/test/Driver/darwin-sdk-vs-os-version.c | 6 +++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 1c95a79a52a9c..d7541008bdb64 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1938,9 +1938,13 @@ struct DarwinPlatform {
const DarwinSDKInfo &SDKInfo) {
const DarwinSDKInfo::SDKPlatformInfo PlatformInfo =
SDKInfo.getCanonicalPlatformInfo();
- DarwinPlatform Result(InferredFromSDK,
- getPlatformFromOS(PlatformInfo.getOS()),
- SDKInfo.getVersion());
+ const llvm::Triple::OSType OS = PlatformInfo.getOS();
+ VersionTuple Version = SDKInfo.getVersion();
+ if (OS == llvm::Triple::MacOSX) {
+ Version = getVersionFromString(
+ getSystemOrSDKMacOSVersion(Version.getAsString()));
+ }
+ DarwinPlatform Result(InferredFromSDK, getPlatformFromOS(OS), Version);
Result.Environment = getEnvKindFromEnvType(PlatformInfo.getEnvironment());
Result.InferSimulatorFromArch = false;
Result.InferredSource = SDKRoot;
diff --git a/clang/test/Driver/darwin-sdk-vs-os-version.c b/clang/test/Driver/darwin-sdk-vs-os-version.c
index 94e52a9036ede..346161452216e 100644
--- a/clang/test/Driver/darwin-sdk-vs-os-version.c
+++ b/clang/test/Driver/darwin-sdk-vs-os-version.c
@@ -7,4 +7,8 @@
// RUN: %clang -target x86_64-apple-darwin -isysroot %t/SDKs/MacOSX99.99.99.sdk %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
-// CHECK-MACOSX-SYSTEM-VERSION-NOT: 99.99.99"
+// RUN: sed -e 's/15\.1/99\.99\.99/g' %S/Inputs/MacOSX15.1.sdk/SDKSettings.json > %t/SDKs/MacOSX99.99.99.sdk/SDKSettings.json
+// RUN: %clang -target x86_64-apple-darwin -isysroot %t/SDKs/MacOSX99.99.99.sdk %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
+
+// CHECK-MACOSX-SYSTEM-VERSION-NOT: "-triple" "{{[[:alnum:]_-]*}}99.99.99"
More information about the cfe-commits
mailing list