Skip to content

[5.9] Always specify -gmodules on built-in Clang invocations #64913

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
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
12 changes: 6 additions & 6 deletions lib/ClangImporter/ClangModuleDependencyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@ static void addSearchPathInvocationArguments(
static std::vector<std::string> getClangDepScanningInvocationArguments(
ASTContext &ctx,
Optional<StringRef> sourceFileName = None) {
std::vector<std::string> commandLineArgs;

// Form the basic command line.
commandLineArgs.push_back("clang");
importer::getNormalInvocationArguments(commandLineArgs, ctx);
importer::addCommonInvocationArguments(commandLineArgs, ctx);
std::vector<std::string> commandLineArgs =
ClangImporter::getClangArguments(ctx);
addSearchPathInvocationArguments(commandLineArgs, ctx);

auto sourceFilePos = std::find(
Expand Down Expand Up @@ -114,6 +110,10 @@ static std::vector<std::string> getClangDepScanningInvocationArguments(
*syntaxOnlyPos = "-c";
}

// The Clang modules produced by ClangImporter are always embedded in an
// ObjectFilePCHContainer and contain -gmodules debug info.
commandLineArgs.push_back("-gmodules");

return commandLineArgs;
}

Expand Down
12 changes: 12 additions & 0 deletions test/ScanDependencies/test_clang_gmodules.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/module-cache)
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -target %target-cpu-apple-macosx10.14
// RUN: %FileCheck %s < %t/deps.json

import X

// CHECK: "clang": "X"
// CHECK: "clang": "X"
// CHECK: "commandLine": [
// CHECK-DAG: "-fmodule-format=obj"
// CHECK-DAG: "-dwarf-ext-refs"