Skip to content

Commit cf56e26

Browse files
committed
Revert "[lldb][ClangExpressionParser] Set BuiltinHeadersInSystemModules depending on SDK version (#102309)"
This reverts commit 1cbcf74. unittests do not build because liblldbPluginExpressionParserClang.a now depends on liblldbPluginPlatformMacOSX.a when built on macOS, reverting until we can straighten out the dependency.
1 parent 4fe33d0 commit cf56e26

File tree

3 files changed

+3
-94
lines changed

3 files changed

+3
-94
lines changed

lldb/include/lldb/Utility/XcodeSDK.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,6 @@ class XcodeSDK {
8585
/// Whether LLDB feels confident importing Clang modules from this SDK.
8686
static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
8787
static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
88-
89-
/// Returns true if the SDK for the specified triple supports
90-
/// builtin modules in system headers.
91-
///
92-
/// NOTE: should be kept in sync with sdkSupportsBuiltinModules in
93-
/// Toolchains/Darwin.cpp
94-
///
95-
/// FIXME: this function will be removed once LLDB's ClangExpressionParser
96-
/// constructs the compiler instance through the driver/toolchain. See \ref
97-
/// SetupImportStdModuleLangOpts
98-
///
99-
static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
100-
llvm::VersionTuple sdk_version);
101-
10288
/// Return the canonical SDK name, such as "macosx" for the macOS SDK.
10389
static std::string GetCanonicalName(Info info);
10490
/// Return the best-matching SDK type for a specific triple.

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "clang/AST/ExternalASTSource.h"
1212
#include "clang/AST/PrettyPrinter.h"
1313
#include "clang/Basic/Builtins.h"
14-
#include "clang/Basic/DarwinSDKInfo.h"
1514
#include "clang/Basic/DiagnosticIDs.h"
1615
#include "clang/Basic/SourceLocation.h"
1716
#include "clang/Basic/TargetInfo.h"
@@ -40,7 +39,6 @@
4039
#include "llvm/ExecutionEngine/ExecutionEngine.h"
4140
#include "llvm/Support/CrashRecoveryContext.h"
4241
#include "llvm/Support/Debug.h"
43-
#include "llvm/Support/Error.h"
4442
#include "llvm/Support/FileSystem.h"
4543
#include "llvm/Support/TargetSelect.h"
4644

@@ -93,8 +91,6 @@
9391
#include "lldb/Utility/StringList.h"
9492

9593
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
96-
#include "Plugins/Platform/MacOSX/PlatformDarwin.h"
97-
#include "lldb/Utility/XcodeSDK.h"
9894

9995
#include <cctype>
10096
#include <memory>
@@ -283,49 +279,6 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer {
283279
std::string m_output;
284280
};
285281

