fahadnayyar created this revision. Herald added a project: All. fahadnayyar requested review of this revision. Herald added subscribers: cfe-commits, MaskRay. Herald added a project: clang.
When libc++ is bootstrapped with clang using the cmake options -DLLVM_ENABLE_PROJECTS="clang;llvm;lldb" and -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" then the resulting clang uses the just-built libcxx headers from <build-directory>/bin/../include/c++/v1 . So the clang in this case should also use the just-built libc++.dylib from <build-directory>/bin/../lib instead of using the system's libc++ libraries. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148266 Files: clang/lib/Driver/ToolChains/Darwin.cpp Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -410,6 +410,21 @@ Args.AddAllArgs(CmdArgs, options::OPT_sub__library); Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella); + // Including the path to the just-built libc++.dylib if libc++ is bootstrapped + // and <install>/bin/../lib/libc++.dylib is a valid path + + llvm::SmallString<128> LibCXXDylibDirPath = + llvm::StringRef(D.getInstalledDir()); // <install>/bin + llvm::sys::path::append(LibCXXDylibDirPath, "..", "lib"); + + llvm::SmallString<128> LibCXXDylibPath = LibCXXDylibDirPath; + llvm::sys::path::append(LibCXXDylibPath, "..", "lib", "libc++.dylib"); + + if (D.getVFS().exists(LibCXXDylibPath)) { + CmdArgs.push_back("-L"); + CmdArgs.push_back(C.getArgs().MakeArgString(LibCXXDylibDirPath)); + } + // Give --sysroot= preference, over the Apple specific behavior to also use // --isysroot as the syslibroot. StringRef sysroot = C.getSysRoot();
Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -410,6 +410,21 @@ Args.AddAllArgs(CmdArgs, options::OPT_sub__library); Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella); + // Including the path to the just-built libc++.dylib if libc++ is bootstrapped + // and <install>/bin/../lib/libc++.dylib is a valid path + + llvm::SmallString<128> LibCXXDylibDirPath = + llvm::StringRef(D.getInstalledDir()); // <install>/bin + llvm::sys::path::append(LibCXXDylibDirPath, "..", "lib"); + + llvm::SmallString<128> LibCXXDylibPath = LibCXXDylibDirPath; + llvm::sys::path::append(LibCXXDylibPath, "..", "lib", "libc++.dylib"); + + if (D.getVFS().exists(LibCXXDylibPath)) { + CmdArgs.push_back("-L"); + CmdArgs.push_back(C.getArgs().MakeArgString(LibCXXDylibDirPath)); + } + // Give --sysroot= preference, over the Apple specific behavior to also use // --isysroot as the syslibroot. StringRef sysroot = C.getSysRoot();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits