Skip to content

[DepScanner] Do not remove the resource directory path #39945

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
Oct 28, 2021
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
23 changes: 15 additions & 8 deletions lib/ClangImporter/ClangModuleDependencyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,29 @@ void ClangImporter::recordModuleDependencies(
swiftArgs.push_back("-Xcc");
swiftArgs.push_back(arg.str());
};
// Add all args inheritted from creating the importer.

// Add all args inherited from creating the importer.
auto It = allArgs.begin();

{
StringRef arg = *It;
if (arg == "clang" ||
arg.endswith(llvm::sys::path::get_separator().str() + "clang")) {
// Remove the initial path to clang executable argument, to avoid
// treating it as an executable input to compilation. It is not needed
// because the consumer of this command-line will invoke the emit-PCM
// action via swift-frontend.
It += 1;
}
}

while(It != allArgs.end()) {
StringRef arg = *It;
// Remove the -target arguments because we should use the target triple
// specified with `-clang-target` on the scanner invocation, or
// from the depending Swift modules.
if (arg == "-target") {
It += 2;
} else if (arg == "clang" ||
arg.endswith(llvm::sys::path::get_separator().str() + "clang")) {
// Remove the initial path to clang executable argument, to avoid
// treating it as an executable input to compilation. It is not needed
// because the consumer of this command-line will invoke the emit-PCM
// action via swift-frontend.
It += 1;
} else if (arg.startswith("-fapinotes-swift-version=")) {
// Remove the apinotes version because we should use the language version
// specified in the interface file.
Expand Down
6 changes: 5 additions & 1 deletion test/ScanDependencies/module_deps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ import SubE
// CHECK: "commandLine": [
// CHECK-NEXT: "-frontend"
// CHECK-NEXT: "-only-use-extra-clang-opts"
// CHECK-NOT: "BUILD_DIR/bin/clang"
// CHECK-NOT: "BUILD_DIR/bin/clang"
// CHECK: "-Xcc"
// CHECK-NEXT: "-resource-dir"
// CHECK-NEXT: "-Xcc"
// CHECK-NEXT: "BUILD_DIR/lib/swift/clang"
// CHECK: "-fsystem-module",
// CHECK-NEXT: "-emit-pcm",
// CHECK-NEXT: "-module-name",
Expand Down