Skip to content

Switch TBD validation on by default #11031

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

Closed
Closed
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 include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ ERROR(symbol_in_ir_not_in_tbd,none,
"symbol '%0' (%1) is in generated IR file, but not in TBD file",
(StringRef, StringRef))

NOTE(pass_validate_tbd_against_ir_none,none,
"please file a bug including this code as a test case, and consider adding "
"'-Xfrontend -validate-tbd-against-ir=none' to the Swift compiler options to "
"silence this error", ())

ERROR(invalid_conditional_compilation_flag,none,
"conditional compilation flags must be valid Swift identifiers (rather than '%0')",
(StringRef))
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class FrontendOptions {
};

/// Compare the symbols in the IR against the TBD file we would generate.
TBDValidationMode ValidateTBDAgainstIR = TBDValidationMode::None;
TBDValidationMode ValidateTBDAgainstIR = TBDValidationMode::MissingFromTBD;

/// An enum with different modes for automatically crashing at defined times.
enum class DebugCrashMode {
Expand Down
6 changes: 6 additions & 0 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ static bool performCompile(CompilerInstance &Instance,
break;

const auto &silOpts = Invocation.getSILOptions();

// -sil-serialize-all is problematic and not what we intend to do long term,
// so we don't try to get the public symbols to line up.
if (silOpts.SILSerializeAll)
break;

auto hasMultipleIRGenThreads = silOpts.NumThreads > 1;
bool error;
if (PrimarySourceFile)
Expand Down
6 changes: 6 additions & 0 deletions lib/FrontendTool/TBD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ static bool validateSymbolSet(DiagnosticEngine &diags,
}
}

if (error) {
// Inform the user how to silence this error (and request they file a bug)
// so they can continue working while us compiler folk fix it properly.
diags.diagnose(SourceLoc(), diag::pass_validate_tbd_against_ir_none);
}

return error;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Migrator/member.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: objc_interop
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/member.swift.result -emit-remap-file-path %t/member.swift.remap -o /dev/null
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/member.swift.result -emit-remap-file-path %t/member.swift.remap -o /dev/null -validate-tbd-against-ir=none
// RUN: diff -u %S/member.swift.expected %t/member.swift.result

import Bar
Expand Down
2 changes: 1 addition & 1 deletion test/Migrator/member.swift.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: objc_interop
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/member.swift.result -emit-remap-file-path %t/member.swift.remap -o /dev/null
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/member.swift.result -emit-remap-file-path %t/member.swift.remap -o /dev/null -validate-tbd-against-ir=none
// RUN: diff -u %S/member.swift.expected %t/member.swift.result

import Bar
Expand Down
2 changes: 1 addition & 1 deletion test/Migrator/rename.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: objc_interop
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null -validate-tbd-against-ir=none
// RUN: diff -u %S/rename.swift.expected %t/rename.swift.result

import Bar
Expand Down
2 changes: 1 addition & 1 deletion test/Migrator/rename.swift.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: objc_interop
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null -validate-tbd-against-ir=none
// RUN: diff -u %S/rename.swift.expected %t/rename.swift.result

import Bar
Expand Down