[lldb-dev] When should ArchSpecs match?

Adrian Prantl via lldb-dev lldb-dev at lists.llvm.org
Thu Dec 6 15:19:54 PST 2018


I was puzzled by the behavior of ArchSpec::IsExactMatch() and IsCompatibleMatch() yesterday, so I created a couple of unit tests to document the current behavior. Most of the tests make perfect sense, but a few edge cases really don't behave like I would have expected them to.

>   {
>     ArchSpec A("arm64-*-*");
>     ArchSpec B("arm64-apple-ios");
>     ASSERT_FALSE(A.IsExactMatch(B));
>     // FIXME: This looks unintuitive and we should investigate whether
>     // this is the desired behavior.
>     ASSERT_FALSE(A.IsCompatibleMatch(B));
>   }
>   {
>     ArchSpec A("x86_64-*-*");
>     ArchSpec B("x86_64-apple-ios-simulator");
>     ASSERT_FALSE(A.IsExactMatch(B));
>     // FIXME: See above, though the extra environment complicates things.
>     ASSERT_FALSE(A.IsCompatibleMatch(B));
>   }
>   {
>     ArchSpec A("x86_64");
>     ArchSpec B("x86_64-apple-macosx10.14");
>     // FIXME: The exact match also looks unintuitive.
>     ASSERT_TRUE(A.IsExactMatch(B));
>     ASSERT_TRUE(A.IsCompatibleMatch(B));
>   }
> 

Particularly, I believe that:
- ArchSpec("x86_64-*-*") and ArchSpec("x86_64") should behave the same.
- ArchSpec("x86_64").IsExactMatch("x86_64-apple-macosx10.14") should be false.
- ArchSpec("x86_64-*-*").IsCompatibleMath("x86_64-apple-macosx") should be true.

Does anyone disagree with any of these statements?

I fully understand that changing any of these behaviors will undoubtedly break one or the other edge case, but I think it would be important to build on a foundation that actually makes sense if we want to be able to reason about the architecture matching logic at all.

let me know what you think!
-- adrian


More information about the lldb-dev mailing list