Skip to content

Commit f6301fa

Browse files
committedNov 23, 2015
Driver: fallback to the location of clang if no sysroot,
hard coding /usr makes little sense for mingw-w64. If we have portable toolchains having /usr breaks that. If the clang we use is in /usr/bin or /usr/sbin etc this will still detect as though it was hard coded to /usr This makes the most sense going forward for mingw-w64 toolchains on both linux and mac Differential Revision: http://reviews.llvm.org/D14164 llvm-svn: 253898
1 parent 7c7f120 commit f6301fa

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed
 

‎clang/lib/Driver/MinGWToolChain.cpp

+11-15
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,20 @@ MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
6666
: ToolChain(D, Triple, Args) {
6767
getProgramPaths().push_back(getDriver().getInstalledDir());
6868

69-
// In Windows there aren't any standard install locations, we search
70-
// for gcc on the PATH. In Linux the base is always /usr.
69+
// On Windows if there is no sysroot we search for gcc on the PATH.
70+
71+
if (getDriver().SysRoot.size())
72+
Base = getDriver().SysRoot;
7173
#ifdef LLVM_ON_WIN32
72-
if (getDriver().SysRoot.size())
73-
Base = getDriver().SysRoot;
74-
else if (llvm::ErrorOr<std::string> GPPName =
75-
llvm::sys::findProgramByName("gcc"))
76-
Base = llvm::sys::path::parent_path(
77-
llvm::sys::path::parent_path(GPPName.get()));
78-
else
79-
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
80-
#else
81-
if (getDriver().SysRoot.size())
82-
Base = getDriver().SysRoot;
83-
else
84-
Base = "/usr";
74+
else if (llvm::ErrorOr<std::string> GPPName =
75+
llvm::sys::findProgramByName("gcc"))
76+
Base = llvm::sys::path::parent_path(
77+
llvm::sys::path::parent_path(GPPName.get()));
8578
#endif
8679

80+
if (!Base.size())
81+
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
82+
8783
Base += llvm::sys::path::get_separator();
8884
findGccLibDir();
8985
// GccLibDir must precede Base/lib so that the

0 commit comments

Comments
 (0)