I totally agree with Reid, clang should work outside the mingw directory not
only for us developers but as the default result of someone installing
mingw-w64 at one location and then using the official LLVM installer to install
clang at c:\Program Files (X86). This combination will not work with the clang
in gcc bin assumption.
This assumption is not really required. I've been using the code below locally
for some time. It's tested on Windows only though it's the same principle with
Linux - using findProgramByName to find gcc instead of assuming it's the same
dir.
MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
: ToolChain(D, Triple, Args) {
getProgramPaths().push_back(getDriver().getInstalledDir());
llvm::ErrorOr<std::string> GPPName = llvm::sys::findProgramByName("gcc");
if (GPPName) {
llvm::StringRef GPP = GPPName.get();
Base = llvm::sys::path::parent_path(llvm::sys::path::parent_path(GPP));
} else {
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
}
Base += llvm::sys::path::get_separator();
Arch = getTriple().getArchName();
Arch += "-w64-mingw32";
Arch += llvm::sys::path::get_separator();
llvm::SmallString<1024> LibDir(Base);
llvm::sys::path::append(LibDir, "lib", "gcc", Arch);
std::error_code EC;
llvm::sys::fs::directory_iterator entry(LibDir.str(), EC);
if (EC)
return;
GccLibDir = entry->path();
// GccLibDir must precede Base/lib so that the
// correct crtbegin.o ,cetend.o would be found.
getFilePaths().push_back(GccLibDir);
getFilePaths().push_back(Base + "lib");
getFilePaths().push_back(Base + Arch + "lib");
}
The corresponding add include routines are (again tested on Windows only)
void MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
SmallString<1024> P(getDriver().ResourceDir);
llvm::sys::path::append(P, "include");
addSystemInclude(DriverArgs, CC1Args, P.str());
}
if (DriverArgs.hasArg(options::OPT_nostdlibinc))
return;
llvm::SmallString<1024> IncludeDir(GccLibDir);
llvm::sys::path::append(IncludeDir, "include");
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
IncludeDir += "-fixed";
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
addSystemInclude(DriverArgs, CC1Args, Base + Arch + "include");
}
void MinGW::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx))
return;
llvm::SmallString<1024> IncludeDir(Base);
llvm::sys::path::append(IncludeDir, Arch, "include", "c++");
addSystemInclude(DriverArgs, CC1Args, IncludeDir.str());
IncludeDir += llvm::sys::path::get_separator();
addSystemInclude(DriverArgs, CC1Args, IncludeDir.str() + Arch);
addSystemInclude(DriverArgs, CC1Args, IncludeDir.str() + "backward");
}
Please merge something along these lines into the patch so clang will be able
to run outside the gcc bin directory.
http://reviews.llvm.org/D5268
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits