This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes
ClosedPublic

Authored by phosek on Jun 16 2017, 1:06 PM.

Details

Summary

When -no-canonical-prefixes option is used and argv0 contains only
a program name, we need to do a PATH lookup to get an executable path,
otherwise the return value won't be a valid path and any subsequent
uses of it (e.g. invoking -cc1) will fail with an error.

This patch fixes PR9576.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek created this revision.Jun 16 2017, 1:06 PM
hans edited edge metadata.Jun 16 2017, 1:49 PM

Thanks!

Please add to the description that this is for PR9576.

tools/driver/driver.cpp
58 ↗(On Diff #102861)

What if "clang" is in the current directory? Presumably that should then be preferred over PATH.. will we get that right with this patch?

Another way would be to check access() on Argv0, which is what we do when trying to execute anyway. Is there any downside to that?

phosek updated this revision to Diff 102881.Jun 16 2017, 2:37 PM
phosek marked an inline comment as done.
phosek edited the summary of this revision. (Show Details)
phosek added inline comments.
tools/driver/driver.cpp
58 ↗(On Diff #102861)

I don't think there should be any downside to that approach.

hans accepted this revision.Jun 16 2017, 2:45 PM

lgtm

This revision is now accepted and ready to land.Jun 16 2017, 2:45 PM
This revision was automatically updated to reflect the committed changes.