[PATCH] D156487: [TextAPI] Make min-os deployment version optional in tbd-v5.

Cyndy Ishida via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 11:27:30 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b73139150be: [TextAPI] Make min-os deployment version optional in tbd-v5. (authored by cishida).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156487/new/

https://reviews.llvm.org/D156487

Files:
  llvm/lib/TextAPI/TextStubV5.cpp
  llvm/unittests/TextAPI/TextStubV5Tests.cpp


Index: llvm/unittests/TextAPI/TextStubV5Tests.cpp
===================================================================
--- llvm/unittests/TextAPI/TextStubV5Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV5Tests.cpp
@@ -1104,6 +1104,53 @@
   EXPECT_EQ("invalid exported_symbols section\n", ErrorMessage);
 }
 
+TEST(TBDv5, DefaultMinOS) {
+  static const char TBDv5File[] = R"({ 
+"tapi_tbd_version": 5,
+"main_library": {
+  "target_info": [
+    {
+      "target": "arm64-ios-simulator"
+    }
+  ],
+  "install_names":[
+    { "name":"/S/L/F/Foo.framework/Foo" }
+  ]
+}})";
+
+  Expected<TBDFile> Result =
+      TextAPIReader::get(MemoryBufferRef(TBDv5File, "Test.tbd"));
+  EXPECT_TRUE(!!Result);
+  TBDFile File = std::move(Result.get());
+  EXPECT_EQ(FileType::TBD_V5, File->getFileType());
+  EXPECT_EQ(std::string("/S/L/F/Foo.framework/Foo"), File->getInstallName());
+  EXPECT_TRUE(File->targets().begin() != File->targets().end());
+  EXPECT_EQ(*File->targets().begin(),
+            Target(AK_arm64, PLATFORM_IOSSIMULATOR, VersionTuple(0, 0)));
+}
+
+TEST(TBDv5, InvalidMinOS) {
+  static const char TBDv5File[] = R"({ 
+"tapi_tbd_version": 5,
+"main_library": {
+  "target_info": [
+    {
+      "target": "arm64-ios-simulator",
+      "min_deployment": "swift-abi"
+    }
+  ],
+  "install_names":[
+    { "name":"/S/L/F/Foo.framework/Foo" }
+  ]
+}})";
+
+  Expected<TBDFile> Result =
+      TextAPIReader::get(MemoryBufferRef(TBDv5File, "Test.tbd"));
+  EXPECT_FALSE(!!Result);
+  std::string ErrorMessage = toString(Result.takeError());
+  EXPECT_EQ("invalid min_deployment section\n", ErrorMessage);
+}
+
 TEST(TBDv5, MergeIF) {
   static const char TBDv5FileA[] = R"({
 "tapi_tbd_version": 5,
Index: llvm/lib/TextAPI/TextStubV5.cpp
===================================================================
--- llvm/lib/TextAPI/TextStubV5.cpp
+++ llvm/lib/TextAPI/TextStubV5.cpp
@@ -27,7 +27,7 @@
   "target_info": [                                # Required: target information 
     {
       "target": "x86_64-macos",
-      "min_deployment": "10.14"                   # Required: minimum OS deployment version
+      "min_deployment": "10.14"                   # Optional: minOS defaults to 0
     },
     {
       "target": "arm64-macos",
@@ -283,17 +283,16 @@
         getRequiredValue<StringRef>(TBDKey::Target, Obj, &Object::getString);
     if (!TargetStr)
       return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Target));
-    auto VersionStr = getRequiredValue<StringRef>(TBDKey::Deployment, Obj,
-                                                  &Object::getString);
-    if (!VersionStr)
-      return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Deployment));
-    VersionTuple Version;
-    if (Version.tryParse(*VersionStr))
-      return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Deployment));
     auto TargetOrErr = Target::create(*TargetStr);
     if (!TargetOrErr)
       return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Target));
+
+    auto VersionStr = Obj->getString(Keys[TBDKey::Deployment]);
+    VersionTuple Version;
+    if (VersionStr && Version.tryParse(*VersionStr))
+      return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Deployment));
     TargetOrErr->MinDeployment = Version;
+
     // Convert to LLVM::Triple to accurately compute minOS + platform + arch
     // pairing.
     IFTargets.push_back(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156487.545230.patch
Type: text/x-patch
Size: 3387 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/5f4d7f14/attachment.bin>


More information about the llvm-commits mailing list