summaryrefslogtreecommitdiffstats
path: root/lib/Driver/ToolChains/Darwin.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-01-09 13:08:11 +0000
committerIlya Biryukov <ibiryukov@google.com>2019-01-09 13:08:11 +0000
commit8db048138c2194434b3c69c8bddbb8340cac4ee1 (patch)
tree79fb5643c402d82254140ac97105d05dc518e5a6 /lib/Driver/ToolChains/Darwin.cpp
parent7f43dcfad8b0ba27dda9b1de50a9787f2473e928 (diff)
[Driver] Fix libcxx detection on Darwin with clang run as ./clang
Summary: By using '..' instead of fs::parent_path. The intention of the code was to go from 'path/to/clang/bin' to 'path/to/clang/include'. In most cases parent_path works, however it would fail when clang is run as './clang'. This was noticed in Chromium's bug tracker, see https://bugs.chromium.org/p/chromium/issues/detail?id=919761 Reviewers: arphaman, thakis, EricWF Reviewed By: arphaman, thakis Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D56446 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r--lib/Driver/ToolChains/Darwin.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp
index 4e306fd960..50ecd13e69 100644
--- a/lib/Driver/ToolChains/Darwin.cpp
+++ b/lib/Driver/ToolChains/Darwin.cpp
@@ -1752,10 +1752,11 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
break;
// On Darwin, libc++ may be installed alongside the compiler in
// include/c++/v1.
- // Get from 'foo/bin' to 'foo'.
- SmallString<128> P = llvm::sys::path::parent_path(InstallDir);
- // Get to 'foo/include/c++/v1'.
- llvm::sys::path::append(P, "include", "c++", "v1");
+ // Get from 'foo/bin' to 'foo/include/c++/v1'.
+ SmallString<128> P = InstallDir;
+ // Note that InstallDir can be relative, so we have to '..' and not
+ // parent_path.
+ llvm::sys::path::append(P, "..", "include", "c++", "v1");
addSystemInclude(DriverArgs, CC1Args, P);
break;
}