Skip to content

[SR-2855] Show inputs mismatch in -driver-show-incremental #5340

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
31 changes: 28 additions & 3 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,34 @@ static bool populateOutOfDateMap(InputInfoMap &map, StringRef argsHashStr,
map[inputPair.second] = iter->getValue();
}

// If a file was removed, we've lost its dependency info. Rebuild everything.
// FIXME: Can we do better?
return numInputsFromPrevious != previousInputs.size();
if (numInputsFromPrevious == previousInputs.size()) {
return false;
} else {
// If a file was removed, we've lost its dependency info. Rebuild everything.
// FIXME: Can we do better?
if (ShowIncrementalBuildDecisions) {
llvm::StringSet<> inputArgs;
for (auto &inputPair : inputs) {
inputArgs.insert(inputPair.second->getValue());
}

SmallVector<StringRef, 8> missingInputs;
for (auto &previousInput : previousInputs) {
auto previousInputArg = previousInput.getKey();
if (inputArgs.find(previousInputArg) == inputArgs.end()) {
missingInputs.push_back(previousInputArg);
}
}

llvm::outs() << "Incremental compilation has been disabled, because "
<< "the following inputs were used in the previous "
<< "compilation, but not in the current compilation:\n";
for (auto &missing : missingInputs) {
llvm::outs() << "\t" << missing << "\n";
}
}
return true;
}
}

std::unique_ptr<Compilation> Driver::buildCompilation(
Expand Down
23 changes: 23 additions & 0 deletions test/Driver/Dependencies/driver-show-incremental-inputs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Test that when:
//
// 1. Using -incremental -v -driver-show-incremental, and...
// 2. ...the inputs passed to the Swift compiler version differ from the ones
// used in the original compilation...
//
// ...then the driver prints a message indicating that incremental compilation
// is disabled.


// RUN: rm -rf %t && cp -r %S/Inputs/one-way/ %t
// RUN: %S/Inputs/touch.py 443865900 %t/*
// RUN: echo '{version: "'$(%swiftc_driver_plain -version | head -n1)'", inputs: {"./main.swift": [443865900, 0], "./other.swift": [443865900, 0]}}' > %t/main~buildrecord.swiftdeps

// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift ./other.swift -module-name main -incremental -v -driver-show-incremental -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-INCREMENTAL %s
// CHECK-INCREMENTAL-NOT: Incremental compilation has been disabled
// CHECK-INCREMENTAL: Queuing main.swift (initial)

// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift -module-name main -incremental -v -driver-show-incremental -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-INPUTS-MISMATCH %s
// CHECK-INPUTS-MISMATCH: Incremental compilation has been disabled{{.*}}inputs
// CHECK-INPUTS-MISMATCH: ./other.swift
// CHECK-INPUTS-MISMATCH-NOT: Queuing main.swift (initial)

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// RUN: echo '{version: "bogus", inputs: {"./main.swift": [443865900, 0], "./other.swift": [443865900, 0]}}' > %t/main~buildrecord.swiftdeps
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift ./other.swift -module-name main -incremental -v -driver-show-incremental -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-VERSION-MISMATCH %s
// CHECK-VERSION-MISMATCH: Incremental compilation has been disabled
// CHECK-VERSION-MISMATCH: Incremental compilation has been disabled{{.*}}compiler version mismatch
// CHECK-VERSION-MISMATCH: Compiling with:
// CHECK-VERSION-MISMATCH: Previously compiled with: bogus
// CHECK-VERSION-MISMATCH-NOT: Queuing main.swift (initial)
Expand Down