286-
/// Returns true if the SDK for the specified triple supports
287-
/// builtin modules in system headers. This is used to decide
288-
/// whether to pass -fbuiltin-headers-in-system-modules to
289-
/// the compiler instance when compiling the `std` module.
290-
static llvm::Expected<bool>
291-
sdkSupportsBuiltinModules(lldb_private::Target &target) {
292-
#ifndef __APPLE__
293-
return false;
294-
#else
295-
auto arch_spec = target.GetArchitecture();
296-
auto const &triple = arch_spec.GetTriple();
297-
auto module_sp = target.GetExecutableModule();
298-
if (!module_sp)
299-
return llvm::createStringError("Executable module not found.");
300-
301-
// Get SDK path that the target was compiled against.
302-
auto sdk_or_err = PlatformDarwin::GetSDKPathFromDebugInfo(*module_sp);
303-
if (!sdk_or_err)
304-
return sdk_or_err.takeError();
305-
306-
// Use the SDK path from debug-info to find a local matching SDK directory.
307-
auto sdk_path_or_err =
308-
HostInfo::GetSDKRoot(HostInfo::SDKOptions{std::move(sdk_or_err->first)});
309-
if (!sdk_path_or_err)
310-
return sdk_path_or_err.takeError();
311-
312-
auto VFS = FileSystem::Instance().GetVirtualFileSystem();
313-
if (!VFS)
314-
return llvm::createStringError("No virtual filesystem available.");
315-
316-
// Extract SDK version from the /path/to/some.sdk/SDKSettings.json
317-
auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
318-
if (!parsed_or_err)
319-
return parsed_or_err.takeError();
320-
321-
auto maybe_sdk = *parsed_or_err;
322-
if (!maybe_sdk)
323-
return llvm::createStringError("Couldn't find Darwin SDK info.");
324-
325-
return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
326-
#endif
327-
}
328-
329282
static void SetupModuleHeaderPaths(CompilerInstance *compiler,
330283
std::vector<std::string> include_directories,
331284
lldb::TargetSP target_sp) {
@@ -608,9 +561,7 @@ static void SetupLangOpts(CompilerInstance &compiler,
608561
lang_opts.NoBuiltin = true;
609562
}
610563

611-
static void SetupImportStdModuleLangOpts(CompilerInstance &compiler,
612-
lldb_private::Target &target) {
613-
Log *log = GetLog(LLDBLog::Expressions);
564+
static void SetupImportStdModuleLangOpts(CompilerInstance &compiler) {
614565
LangOptions &lang_opts = compiler.getLangOpts();
615566
lang_opts.Modules = true;
616567
// We want to implicitly build modules.
@@ -627,14 +578,7 @@ static void SetupImportStdModuleLangOpts(CompilerInstance &compiler,
627578
lang_opts.GNUMode = true;
628579
lang_opts.GNUKeywords = true;
629580
lang_opts.CPlusPlus11 = true;
630-
631-
auto supported_or_err = sdkSupportsBuiltinModules(target);
632-
if (supported_or_err)
633-
lang_opts.BuiltinHeadersInSystemModules = !*supported_or_err;
634-
else
635-
LLDB_LOG_ERROR(log, supported_or_err.takeError(),
636-
"Failed to determine BuiltinHeadersInSystemModules when "
637-
"setting up import-std-module: {0}");
581+
lang_opts.BuiltinHeadersInSystemModules = true;
638582

639583
// The Darwin libc expects this macro to be set.
640584
lang_opts.GNUCVersion = 40201;
@@ -715,7 +659,7 @@ ClangExpressionParser::ClangExpressionParser(
715659
if (auto *clang_expr = dyn_cast<ClangUserExpression>(&m_expr);
716660
clang_expr && clang_expr->DidImportCxxModules()) {
717661
LLDB_LOG(log, "Adding lang options for importing C++ modules");
718-
SetupImportStdModuleLangOpts(*m_compiler, *target_sp);
662+
SetupImportStdModuleLangOpts(*m_compiler);
719663
SetupModuleHeaderPaths(m_compiler.get(), m_include_directories, target_sp);
720664
}
721665

lldb/source/Utility/XcodeSDK.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -259,27 +259,6 @@ bool XcodeSDK::SupportsSwift() const {
259259
}
260260
}
261261

262-
bool XcodeSDK::SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
263-
llvm::VersionTuple sdk_version) {
264-
using namespace llvm;
265-
266-
switch (target_triple.getOS()) {
267-
case Triple::OSType::MacOSX:
268-
return sdk_version >= VersionTuple(15U);
269-
case Triple::OSType::IOS:
270-
return sdk_version >= VersionTuple(18U);
271-
case Triple::OSType::TvOS:
272-
return sdk_version >= VersionTuple(18U);
273-
case Triple::OSType::WatchOS:
274-
return sdk_version >= VersionTuple(11U);
275-
case Triple::OSType::XROS:
276-
return sdk_version >= VersionTuple(2U);
277-
default:
278-
// New SDKs support builtin modules from the start.
279-
return true;
280-
}
281-
}
282-
283262
bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type,
284263
const FileSpec &sdk_path) {
285264
ConstString last_path_component = sdk_path.GetFilename();

0 commit comments

Comments
 (0)