Skip to content

[lldb] Add setting to disable PCM validation (from Swift) #9043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ class TargetProperties : public Properties {

bool GetSwiftAllowExplicitModules() const;

bool GetSwiftDisablePCMValidation() const;

Args GetSwiftPluginServerForPath() const;

bool GetSwiftAutoImportFrameworks() const;
Expand Down
8 changes: 8 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
#include "clang/Basic/TargetOptions.h"
#include "clang/Driver/Driver.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"

#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
Expand Down Expand Up @@ -3748,6 +3750,12 @@ ThreadSafeASTContext SwiftASTContext::GetASTContext() {
// 4. Install the clang importer.
if (clang_importer_ap) {
m_clangimporter = (swift::ClangImporter *)clang_importer_ap.get();
TargetSP target_sp = GetTargetWP().lock();
if (target_sp && target_sp->GetSwiftDisablePCMValidation())
m_clangimporter->getClangPreprocessor()
.getPreprocessorOpts()
.DisablePCHOrModuleValidation =
clang::DisableValidationForModuleKind::Module;
m_ast_context_ap->addModuleLoader(std::move(clang_importer_ap),
/*isClang=*/true);
m_clangimporter_typesystem = std::make_shared<TypeSystemClang>(
Expand Down
13 changes: 13 additions & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4927,6 +4927,19 @@ bool TargetProperties::GetSwiftAllowExplicitModules() const {
return true;
}

bool TargetProperties::GetSwiftDisablePCMValidation() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftDisablePCMValidation)
.value_or(true);

return true;
}

Args TargetProperties::GetSwiftPluginServerForPath() const {
const uint32_t idx = ePropertySwiftPluginServerForPath;

Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Target/TargetProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ let Definition = "target_experimental" in {
def SwiftAllowExplicitModules: Property<"swift-allow-explicit-modules", "Boolean">,
DefaultTrue,
Desc<"Allows explicit module flags to be passed through to ClangImporter.">;
def SwiftDisablePCMValidation: Property<"swift-disable-pcm-validation", "Boolean">,
DefaultFalse,
Desc<"Disable validation when loading Clang PCM files (-fno-validate-pch).">;
}

let Definition = "target" in {
Expand Down