-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Support target names containing dots in all utilities #65812
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
base: main
Are you sure you want to change the base?
Conversation
1a1a85c
to
a42cbcc
Compare
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-platform-windows ChangesInstead of using custom code to find the program name throughout the codebase, write one function as a path helper to consistently determine the program name. This globally correctly finds target names with dots in them (ie freebsd13.2).This works by moving lld's code for stripping the
|
That windows build check looks like a problem with its configuration, am I mistaken? |
I was not mistaken. #66192 fixed this, so hopefully we build now. |
Instead of merging in changes to your PR branch - please rebase instead. |
You now have not one but four merge commits |
Sure, I was misinterpreting the new github contributor guides. I'll rebase for instead. |
4ea7e74
to
5f6d049
Compare
I think we need some tests around this. It can easily break otherwise. |
Tests make sense. Took some doing to find the unit tests for the clang version of this code. I'll add some for these other users. |
5f6d049
to
2cec601
Compare
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.
Hm. I'm happy with this file, but I also discovered a bunch of other tool-name
tests that can be updated. I'll add those too.
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.
Okay, added tool-name tests for the utilities for ELF and such. Not sure if I should add similar tests for Windows targets; they never have dots in their names.
2cec601
to
53937c7
Compare
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.
LGTM, but @jh7370 usually wants to have an eye on such changes.
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.
Just making sure I follow: the problem with stem
is that if a filename includes a dot, but no ".exe" or equivalent suffix, it would drop the bit from the last dot onwards, even though it might be part of the tool's actual name. Is that correct?
It looks like a number of tools have changed, but I don't see equivalent test changes/new tests for all of them. It seems like we should have testing for all cases where the code goes to some attempt to print the tool name.
Assuming it is, I note that some tools no longer will drop "other" file extensions. However, I don't know of any real such extensions other than Window's ".exe". Do any others exist on other platforms?
@@ -5,11 +5,14 @@ | |||
# RUN: mkdir %t | |||
# RUN: ln -s llvm-ranlib %t/llvm-ranlib-9 | |||
# RUN: ln -s llvm-ranlib %t/ranlib.exe | |||
# RUN: ln -s llvm-ranlib %t/x86_64-unknown-freebsd13.2-llvm-ranlib |
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.
I'm struggling to understand the logic in the llvm-ar test case gaining two new test cases, but the ranlib one only gaining one.
(On further investigation, I'm struggling to understand why the llvm-ranlib tool-name test even needs to exist, given that the code is the same code as llvm-ar at the relevant point).
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.
Yep, your second point is why I didn't bother making the second case for llvm-ranlib. On my first pass I just updated the existing testcases I found, but for ranlib I realised the same thing you did. I may just drop the ranlib test entirely.
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.
Let's put the new test files and deletion of this old test in a different PR. The old code was untested, so we're not making things worse, but it also helps keep the PRs focused. Aside: if we're deleting this old file, I think it would be a good idea to add one or two cases to the llvm-ar test showing the "llvm-ranlib" name.
llvm/unittests/Support/Path.cpp
Outdated
path::Style::posix); | ||
EXPECT_EQ(PosixProgNameSh, "x86_64-portbld-freebsd13.2-llvm-ar.sh"); | ||
|
||
StringRef WorseThanFailure = |
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.
WorseThanFailure
doesn't describe the case particularly well, especially as the behaviour here is the same as stem
. Could it simply be OnlyExe
?
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.
Yeah, that one was purely for my own benefit. I was describing behaviour I wasn't sure I wanted to keep, just what it was currently doing. It was intended as a reminder to me to come up 1. A better name, and 2. what the intended output should be.
Yes, that's correct. The real examples I've run into have been
This makes sense. For my first round I did leave out the cases where having multiple dots in the tool name didn't make sense, such as for |
I don't know. I explicitly tested that |
53937c7
to
c5854c0
Compare
Instead of using custom code to find the program name throughout the codebase, write one function as a path helper to consistently determine the program name. This globally correctly finds target names with dots in them (ie freebsd13.2).
Simple clang test for now, tests in lld and other tools coming soon.
c5854c0
to
f10871b
Compare
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.
Force pushing (and therefore rebasing) is supposed to be avoided unless it's absolutely necessary. Was a rebase actually required for this change? One of the motivations to avoid force pushes is that I can no longer see what changed versus my previous review, which is a fairly major usability issue for reviewing. Fortunately, this is a small review...
By the way, did you mean to have two commits in your PR?
LGTM, aside from a comment on the TODO.
@@ -5,11 +5,14 @@ | |||
# RUN: mkdir %t | |||
# RUN: ln -s llvm-ranlib %t/llvm-ranlib-9 | |||
# RUN: ln -s llvm-ranlib %t/ranlib.exe | |||
# RUN: ln -s llvm-ranlib %t/x86_64-unknown-freebsd13.2-llvm-ranlib |
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.
Let's put the new test files and deletion of this old test in a different PR. The old code was untested, so we're not making things worse, but it also helps keep the PRs focused. Aside: if we're deleting this old file, I think it would be a good idea to add one or two cases to the llvm-ar test showing the "llvm-ranlib" name.
@dankm, is there a particular reason you haven't merged this change in yet? FWIW, the formatter check failed for some reason, but I'm not sure it's related to any formatting issue. Please verify by running clang-format on your changes before merging. |
No good particular reason. I got hung up on the formatting issues then ran out of steam, and busy with $job. I just ran clang-format on this change and it came up clean. And now that I've done that the only reason I have left is I'm unable to merge my own changes. Would you mind, @jh7370? |
Hm. I have "fixup" commits in this branch, should I rebase those, or can we squash merge as-is? |
I can merge it for you, but first I just want to confirm that all 4 commits in this PR are intended to be for the PR? If not, you'll need to rebase and force push. There's no need for you to manually squash the fixups (although you might as well if you do end up rebasing). When I do the merge via the UI, it'll be using the Squash and merge button, which squashes everything into a single commit. The final commit message will be the PR description. I found the description a little confusing at first, without reading the code and test, so it may be beneficial to add an example of the before and after behaviour to that description before I merge it. Please could you update the patch description accordingly. |
Sounds good, @jh7370. Everything I want is in the pull request, I'm going to create a new pull request to update some tests as we discussed above. I'll update the description to be a bit more clear. Thanks for all help. |
Instead of using custom code to find the program name throughout the codebase, write one function as a path helper to consistently determine the program name. This globally correctly finds target names with dots in them (ie freebsd13.2).
This works by moving lld's code for stripping the
.exe
string from the program name toPath.h
, and replaces several instances of bespoke.exe
stripping with the new helper.As an example of the old behaviour:
The new behaviour expressed by this change: