Skip to content

Commit f869bd7

Browse files
committed
[TBDGen] Write tbd-v5 files by default
* Fixup tests to handle new json based output. * Use llvm-nm & readtapi to verify tbd file outputs. resolves: rdar://117604275
1 parent 331b11f commit f869bd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+265
-200
lines changed

lib/IRGen/TBDGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ TBDFile GenerateTBDRequest::evaluate(Evaluator &evaluator,
593593
auto &ctx = M->getASTContext();
594594

595595
llvm::MachO::InterfaceFile file;
596-
file.setFileType(llvm::MachO::FileType::TBD_V4);
596+
file.setFileType(llvm::MachO::FileType::TBD_V5);
597597
file.setApplicationExtensionSafe(isApplicationExtensionSafe(ctx.LangOpts));
598598
file.setInstallName(opts.InstallName);
599599
file.setTwoLevelNamespace();
@@ -659,7 +659,7 @@ void swift::writeTBDFile(ModuleDecl *M, llvm::raw_ostream &os,
659659
auto desc = TBDGenDescriptor::forModule(M, opts);
660660
auto file = llvm::cantFail(evaluator(GenerateTBDRequest{desc}));
661661
llvm::cantFail(llvm::MachO::TextAPIWriter::writeToStream(os, file),
662-
"YAML writing should be error-free");
662+
"TBD writing should be error-free");
663663
}
664664

