Skip to content

Commit 3201e97

Browse files
committed
Frontend: support emitting ABI descriptor when specifying the path in supplementary output map. rdar://86559811
1 parent 3fbb52c commit 3201e97

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

include/swift/Basic/FileTypes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ TYPE("pcm", ClangModuleFile, "pcm", "")
9595
TYPE("pch", PCH, "pch", "")
9696
TYPE("none", Nothing, "", "")
9797

98+
TYPE("abi-baseline-json", SwiftABIDescriptor, "abi.json", "")
99+
98100
#undef TYPE

lib/Basic/FileTypes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ bool file_types::isTextual(ID Id) {
8484
case file_types::TY_SwiftOverlayFile:
8585
case file_types::TY_JSONDependencies:
8686
case file_types::TY_JSONFeatures:
87+
case file_types::TY_SwiftABIDescriptor:
8788
return true;
8889
case file_types::TY_Image:
8990
case file_types::TY_Object:
@@ -157,6 +158,7 @@ bool file_types::isAfterLLVM(ID Id) {
157158
case file_types::TY_JSONDependencies:
158159
case file_types::TY_JSONFeatures:
159160
case file_types::TY_IndexUnitOutputPath:
161+
case file_types::TY_SwiftABIDescriptor:
160162
return false;
161163
case file_types::TY_INVALID:
162164
llvm_unreachable("Invalid type ID.");
@@ -208,6 +210,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
208210
case file_types::TY_JSONDependencies:
209211
case file_types::TY_JSONFeatures:
210212
case file_types::TY_IndexUnitOutputPath:
213+
case file_types::TY_SwiftABIDescriptor:
211214
return false;
212215
case file_types::TY_INVALID:
213216
llvm_unreachable("Invalid type ID.");

lib/Driver/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
20802080
case file_types::TY_SwiftOverlayFile:
20812081
case file_types::TY_JSONDependencies:
20822082
case file_types::TY_JSONFeatures:
2083+
case file_types::TY_SwiftABIDescriptor:
20832084
// We could in theory handle assembly or LLVM input, but let's not.
20842085
// FIXME: What about LTO?
20852086
Diags.diagnose(SourceLoc(), diag::error_unexpected_input_file,

lib/Driver/ToolChains.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ const char *ToolChain::JobContext::computeFrontendModeForCompile() const {
681681
case file_types::TY_SwiftCrossImportDir:
682682
case file_types::TY_SwiftOverlayFile:
683683
case file_types::TY_IndexUnitOutputPath:
684+
case file_types::TY_SwiftABIDescriptor:
684685
llvm_unreachable("Output type can never be primary output.");
685686
case file_types::TY_INVALID:
686687
llvm_unreachable("Invalid type ID");
@@ -940,6 +941,7 @@ ToolChain::constructInvocation(const BackendJobAction &job,
940941
case file_types::TY_SwiftCrossImportDir:
941942
case file_types::TY_SwiftOverlayFile:
942943
case file_types::TY_IndexUnitOutputPath:
944+
case file_types::TY_SwiftABIDescriptor:
943945
llvm_unreachable("Output type can never be primary output.");
944946
case file_types::TY_INVALID:
945947
llvm_unreachable("Invalid type ID");

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ createFromTypeToPathMap(const TypeToPathMap *map) {
599599
paths.PrivateModuleInterfaceOutputPath},
600600
{file_types::TY_YAMLOptRecord, paths.YAMLOptRecordPath},
601601
{file_types::TY_BitstreamOptRecord, paths.BitstreamOptRecordPath},
602+
{file_types::TY_SwiftABIDescriptor, paths.ABIDescriptorOutputPath},
602603
};
603604
for (const std::pair<file_types::ID, std::string &> &typeAndString :
604605
typesAndStrings) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo 'print("Hello, World!")' >%t/main.swift
3+
// RUN: cd %t
4+
5+
// RUN: %target-swift-frontend -emit-module -emit-abi-descriptor-path %t/main.abi.json %t/main.swift
6+
// RUN: test -f %t/main.abi.json
7+
8+
// RUN: echo '"%/t/main.swift": { abi-baseline-json: "%/t/foo.abi.json" }' > %/t/filemap.yaml
9+
// RUN: %target-swift-frontend -emit-module -supplementary-output-file-map %/t/filemap.yaml %/t/main.swift
10+
// RUN: test -f %t/foo.abi.json

0 commit comments

Comments
 (0)