https://github.com/ian-twilightcoder created https://github.com/llvm/llvm-project/pull/181897
-isysroot can be an unrecognized value in unusual circumstances. Don't emit an error when checking the triple against such an isysroot, let the user try to do what they're trying to do. >From 02d733809b0a1ca95a832c888bd51d1bd40764aa Mon Sep 17 00:00:00 2001 From: Ian Anderson <[email protected]> Date: Tue, 17 Feb 2026 12:10:56 -0800 Subject: [PATCH] [clang][driver] Don't emit an error on an unrecognized SDK name -isysroot can be an unrecognized value in unusual circumstances. Don't emit an error when checking the triple against such an isysroot, let the user try to do what they're trying to do. --- clang/lib/Driver/ToolChains/Darwin.cpp | 13 ++++++------- .../XRSimulator1.0.sdk/usr/include/libxml/.keep | 0 clang/test/Driver/incompatible_sysroot.c | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 clang/test/Driver/Inputs/XRSimulator1.0.sdk/usr/include/libxml/.keep diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 1c95a79a52a9c..0650b49017290 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1145,11 +1145,11 @@ void Darwin::VerifyTripleForSDK(const llvm::opt::ArgList &Args, getDriver().Diag(diag::warn_incompatible_sysroot) << SDKInfo->getDisplayName() << Triple.getTriple(); } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { + // If there is no SDK info, assume this is building against an SDK that + // predates SDKSettings.json. Try to match the triple to the SDK path. const char *isysroot = A->getValue(); - StringRef SDK = getSDKName(isysroot); - if (!SDK.empty()) { - size_t StartVer = SDK.find_first_of("0123456789"); - StringRef SDKName = SDK.slice(0, StartVer); + StringRef SDKName = getSDKName(isysroot); + if (!SDKName.empty()) { bool supported = true; if (Triple.isWatchOS()) supported = SDKName.starts_with("Watch"); @@ -1161,9 +1161,8 @@ void Darwin::VerifyTripleForSDK(const llvm::opt::ArgList &Args, supported = SDKName.starts_with("iPhone"); else if (Triple.isMacOSX()) supported = SDKName.starts_with("MacOSX"); - else - llvm::reportFatalUsageError(Twine("SDK at '") + isysroot + - "' missing SDKSettings.json."); + // If it's not an older SDK, then it might be a damaged SDK or a + // non-standard -isysroot path. Don't try to diagnose that here. if (!supported) getDriver().Diag(diag::warn_incompatible_sysroot) diff --git a/clang/test/Driver/Inputs/XRSimulator1.0.sdk/usr/include/libxml/.keep b/clang/test/Driver/Inputs/XRSimulator1.0.sdk/usr/include/libxml/.keep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/incompatible_sysroot.c b/clang/test/Driver/incompatible_sysroot.c index a5f7d03da7254..ee88d241a3496 100644 --- a/clang/test/Driver/incompatible_sysroot.c +++ b/clang/test/Driver/incompatible_sysroot.c @@ -12,6 +12,7 @@ // RUN: %clang -target arm64-apple-visionos1.0-simulator -Wincompatible-sysroot -isysroot %S/Inputs/XRSimulator1.0.sdk -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-VISIONOSSIM %s // RUN: %clang -target arm64-apple-xros1.0 -Wincompatible-sysroot -isysroot %S/Inputs/XRSimulator1.0.sdk -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-VISIONOSSIM-VISIONOS %s // RUN: %clang -target arm64-apple-ios17.1 -Wincompatible-sysroot -isysroot %S/Inputs/XRSimulator1.0.sdk -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-VISIONOSSIM-IOS %s +// RUN: %clang -target arm64-apple-visionos1.0-simulator -Wincompatible-sysroot -isysroot %S/Inputs/XRSimulator1.0.sdk/usr/include/libxml -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-VISIONOSSIM %s int main() { return 0; } // CHECK-OSX-IOS: warning: using sysroot for 'MacOSX' but targeting 'x86_64-apple-ios9.0.0-simulator' _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
