Author: Charles Zablit Date: 2025-08-04T11:39:15+02:00 New Revision: 440a4de55265c67cf41a77e40f96d7c18ed7590a
URL: https://github.com/llvm/llvm-project/commit/440a4de55265c67cf41a77e40f96d7c18ed7590a DIFF: https://github.com/llvm/llvm-project/commit/440a4de55265c67cf41a77e40f96d7c18ed7590a.diff LOG: [lldb][darwin] force BuiltinHeadersInSystemModules to be always false (#151535) This is a re-landing of https://github.com/llvm/llvm-project/pull/144913, which was reverted because of tests failing on Darwin. The bots were failing because the x64 bots run the macOS 14.0 SDKs whereas we assumed all the bots were running the macOS 15.0+ SDKs. To address this, we deactivated the failing tests on SDKs that are older than 15.0 in https://github.com/llvm/llvm-project/pull/147768. Now that this is merged, we can re-land https://github.com/llvm/llvm-project/pull/144913. Added: Modified: lldb/include/lldb/Utility/XcodeSDK.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Utility/XcodeSDK.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h index ceb8abb8c502d..a1a0ec415b90e 100644 --- a/lldb/include/lldb/Utility/XcodeSDK.h +++ b/lldb/include/lldb/Utility/XcodeSDK.h @@ -93,19 +93,6 @@ class XcodeSDK { static bool SDKSupportsModules(Type type, llvm::VersionTuple version); static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path); - /// Returns true if the SDK for the specified triple supports - /// builtin modules in system headers. - /// - /// NOTE: should be kept in sync with sdkSupportsBuiltinModules in - /// Toolchains/Darwin.cpp - /// - /// FIXME: this function will be removed once LLDB's ClangExpressionParser - /// constructs the compiler instance through the driver/toolchain. See \ref - /// SetupImportStdModuleLangOpts - /// - static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple, - llvm::VersionTuple sdk_version); - /// Return the canonical SDK name, such as "macosx" for the macOS SDK. static std::string GetCanonicalName(Info info); /// Return the best-matching SDK type for a specific triple. diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index c32e6377c24ff..86ff010e760fa 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -319,49 +319,6 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { StringRef m_filename; }; -/// Returns true if the SDK for the specified triple supports -/// builtin modules in system headers. This is used to decide -/// whether to pass -fbuiltin-headers-in-system-modules to -/// the compiler instance when compiling the `std` module. -static llvm::Expected<bool> -sdkSupportsBuiltinModules(lldb_private::Target &target) { - auto arch_spec = target.GetArchitecture(); - auto const &triple = arch_spec.GetTriple(); - auto module_sp = target.GetExecutableModule(); - if (!module_sp) - return llvm::createStringError("Executable module not found."); - - // Get SDK path that the target was compiled against. - auto platform_sp = target.GetPlatform(); - if (!platform_sp) - return llvm::createStringError("No Platform plugin found on target."); - - auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp); - if (!sdk_or_err) - return sdk_or_err.takeError(); - - // Use the SDK path from debug-info to find a local matching SDK directory. - auto sdk_path_or_err = - HostInfo::GetSDKRoot(HostInfo::SDKOptions{std::move(sdk_or_err->first)}); - if (!sdk_path_or_err) - return sdk_path_or_err.takeError(); - - auto VFS = FileSystem::Instance().GetVirtualFileSystem(); - if (!VFS) - return llvm::createStringError("No virtual filesystem available."); - - // Extract SDK version from the /path/to/some.sdk/SDKSettings.json - auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err); - if (!parsed_or_err) - return parsed_or_err.takeError(); - - auto maybe_sdk = *parsed_or_err; - if (!maybe_sdk) - return llvm::createStringError("Couldn't find Darwin SDK info."); - - return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion()); -} - static void SetupModuleHeaderPaths(CompilerInstance *compiler, std::vector<std::string> include_directories, lldb::TargetSP target_sp) { @@ -705,7 +662,6 @@ static void SetupLangOpts(CompilerInstance &compiler, static void SetupImportStdModuleLangOpts(CompilerInstance &compiler, lldb_private::Target &target) { - Log *log = GetLog(LLDBLog::Expressions); LangOptions &lang_opts = compiler.getLangOpts(); lang_opts.Modules = true; // We want to implicitly build modules. @@ -723,12 +679,7 @@ static void SetupImportStdModuleLangOpts(CompilerInstance &compiler, lang_opts.GNUKeywords = true; lang_opts.CPlusPlus11 = true; - if (auto supported_or_err = sdkSupportsBuiltinModules(target)) - lang_opts.BuiltinHeadersInSystemModules = !*supported_or_err; - else - LLDB_LOG_ERROR(log, supported_or_err.takeError(), - "Failed to determine BuiltinHeadersInSystemModules when " - "setting up import-std-module: {0}"); + lang_opts.BuiltinHeadersInSystemModules = false; // The Darwin libc expects this macro to be set. lang_opts.GNUCVersion = 40201; diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp index 004b4717e315b..eb2047e67c326 100644 --- a/lldb/source/Utility/XcodeSDK.cpp +++ b/lldb/source/Utility/XcodeSDK.cpp @@ -266,27 +266,6 @@ bool XcodeSDK::SupportsSwift() const { } } -bool XcodeSDK::SDKSupportsBuiltinModules(const llvm::Triple &target_triple, - llvm::VersionTuple sdk_version) { - using namespace llvm; - - switch (target_triple.getOS()) { - case Triple::OSType::MacOSX: - return sdk_version >= VersionTuple(15U); - case Triple::OSType::IOS: - return sdk_version >= VersionTuple(18U); - case Triple::OSType::TvOS: - return sdk_version >= VersionTuple(18U); - case Triple::OSType::WatchOS: - return sdk_version >= VersionTuple(11U); - case Triple::OSType::XROS: - return sdk_version >= VersionTuple(2U); - default: - // New SDKs support builtin modules from the start. - return true; - } -} - bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type, const FileSpec &sdk_path) { ConstString last_path_component = sdk_path.GetFilename(); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits