This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Fix implicit config files from prefixed symlinks
ClosedPublic

Authored by mstorsjo on Apr 23 2018, 7:42 AM.

Details

Summary

If -no-canonical-prefixes isn't used, the clang executable name used is the one of the actual executable, not the name of the symlink that the user invoked.

In these cases, the target prefix was overridden based on the clang executable name. (On the other hand the implicit -target option that such a symlink adds, is added as an actual command line parameter in tools/driver/driver.cop, before resolving the symlink and finding the actual clang executable.

Use the original ClangNameParts (set from argv[0] in tools/driver/driver.cpp) if it seems to be initialized propery.

All existing tests of this feature used -no-canonical-prefixes (possibly because it also makes the driver look in the directory of the symlink instead of the directory of the executable); add another one that uses --config-user-dir= to specify the directory instead. (For actual users of such symlinks, outisde of the test suite, the directory is probably the same for both.)

This makes this feature work more like what the documentation describes.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Apr 23 2018, 7:42 AM
sepavloff accepted this revision.Apr 24 2018, 10:56 AM

Thank you for fixing this issue!

LGTM

lib/Driver/Driver.cpp
132 ↗(On Diff #143560)

Maybe this check could be made a method of ParsedClangName, something like isEmpty?

This revision is now accepted and ready to land.Apr 24 2018, 10:56 AM
mstorsjo updated this revision to Diff 143794.Apr 24 2018, 12:06 PM

Added an isEmpty() method.

Btw, did you see https://bugs.llvm.org/show_bug.cgi?id=37196? That one feels quite a bit more convolved so I don't really know (so far) how to approach fixing that.

Added an isEmpty() method.

This variant is more readable.

Btw, did you see https://bugs.llvm.org/show_bug.cgi?id=37196? That one feels quite a bit more convolved so I don't really know (so far) how to approach fixing that.

Indeed, that bug looked mysterious. The reason is that InputArgList assumes its field ArgStrings contains strings for each argument exactly in the same order, this condition was broken when arguments from config file and from invocation were merged. I will commit the patch soon.

This revision was automatically updated to reflect the committed changes.