Update help text for each of the three tools: objcopy, strip and
install-name-tool. For reference: the issue is
highlighted in comments under https://reviews.llvm.org/D81527.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm-strip doesn't allow a positional argument output either, as it can take multiple input files. This looks like a regression in the help text since an older version I have kicking around. Could you fix it for both (and update the patch description), please? You should also expand the help message test for both llvm-strip and llvm-objcopy to test that the full string has been matched.
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | Rather than relying on a string for the name, I wonder if this code would be more robust with an enum that represents the three different tools, given that there's always potential for more front ends to be added. You would probably still want to pass in the tool name, but that could just be whatever the executable is called, possibly. For example, if the tool was llvm_install_name_tool, it would print that as the name in the help text message, rather than the current llvm-install-name-tool. |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | So I made a small enum and passed the appropriate enum types at the various function calls to printHelp. Does this work? |
LGTM, with one nit.
llvm/test/tools/llvm-objcopy/ELF/help-message.test | ||
---|---|---|
17–18 | Nit: whilst you're here, please delete one of these two blank lines. | |
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-help-message.test | ||
1–3 | So I just noticed that neither this nor the llvm-objcopy/llvm-strip test belong in their current directories - they should be one level up, since they are not platform specific, and probably then merged into a single test in my opinion. No need to change it in this patch, but if you can afford the hopefully small amount of time to do it, I think merging the two tests and putting them in llvm/test/tools/llvm-objcopy/ would be a nice thing to do. Note that tool-name.test already tests all three tools. | |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
403–419 | Yup, thanks. |
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-help-message.test | ||
---|---|---|
1–3 | yup, i can create a separate diff merging the two help test files into help-message.test |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | nit: ToolType ToolEnum -> ToolType Tool ToolName can be derived from ToolType, we probably don't need to pass it as an argument. |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | How would you and others feel about passing in the real executable name and printing that instead? It was an idea I had, but didn't suggest it before. |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | I would be fine with that |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | @jhenderson What do you mean by "real executable name"? So what should I be doing here now? We keep the ToolName? Sorry for not understanding what you guys meant exactly 😔 Currently I have made the change ToolType ToolEnum -> ToolType Tool. Not sure about ToolName yet? |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | @sameerarora101, sorry about the confusion, if I understand correctly @jhenderson is referring to the global variable ToolName (initialized in llvm-objcopy.cpp) or its basename. My first thought was that it might be useful but now i think that there are some undesirable consequences of this approach - e.g. some unexpected changes to the help message if the binary is moved around. It's already the case to some extent (because that's how we differentiate objcopy vs strip vs install-name-tool), but now it'll happen more frequently + it would create a dependency on the global variable from another file. I don't insist on any particular approach here, it feels like it's simpler to get rid of the duplication which I mentioned above and keep the old behavior. |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | oh ok I think I understand now. Thanks a lot for clarifying @alexshap . I'll update the diff to remove duplication. |
llvm/tools/llvm-objcopy/CopyConfig.cpp | ||
---|---|---|
403–419 | Thanks for the update. I was suggesting something like the following output: my-renamed-objcopy-11.exe [options] input [output] etc, i.e. whatever the real file name is, but I'm not sure about it myself either way, so I'm happy not to bother. |
Nit: whilst you're here, please delete one of these two blank lines.