Skip to content

Commit 938ddbf

Browse files
committed
[Driver,Darwin] Simplify libc++ include path after #80527. NFC
My #80527 mentioned that `InstalledDir` was weird in the -canonical-prefixes mode. #70817 was a workaround to find the libc++ include path for a symlinked clang. After #80527, `InstalledDir` was identical to `Dir` and was subsequently removed, the code change #70817 can be reverted.
1 parent ff72c83 commit 938ddbf

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

+4-23
Original file line numberDiff line numberDiff line change
@@ -2514,25 +2514,19 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
25142514
switch (GetCXXStdlibType(DriverArgs)) {
25152515
case ToolChain::CST_Libcxx: {
25162516
// On Darwin, libc++ can be installed in one of the following places:
2517-
// 1. Alongside the compiler in <install>/include/c++/v1
2518-
// 2. Alongside the compiler in <clang-executable-folder>/../include/c++/v1
2519-
// 3. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1
2517+
// 1. Alongside the compiler in <clang-executable-folder>/../include/c++/v1
2518+
// 2. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1
25202519
//
25212520
// The precedence of paths is as listed above, i.e. we take the first path
25222521
// that exists. Note that we never include libc++ twice -- we take the first
25232522
// path that exists and don't send the other paths to CC1 (otherwise
25242523
// include_next could break).
2525-
//
2526-
// Also note that in most cases, (1) and (2) are exactly the same path.
2527-
// Those two paths will differ only when the `clang` program being run
2528-
// is actually a symlink to the real executable.
25292524

25302525
// Check for (1)
25312526
// Get from '<install>/bin' to '<install>/include/c++/v1'.
25322527
// Note that InstallBin can be relative, so we use '..' instead of
25332528
// parent_path.
2534-
llvm::SmallString<128> InstallBin =
2535-
llvm::StringRef(getDriver().Dir); // <install>/bin
2529+
llvm::SmallString<128> InstallBin(getDriver().Dir); // <install>/bin
25362530
llvm::sys::path::append(InstallBin, "..", "include", "c++", "v1");
25372531
if (getVFS().exists(InstallBin)) {
25382532
addSystemInclude(DriverArgs, CC1Args, InstallBin);
@@ -2542,20 +2536,7 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
25422536
<< "\"\n";
25432537
}
25442538

2545-
// (2) Check for the folder where the executable is located, if different.
2546-
if (getDriver().Dir != getDriver().Dir) {
2547-
InstallBin = llvm::StringRef(getDriver().Dir);
2548-
llvm::sys::path::append(InstallBin, "..", "include", "c++", "v1");
2549-
if (getVFS().exists(InstallBin)) {
2550-
addSystemInclude(DriverArgs, CC1Args, InstallBin);
2551-
return;
2552-
} else if (DriverArgs.hasArg(options::OPT_v)) {
2553-
llvm::errs() << "ignoring nonexistent directory \"" << InstallBin
2554-
<< "\"\n";
2555-
}
2556-
}
2557-
2558-
// Otherwise, check for (3)
2539+
// Otherwise, check for (2)
25592540
llvm::SmallString<128> SysrootUsr = Sysroot;
25602541
llvm::sys::path::append(SysrootUsr, "usr", "include", "c++", "v1");
25612542
if (getVFS().exists(SysrootUsr)) {

0 commit comments

Comments
 (0)