[Driver] Fix implicit config files from prefixed symlinks
authorMartin Storsjo <martin@martin.st>
Wed, 25 Apr 2018 21:23:59 +0000 (21:23 +0000)
committerMartin Storsjo <martin@martin.st>
Wed, 25 Apr 2018 21:23:59 +0000 (21:23 +0000)
commit1fab23da1cef52d1752cb5877048c5d771e9b0f1
treee0c26819c000253d9461c987900b9f749dd1f09c
parent2faf606fb6679cd0fbaed48aef8765b684835578
[Driver] Fix implicit config files from prefixed symlinks

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.

Differential Revision: https://reviews.llvm.org/D45964

llvm-svn: 330871
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/test/Driver/config-file3.c