Skip to content

[Caching] Adopt -finclude-tree-preserve-pch-path to fix -gmodules with #73038

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
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
5 changes: 5 additions & 0 deletions lib/ClangImporter/ClangModuleDependencyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ static std::vector<std::string> getClangDepScanningInvocationArguments(
// ObjectFilePCHContainer and contain -gmodules debug info.
commandLineArgs.push_back("-gmodules");

// To use -gmodules we need to have a real path for the PCH; this option has
// no effect if caching is disabled.
commandLineArgs.push_back("-Xclang");
commandLineArgs.push_back("-finclude-tree-preserve-pch-path");

return commandLineArgs;
}

Expand Down
2 changes: 2 additions & 0 deletions test/CAS/bridging-header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// CHECK-NEXT: "A"
// CHECK-NEXT: ],
// CHECK-NEXT: "commandLine": [
// CHECK: "-fmodule-format=obj"
// CHECK: "-dwarf-ext-refs"
// CHECK: "-fmodule-file-cache-key",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "{{.*}}{{/|\\}}A-{{.*}}.pcm",
Expand Down
9 changes: 8 additions & 1 deletion test/CAS/module_deps_include_tree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,18 @@ import SubE
// CHECK: "contextHash"
// CHECK-SAME: "{{.*}}"

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

/// --------Clang module B
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}B-{{.*}}.pcm",
// CHECK: "contextHash": "[[B_CONTEXT:.*]]",
// CHECK: "-o"
// CHECK: "commandLine": [
// CHECK: "-o"
// CHECK-NEXT: B-{{.*}}[[B_CONTEXT]].pcm
// CHECK: "-fmodule-format=obj"
// CHECK: "-dwarf-ext-refs"

// Check make-style dependencies
// CHECK-MAKE-DEPS: module_deps_include_tree.swift
Expand Down