Skip to content

Commit 266bd0f

Browse files
committed
Cross-module-optimization: issue an error if TBD file generation is requested with CMO
This combination is not supported and may result in undefined-symbol linker errors. rdar://problem/63238999
1 parent 5013a02 commit 266bd0f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ WARNING(tbd_only_supported_in_whole_module,none,
234234
"TBD generation is only supported when the whole module can be seen",
235235
())
236236

237+
ERROR(tbd_not_supported_with_cmo,none,
238+
"Test-Based InstallAPI (TBD) is not support with cross-module-optimization",
239+
())
240+
237241
WARNING(linker_directives_choice_confusion,none,
238242
"only one of -emit-ldadd-cfile-path and -module-installname-map-file can be specified;"
239243
"the c file won't be generated",

lib/FrontendTool/FrontendTool.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,12 @@ static bool writeTBDIfNeeded(CompilerInstance &Instance) {
10041004
return false;
10051005
}
10061006

1007+
if (Invocation.getSILOptions().CrossModuleOptimization) {
1008+
Instance.getDiags().diagnose(SourceLoc(),
1009+
diag::tbd_not_supported_with_cmo);
1010+
return false;
1011+
}
1012+
10071013
const std::string &TBDPath = Invocation.getTBDPathForWholeModule();
10081014

10091015
return writeTBD(Instance.getMainModule(), TBDPath, tbdOpts);
@@ -1404,7 +1410,7 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
14041410
return false;
14051411
}
14061412

1407-
// Cross-module optimization does not yet support TBD validation.
1413+
// Cross-module optimization does not support TBD.
14081414
if (Invocation.getSILOptions().CrossModuleOptimization) {
14091415
return false;
14101416
}

test/Frontend/no-cmo-with-tbd.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: not %target-swift-frontend -O -parse-as-library -cross-module-optimization -emit-tbd -module-name=Test %s -c -o /dev/null -verify 2>&1 | %FileCheck %s
2+
3+
// CHECK: Test-Based InstallAPI (TBD) is not support with cross-module-optimization
4+
5+
func foo() { }

0 commit comments

Comments
 (0)