Skip to content

Don't pass -Werror to ClangImporter's clang when Swift is used from LLDB #13303

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

Merged
merged 1 commit into from
Dec 11, 2017
Merged
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
3 changes: 3 additions & 0 deletions include/swift/ClangImporter/ClangImporterOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class ClangImporterOptions {
/// When set, don't look for or load adapter modules.
bool DisableAdapterModules = false;

/// When set, don't enforce warnings with -Werror.
bool DebuggerSupport = false;

/// Return a hash code of any components from these options that should
/// contribute to a Swift Bridging PCH hash.
llvm::hash_code getPCHHashComponents() const {
Expand Down
17 changes: 12 additions & 5 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,6 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
// Construct the invocation arguments for the current target.
// Add target-independent options first.
invocationArgStrs.insert(invocationArgStrs.end(), {
// Enable modules
"-fmodules",
"-Werror=non-modular-include-in-framework-module",
"-Xclang", "-fmodule-feature", "-Xclang", "swift",

// Don't emit LLVM IR.
"-fsyntax-only",

Expand All @@ -464,6 +459,18 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
SHIMS_INCLUDE_FLAG, searchPathOpts.RuntimeResourcePath,
});

// Enable modules.
invocationArgStrs.insert(invocationArgStrs.end(), {
"-fmodules",
"-Xclang", "-fmodule-feature", "-Xclang", "swift"
});
// Don't enforce strict rules when inside the debugger to work around search
// path problems caused by a module existing in both the build/install
// directory and the source directory.
if (!importerOpts.DebuggerSupport)
invocationArgStrs.push_back(
"-Werror=non-modular-include-in-framework-module");

if (LangOpts.EnableObjCInterop) {
invocationArgStrs.insert(invocationArgStrs.end(),
{"-x", "objective-c", "-std=gnu11", "-fobjc-arc"});
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation);
}

Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions test/ClangImporter/non-modular-include.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// CHECK-native: error: could not build C module 'Foo'
// CHECK-NOT: error

// RUN: %target-swift-frontend -debugger-support -typecheck %s -I %S/Inputs/non-modular -F %S/Inputs/non-modular 2>&1 | %FileCheck --allow-empty --check-prefix=CHECK-DEBUGGER %s

// CHECK-DEBUGGER-NOT: error:


import Foo

_ = Foo.x