Cameron McInally via llvm-dev
2021-Nov-11 20:41 UTC
[llvm-dev] New Pass Manager '<' '>' syntax
Hey llvm-dev,
The new Pass Manager's "-passes=default<Ox>" syntax is a
little wonky.
It was unfortunate that "<" and ">" were chosen, since
those are the
Unix I/O redirection operators.
Let's take the case of a simple driver:
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
char* cmd = "opt";
char* arr[] = {"-passes=default<O2>", "-S",
"test.ll", NULL};
if (argc == 1)
execv(cmd, arr);
else {
if (strcmp(argv[1], "-###") == 0) {
printf("%s ", cmd);
for(int i =0 ; arr[i] != NULL; i++)
printf("%s ", arr[i]);
printf("\n");
}
}
return 0;
}
So there's two modes there: execute the opt subcommand; or dump the
subcommand in a dryrun. Typically, we'd want to be able to
copy-and-paste the output of the dryrun to the command line.
$ ./driver -###
opt -passes=default<O2> -S test.ll
$ opt -passes=default<O2> -S test.ll
-bash: O2: No such file or directory
But in this case, the new -passes=default<O2> option makes that
awkward since we'd need to escape the '<' and '>'
symbols, so that the
shell doesn't interpret them as I/O redirectors.
Unfortunately, patching this up in our driver is clunky. So I'm
reaching out to the list to see if there's an appetite for a better
way to express this option.
Thanks,
Cameron
Arthur Eubanks via llvm-dev
2021-Nov-11 21:08 UTC
[llvm-dev] New Pass Manager '<' '>' syntax
When printing a command that a user can use, each argument is typically quoted/escaped. This is true of almost every tool I've used that prints out a command to copy paste and seems like the proper solution. I don't think it's reasonable to assume that without any work, raw arguments are shell copy pastable. For example, a file name with a space would already not work with your proposed driver -###. On Thu, Nov 11, 2021 at 12:42 PM Cameron McInally via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hey llvm-dev, > > The new Pass Manager's "-passes=default<Ox>" syntax is a little wonky. > It was unfortunate that "<" and ">" were chosen, since those are the > Unix I/O redirection operators. > > Let's take the case of a simple driver: > > #include <stddef.h> > #include <unistd.h> > #include <string.h> > #include <stdio.h> > > int main(int argc, char *argv[]) { > char* cmd = "opt"; > char* arr[] = {"-passes=default<O2>", "-S", "test.ll", NULL}; > > if (argc == 1) > execv(cmd, arr); > else { > if (strcmp(argv[1], "-###") == 0) { > printf("%s ", cmd); > for(int i =0 ; arr[i] != NULL; i++) > printf("%s ", arr[i]); > printf("\n"); > } > } > return 0; > } > > So there's two modes there: execute the opt subcommand; or dump the > subcommand in a dryrun. Typically, we'd want to be able to > copy-and-paste the output of the dryrun to the command line. > > $ ./driver -### > opt -passes=default<O2> -S test.ll > $ opt -passes=default<O2> -S test.ll > -bash: O2: No such file or directory > > But in this case, the new -passes=default<O2> option makes that > awkward since we'd need to escape the '<' and '>' symbols, so that the > shell doesn't interpret them as I/O redirectors. > > Unfortunately, patching this up in our driver is clunky. So I'm > reaching out to the list to see if there's an appetite for a better > way to express this option. > > Thanks, > Cameron > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211111/432babcd/attachment.html>