665665
class APIGenRecorder final : public APIRecorder {

test/SILOptimizer/default-cmo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// RUN: %target-build-swift -O -wmo -Xfrontend -enable-default-cmo -parse-as-library -emit-module -emit-module-path=%t/Submodule.swiftmodule -module-name=Submodule %S/Inputs/cross-module/default-submodule.swift -c -o %t/submodule.o
55
// RUN: %target-build-swift -O -wmo -Xfrontend -enable-default-cmo -parse-as-library -emit-module -emit-module-path=%t/Module.swiftmodule -module-name=Module -I%t -I%S/Inputs/cross-module %S/Inputs/cross-module/default-module.swift -c -o %t/module.o
6-
// RUN: %target-build-swift -O -wmo -Xfrontend -enable-default-cmo -parse-as-library -emit-tbd -emit-tbd-path %t/ModuleTBD.tbd -emit-module -emit-module-path=%t/ModuleTBD.swiftmodule -module-name=ModuleTBD -I%t -I%S/Inputs/cross-module %S/Inputs/cross-module/default-module.swift -c -o %t/moduletbd.o
6+
// RUN: %target-build-swift -O -wmo -Xfrontend -enable-default-cmo -parse-as-library -emit-tbd -emit-tbd-path %t/ModuleTBD.tbd -emit-module -emit-module-path=%t/ModuleTBD.swiftmodule -module-name=ModuleTBD -I%t -I%S/Inputs/cross-module %S/Inputs/cross-module/default-module.swift -c -o %t/moduletbd.o -Xfrontend -tbd-install_name -Xfrontend module
77

88
// RUN: %target-build-swift -O -wmo -module-name=Main -I%t -I%S/Inputs/cross-module %s -emit-sil | %FileCheck %s
99

test/SPI/spi_symbols.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// REQUIRES: VENDOR=apple
22
// RUN: %empty-directory(%t)
33

4-
// RUN: %target-swift-frontend %S/Inputs/spi_helper.swift -emit-ir -o %t/spi_helper.ll -emit-tbd-path %t/spi_helper.tbd -module-name spi_helper
4+
// RUN: %target-swift-frontend %S/Inputs/spi_helper.swift -emit-ir -o %t/spi_helper.ll -emit-tbd-path %t/spi_helper.tbd -module-name spi_helper -tbd-install_name spi_helper
55

66
// RUN: cat %t/spi_helper.ll | %FileCheck -check-prefix=CHECK-IR %s
7-
// RUN: cat %t/spi_helper.tbd | %FileCheck -check-prefix=CHECK-TBD %s
7+
// RUN: %llvm-nm %t/spi_helper.tbd | %FileCheck -check-prefix=CHECK-TBD %s
88

99
// Look for the SPI symbols in the IR
1010
// CHECK-IR: define swiftcc void @"$s10spi_helper0A4FuncyyF"

test/TBD/abi-version.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// 1. Emit IR and a TBD for this file
88

9-
// RUN: %target-swift-frontend -emit-ir -o %t/test.ll %s -emit-tbd-path %t/test.tbd
9+
// RUN: %target-swift-frontend -emit-ir -o %t/test.ll %s -emit-tbd-path %t/test.tbd -tbd-install_name test
1010

1111
// 2. Concatenate them and FileCheck them both in the same file, so we can capture
1212
// the ABI version in a variable.
@@ -19,4 +19,4 @@
1919

2020
// 4. Look in the TBD for the same version listed
2121

22-
// CHECK: swift-abi-version: [[VERSION]]
22+
// CHECK: "abi": [[VERSION]]

test/TBD/all-in-one.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
// RUN: %target-build-swift %S/Inputs/extension_types.swift -module-name ExtensionTypes -emit-module -emit-module-path %t/ExtensionTypes.swiftmodule
99
// RUN: %target-build-swift %S/Inputs/subclass_super.swift -emit-library -emit-module -o %t/subclass_super%{target-shared-library-suffix} -enable-library-evolution
1010

11-
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/incremental_Onone.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module
12-
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/wmo_Onone.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -wmo
11+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/incremental_Onone.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -Xfrontend -tbd-install_name -Xfrontend all_in_one
12+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/wmo_Onone.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -wmo -Xfrontend -tbd-install_name -Xfrontend all_in_one
1313

14-
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/incremental_O.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -O
15-
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/wmo_O.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -wmo -O -Xllvm -sil-disable-pass=cmo
14+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/incremental_O.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -Xfrontend -tbd-install_name -Xfrontend all_in_one -O
15+
// RUN: %target-build-swift -module-name all_in_one -emit-module-path %t/all_in_one.swiftmodule -emit-tbd-path %t/wmo_O.tbd %S/class.swift %t/class_objc.swift %S/enum.swift %t/extension.swift %S/function.swift %S/global.swift %S/main.swift %S/protocol.swift %S/struct.swift %t/subclass.swift -I %t -import-objc-header %S/Inputs/objc_class_header.h -Xfrontend -disable-objc-attr-requires-foundation-module -wmo -O -Xllvm -sil-disable-pass=cmo -Xfrontend -tbd-install_name -Xfrontend all_in_one
1616

17-
// RUN: diff %t/incremental_Onone.tbd %t/wmo_Onone.tbd
18-
// RUN: diff %t/incremental_O.tbd %t/wmo_O.tbd
19-
// RUN: diff %t/incremental_Onone.tbd %t/incremental_O.tbd
17+
// RUN: %llvm-readtapi --compare %t/incremental_Onone.tbd %t/wmo_Onone.tbd
18+
// RUN: %llvm-readtapi --compare %t/incremental_O.tbd %t/wmo_O.tbd
19+
// RUN: %llvm-readtapi --compare %t/incremental_Onone.tbd %t/incremental_O.tbd
2020

2121
// REQUIRES: objc_interop

test/TBD/app-extension.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// REQUIRES: OS=macosx
22
// RUN: %empty-directory(%t)
3-
// RUN: %target-swift-frontend -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/safe.tbd
4-
// RUN: %target-swift-frontend -typecheck %s -emit-tbd -emit-tbd-path %t/not-safe.tbd
3+
// RUN: %target-swift-frontend -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/safe.tbd -tbd-install_name app_safe
4+
// RUN: %target-swift-frontend -typecheck %s -emit-tbd -emit-tbd-path %t/not-safe.tbd -tbd-install_name no_app_safe
55

6-
// RUN: %FileCheck %s --check-prefix EXTENSIONSAFE < %t/safe.tbd
7-
// RUN: %FileCheck %s --check-prefix NOTEXTENSIONSAFE < %t/not-safe.tbd
6+
// RUN: %validate-json %t/safe.tbd | %FileCheck %s --check-prefix EXTENSIONSAFE
7+
// RUN: %validate-json %t/not-safe.tbd | %FileCheck %s --check-prefix NOTEXTENSIONSAFE
88

99
// EXTENSIONSAFE-NOT: not_app_extension_safe
1010
// NOTEXTENSIONSAFE: not_app_extension_safe
1111

12-
// RUN: %target-swift-frontend -target-variant %target-cpu-apple-ios13.1-macabi -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/target-variant.tbd
13-
// RUN: %FileCheck %s --check-prefix MACABI < %t/target-variant.tbd
14-
15-
// MACABI: targets: [ {{.*}}macos{{.*}}maccatalyst{{.*}} ]
12+
// RUN: %target-swift-frontend -target-variant %target-cpu-apple-ios13.1-macabi -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/target-variant.tbd -tbd-install_name target-variant
13+
// RUN: %validate-json %t/target-variant.tbd | %FileCheck %s --check-prefix MACABI
1614

15+
// MACABI: "target": "{{.*}}-macos"
16+
// MACABI: "target": "{{.*}}-maccatalyst"

test/TBD/arm64e-arch.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %swift -typecheck -target arm64e-apple-ios12.0 -parse-stdlib -parse-as-library %s -module-name TBDTester -emit-tbd -emit-tbd-path - | %FileCheck %s
1+
// RUN: %swift -typecheck -target arm64e-apple-ios12.0 -parse-stdlib -parse-as-library %s -module-name TBDTester -emit-tbd -emit-tbd-path %t/arm64e.tbd -tbd-install_name arm64e
2+
// RUN: %llvm-nm -arch arm64e %t/arm64e.tbd | %FileCheck %s
23

34
public func testSwiftFunc() {}
45

5-
// CHECK: --- !tapi-tbd
6-
// CHECK: arm64e
7-
// CHECK: symbols: [ '_$s{{.*}}testSwiftFunc{{.*}}' ]
6+
7+
// CHECK: _$s{{.*}}testSwiftFunc{{.*}}

test/TBD/class.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
// RUN: %target-swift-frontend -enable-library-evolution -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
1111

1212
// RUN: %empty-directory(%t)
13-
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
14-
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
15-
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
13+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd -tbd-install_name class
14+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd -tbd-install_name class
15+
// RUN: %llvm-readtapi --compare %t/typecheck.tbd %t/emit-ir.tbd
1616

1717
open class OpenNothing {}
1818

test/TBD/custom_objc_error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: VENDOR=apple
22
// RUN: %empty-directory(%t)
33

4-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -I %S/Inputs/ -disable-objc-attr-requires-foundation-module -emit-tbd -emit-tbd-path %t/test.tbd
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -I %S/Inputs/ -disable-objc-attr-requires-foundation-module -emit-tbd -emit-tbd-path %t/test.tbd -tbd-install_name objc_err
55

66
import Foundation
77
@_exported import CustomError

test/TBD/distributed.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// REQUIRES: distributed
44

55
// RUN: %empty-directory(%t)
6-
// RUN: %target-swift-frontend %s -enable-testing -disable-availability-checking -emit-ir -o %t/test.ll -emit-tbd -emit-tbd-path %t/test.tbd -I %t
7-
// RUN cat %t/test.tbd | %FileCheck %s --dump-input=always
6+
// RUN: %target-swift-frontend %s -enable-testing -disable-availability-checking -emit-ir -o %t/test.ll -emit-tbd -emit-tbd-path %t/test.tbd -I %t -tbd-install_name distributed
7+
// RUN %llvm-nm -g %t/test.tbd | %FileCheck %s --dump-input=always
88

99
import Distributed
1010

0 commit comments

Comments
 (0)