[llvm-dev] RFC: Support relative `--path` arguments to lit

Geoffrey Martin-Noble via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 9 17:42:22 PST 2021


I noticed that the lit `--path` argument currently accepts relative paths,
but the way it operates with them is pretty broken. It differs between
external shell and internal shell because the path resolution is done with
a different working directory. With the internal shell, it's resolved
relative to the directory from which lit is executed, whereas with the
external shell it's resolved relative to where the test case is executed.
To make matters worse, using the internal shell the file path
to binaries looked up with the `which` method is returned relative to the
directory from which lit is executed, but then executed from the test
execution directory. That means that relative --path arguments when using
the internal shell result in a `[Errno 2] No such file or directory` error
instead of the expected `command not found`.

I propose that `--path` arguments be resolved as absolute paths as part of
command line argument parsing. So relative paths passed to `--path` would
be consistently interpreted as relative to the directory from which lit was
invoked, which seems the least surprising behavior. To address other
potential edge cases from the `which` method returning relative paths, I
also propose modifying it to return absolute paths, which matches the
behavior of the unix function from which it gets its name.

https://reviews.llvm.org/D115486 is a patch making this change.

Thanks,
Geoffrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211209/8e14c8fb/attachment.html>


More information about the llvm-dev mailing list