[Lldb-commits] [lldb] 8120eba - [lldb/ArchSpec] Always match simulator environment in IsEqualTo

Fred Riss via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 27 17:34:20 PDT 2020


Author: Fred Riss
Date: 2020-07-27T17:33:37-07:00
New Revision: 8120eba5fce378083ef22651f2b7b6dcaa54a098

URL: https://github.com/llvm/llvm-project/commit/8120eba5fce378083ef22651f2b7b6dcaa54a098
DIFF: https://github.com/llvm/llvm-project/commit/8120eba5fce378083ef22651f2b7b6dcaa54a098.diff

LOG: [lldb/ArchSpec] Always match simulator environment in IsEqualTo

Summary:
Initially, Apple simulator binarie triples didn't use a `-simulator`
environment and were just differentiated based on the architecture.
For example, `x86_64-apple-ios` would obviously be a simualtor as iOS
doesn't run on x86_64. With Catalyst, we made the disctinction
explicit and today, all simulator triples (even the legacy ones) are
constructed with an environment. This is especially important on Apple
Silicon were the architecture is not different from the one of the
simulated device.

This change makes the simulator part of the environment always part of
the criteria to detect whether 2 `ArchSpec`s are equal or compatible.

Reviewers: aprantl

Subscribers: inglorion, dexonsmith, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D84716

Added: 
    

Modified: 
    lldb/source/Utility/ArchSpec.cpp
    lldb/unittests/Utility/ArchSpecTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index cd382a322da7..6e4f1b5326dd 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -987,6 +987,12 @@ static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs,
   if (lhs == rhs)
     return true;
 
+  // Apple simulators are a 
diff erent platform than what they simulate.
+  // As the environments are 
diff erent at this point, if one of them is a
+  // simulator, then they are 
diff erent.
+  if (lhs == llvm::Triple::Simulator || rhs == llvm::Triple::Simulator)
+    return false;
+
   // If any of the environment is unknown then they are compatible
   if (lhs == llvm::Triple::UnknownEnvironment ||
       rhs == llvm::Triple::UnknownEnvironment)

diff  --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp
index a8f43ed7dc7c..ad0a8ac18cd1 100644
--- a/lldb/unittests/Utility/ArchSpecTest.cpp
+++ b/lldb/unittests/Utility/ArchSpecTest.cpp
@@ -306,6 +306,14 @@ TEST(ArchSpecTest, Compatibility) {
     ASSERT_FALSE(A.IsExactMatch(B));
     ASSERT_FALSE(A.IsCompatibleMatch(B));
   }
+  {
+    ArchSpec A("arm64-apple-ios");
+    ArchSpec B("arm64-apple-ios-simulator");
+    ASSERT_FALSE(A.IsExactMatch(B));
+    ASSERT_FALSE(A.IsCompatibleMatch(B));
+    ASSERT_FALSE(B.IsCompatibleMatch(A));
+    ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
   {
     ArchSpec A("arm64-*-*");
     ArchSpec B("arm64-apple-ios");


        


More information about the lldb-commits mailing list