-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BinaryPlatforms] Change "shortest match" algorithm to "best match" #49502
Conversation
My assertion in the previous attempt to fix this issue was incorrect: > We define a simpler match as one that has fewer tags overall. > As these candidate matches have already been filtered to match the > given platform, the only other tags that exist are ones that are in > addition to the tags declared by the platform. Hence, selecting the > minimum in number of tags is equivalent to selecting the closest match. This is demonstrably false, by my own test case: ``` platforms = Dict( Platform("x86_64", "linux") => "bad", Platform("x86_64", "linux"; sanitize="memory") => "good", ) select_platform(platforms, Platform("x86_64", "linux"; sanitize="memory")) == "good" ``` In this case, because there exists a candidate that is _more general_ than the provided platform type, the shortest match is no longer the best match. This PR performs a more rigorous matching that works more reliably in all cases.
This fixes #49491 |
@StefanKarpinski I'm totally open to the idea of using natural sort here; but such a sort function needs to be available pretty early on in the bootstrap process; do we have one? |
@@ -330,8 +330,7 @@ end | |||
# Ambiguity test | |||
@test select_platform(platforms, P("aarch64", "linux")) == "linux3" | |||
@test select_platform(platforms, P("aarch64", "linux"; libgfortran_version=v"3")) == "linux3" | |||
# This one may be surprising, but we still match `linux3`, and since linux3 is shorter, we choose it. | |||
@test select_platform(platforms, P("aarch64", "linux"; libgfortran_version=v"3", libstdcxx_version=v"3.4.18")) === "linux3" | |||
@test select_platform(platforms, P("aarch64", "linux"; libgfortran_version=v"3", libstdcxx_version=v"3.4.18")) === "linux5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an aside, this "surprise" should have been my hint that my previous implementation was incorrect.
I think this looks better now, thanks! |
Removing backport since original PR causing this was reverted on 1.9. |
My assertion in the previous attempt to fix this issue was incorrect:
This is demonstrably false, by my own test case:
In this case, because there exists a candidate that is more general than the provided platform type, the shortest match is no longer the best match.
This PR performs a more rigorous matching that works more reliably in all cases.