diff options
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 3 | ||||
| -rw-r--r-- | clang/test/Driver/no-canonical-prefixes.c | 22 | ||||
| -rw-r--r-- | clang/tools/driver/driver.cpp | 10 |
3 files changed, 24 insertions, 11 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index a39f7fc678f..548baf3f0cc 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -762,6 +762,9 @@ void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const { } else OS << "Thread model: " << TC.getThreadModel(); OS << '\n'; + + // Print out the install directory. + OS << "InstalledDir: " << InstalledDir << '\n'; } /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories diff --git a/clang/test/Driver/no-canonical-prefixes.c b/clang/test/Driver/no-canonical-prefixes.c index b617cd4e361..7bc76be22d7 100644 --- a/clang/test/Driver/no-canonical-prefixes.c +++ b/clang/test/Driver/no-canonical-prefixes.c @@ -1,11 +1,17 @@ // Due to ln -sf: // REQUIRES: shell -// RUN: mkdir -p %t -// RUN: cd %t +// RUN: mkdir -p %t.real +// RUN: cd %t.real // RUN: ln -sf %clang test-clang -// RUN: ./test-clang -v -S %s 2>&1 | FileCheck %s -// RUN: ./test-clang -v -S %s -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=NCP %s - - -// CHECK: /clang{{.*}}" -cc1 -// NCP: test-clang" -cc1 +// RUN: cd .. +// RUN: ln -sf %t.real %t.fake +// RUN: cd %t.fake +// RUN: ./test-clang -v -S %s 2>&1 | FileCheck --check-prefix=CANONICAL %s +// RUN: ./test-clang -v -S %s -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=NON-CANONICAL %s +// +// FIXME: This should really be '.real'. +// CANONICAL: InstalledDir: {{.*}}.fake +// CANONICAL: {{[/|\\]*}}clang{{.*}}" -cc1 +// +// NON-CANONICAL: InstalledDir: .{{$}} +// NON-CANONICAL: test-clang" -cc1 diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index d6817a861a0..40c5a6198a8 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -344,7 +344,7 @@ CreateAndPopulateDiagOpts(ArrayRef<const char *> argv) { } static void SetInstallDir(SmallVectorImpl<const char *> &argv, - Driver &TheDriver) { + Driver &TheDriver, bool CanonicalPrefixes) { // Attempt to find the original path used to invoke the driver, to determine // the installed path. We do this manually, because we want to support that // path being a symlink. @@ -355,7 +355,11 @@ static void SetInstallDir(SmallVectorImpl<const char *> &argv, if (llvm::ErrorOr<std::string> Tmp = llvm::sys::findProgramByName( llvm::sys::path::filename(InstalledPath.str()))) InstalledPath = *Tmp; - llvm::sys::fs::make_absolute(InstalledPath); + + // FIXME: We don't actually canonicalize this, we just make it absolute. + if (CanonicalPrefixes) + llvm::sys::fs::make_absolute(InstalledPath); + InstalledPath = llvm::sys::path::parent_path(InstalledPath); if (llvm::sys::fs::exists(InstalledPath.c_str())) TheDriver.setInstalledDir(InstalledPath); @@ -473,7 +477,7 @@ int main(int argc_, const char **argv_) { ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false); Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags); - SetInstallDir(argv, TheDriver); + SetInstallDir(argv, TheDriver, CanonicalPrefixes); llvm::InitializeAllTargets(); insertArgsFromProgramName(ProgName, DS, argv, SavedStrings); |

