--===============6587003143097374481== Content-Type: multipart/alternative; boundary=089e0118377af755f0051ba361ff --089e0118377af755f0051ba361ff Content-Type: text/plain; charset=UTF-8 On Fri, Jul 24, 2015 at 4:01 AM, Yaron Keren wrote: > Author: yrnkrn > Date: Fri Jul 24 06:01:45 2015 > New Revision: 243105 > > URL: http://llvm.org/viewvc/llvm-project?rev=243105&view=rev > Log: > Apparently some of the bots add .svn dirs inside the test/Driver/Inputs > directory structure. Try to make mingw toolchain resilient to such > surprises. > > > Modified: > cfe/trunk/lib/Driver/MinGWToolChain.cpp > > Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=243105&r1=243104&r2=243105&view=diff > > ============================================================================== > --- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original) > +++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Fri Jul 24 06:01:45 2015 > @@ -20,28 +20,38 @@ using namespace clang::driver::toolchain > using namespace clang; > using namespace llvm::opt; > > +namespace { > +bool findGccVersion(StringRef LibDir, std::string &GccLibDir, > + std::string &Ver) { > + std::error_code EC; > + llvm::sys::fs::directory_iterator Entry(LibDir, EC); > + while (!EC) { > + GccLibDir = Entry->path(); > + Ver = llvm::sys::path::filename(GccLibDir); > + if (Ver.size() && isdigit(Ver[0])) > + return true; > This seems like a very questionable approach. What if there are two such directories? You appear to make an arbitrary choice between them. See Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple for how other toolchains handle this. + Entry.increment(EC); > + } > + return false; > +} > +} > + > void MinGW::findGccLibDir() { > + llvm::SmallVector, 2> Archs; > + Archs.emplace_back(getTriple().getArchName()); > + Archs[0] += "-w64-mingw32"; > + Archs.emplace_back("mingw32"); > + Arch = "unknown"; > // lib: Arch Linux, Ubuntu, Windows > // lib64: openSUSE Linux > - llvm::SmallString<1024> LibDir; > for (StringRef Lib : {"lib", "lib64"}) { > - LibDir = Base; > - llvm::sys::path::append(LibDir, Lib, "gcc"); > - LibDir += llvm::sys::path::get_separator(); > - std::error_code EC; > - // First look for mingw-w64. > - llvm::sys::fs::directory_iterator MingW64Entry(LibDir + Arch, EC); > - if (!EC) { > - GccLibDir = MingW64Entry->path(); > - break; > - } > - // If mingw-w64 not found, try looking for mingw.org. > - llvm::sys::fs::directory_iterator MingwOrgEntry(LibDir + "mingw32", > EC); > - if (!EC) { > - GccLibDir = MingwOrgEntry->path(); > - // Replace Arch with mingw32 arch. > - Arch = "mingw32"; > - break; > + for (StringRef MaybeArch : Archs) { > + llvm::SmallString<1024> LibDir(Base); > + llvm::sys::path::append(LibDir, Lib, "gcc", MaybeArch); > + if (findGccVersion(LibDir, GccLibDir, Ver)) { > + Arch = MaybeArch; > + return; > + } > } > } > } > @@ -50,9 +60,6 @@ MinGW::MinGW(const Driver &D, const llvm > : ToolChain(D, Triple, Args) { > getProgramPaths().push_back(getDriver().getInstalledDir()); > > - // Default Arch is mingw-w64. > - Arch = (getTriple().getArchName() + "-w64-mingw32").str(); > - > // In Windows there aren't any standard install locations, we search > // for gcc on the PATH. In Linux the base is always /usr. > #ifdef LLVM_ON_WIN32 > @@ -73,7 +80,6 @@ MinGW::MinGW(const Driver &D, const llvm > > Base += llvm::sys::path::get_separator(); > findGccLibDir(); > - Ver = llvm::sys::path::filename(GccLibDir); > // GccLibDir must precede Base/lib so that the > // correct crtbegin.o ,cetend.o would be found. > getFilePaths().push_back(GccLibDir); > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > --089e0118377af755f0051ba361ff Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable
On F= ri, Jul 24, 2015 at 4:01 AM, Yaron Keren <yaron.keren@gmail.com>= ; wrote:
Author: yrnkrn
Date: Fri Jul 24 06:01:45 2015
New Revision: 243105

URL: http://llvm.org/viewv= c/llvm-project?rev=3D243105&view=3Drev
Log:
Apparently some of the bots add .svn dirs inside the test/Driver/Inputs
directory structure. Try to make mingw toolchain resilient to such surprise= s.


Modified:
=C2=A0 =C2=A0 cfe/trunk/lib/Driver/MinGWToolChain.cpp

Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
URL: http://llvm.org/viewvc/llvm= -project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=3D243105&r1=3D2431= 04&r2=3D243105&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Fri Jul 24 06:01:45 2015
@@ -20,28 +20,38 @@ using namespace clang::driver::toolchain
=C2=A0using namespace clang;
=C2=A0using namespace llvm::opt;

+namespace {
+bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std:= :string &Ver) {
+=C2=A0 std::error_code EC;
+=C2=A0 llvm::sys::fs::directory_iterator Entry(LibDir, EC);
+=C2=A0 while (!EC) {
+=C2=A0 =C2=A0 GccLibDir =3D Entry->path();
+=C2=A0 =C2=A0 Ver =3D llvm::sys::path::filename(GccLibDir);
+=C2=A0 =C2=A0 if (Ver.size() && isdigit(Ver[0]))
+=C2=A0 =C2=A0 =C2=A0 return true;

This= seems like a very questionable approach. What if there are two such direct= ories? You appear to make an arbitrary choice between them. See Generic_GCC= ::GCCInstallationDetector::ScanLibDirForGCCTriple for how other toolchains = handle this.

+=C2=A0 =C2=A0 Entry.increment(EC);
+=C2=A0 }
+=C2=A0 return false;
+}
+}
+
=C2=A0void MinGW::findGccLibDir() {
+=C2=A0 llvm::SmallVector<llvm::SmallString<32>, 2> Archs;
+=C2=A0 Archs.emplace_back(getTriple().getArchName());
+=C2=A0 Archs[0] +=3D "-w64-mingw32";
+=C2=A0 Archs.emplace_back("mingw32");
+=C2=A0 Arch =3D "unknown";
=C2=A0 =C2=A0// lib: Arch Linux, Ubuntu, Windows
=C2=A0 =C2=A0// lib64: openSUSE Linux
-=C2=A0 llvm::SmallString<1024> LibDir;
=C2=A0 =C2=A0for (StringRef Lib : {"lib", "lib64"}) { -=C2=A0 =C2=A0 LibDir =3D Base;
-=C2=A0 =C2=A0 llvm::sys::path::append(LibDir, Lib, "gcc");
-=C2=A0 =C2=A0 LibDir +=3D llvm::sys::path::get_separator();
-=C2=A0 =C2=A0 std::error_code EC;
-=C2=A0 =C2=A0 // First look for mingw-w64.
-=C2=A0 =C2=A0 llvm::sys::fs::directory_iterator MingW64Entry(LibDir + Arch= , EC);
-=C2=A0 =C2=A0 if (!EC) {
-=C2=A0 =C2=A0 =C2=A0 GccLibDir =3D MingW64Entry->path();
-=C2=A0 =C2=A0 =C2=A0 break;
-=C2=A0 =C2=A0 }
-=C2=A0 =C2=A0 // If mingw-w64 not found, try looking for mingw.org.
-=C2=A0 =C2=A0 llvm::sys::fs::directory_iterator MingwOrgEntry(LibDir + &qu= ot;mingw32", EC);
-=C2=A0 =C2=A0 if (!EC) {
-=C2=A0 =C2=A0 =C2=A0 GccLibDir =3D MingwOrgEntry->path();
-=C2=A0 =C2=A0 =C2=A0 // Replace Arch with mingw32 arch.
-=C2=A0 =C2=A0 =C2=A0 Arch =3D "mingw32";
-=C2=A0 =C2=A0 =C2=A0 break;
+=C2=A0 =C2=A0 for (StringRef MaybeArch : Archs) {
+=C2=A0 =C2=A0 =C2=A0 llvm::SmallString<1024> LibDir(Base);
+=C2=A0 =C2=A0 =C2=A0 llvm::sys::path::append(LibDir, Lib, "gcc",= MaybeArch);
+=C2=A0 =C2=A0 =C2=A0 if (findGccVersion(LibDir, GccLibDir, Ver)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Arch =3D MaybeArch;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0}
=C2=A0}
@@ -50,9 +60,6 @@ MinGW::MinGW(const Driver &D, const llvm
=C2=A0 =C2=A0 =C2=A0: ToolChain(D, Triple, Args) {
=C2=A0 =C2=A0getProgramPaths().push_back(getDriver().getInstalledDir());

-=C2=A0 // Default Arch is mingw-w64.
-=C2=A0 Arch =3D (getTriple().getArchName() + "-w64-mingw32").str= ();
-
=C2=A0// In Windows there aren't any standard install locations, we sea= rch
=C2=A0// for gcc on the PATH. In Linux the base is always /usr.
=C2=A0#ifdef LLVM_ON_WIN32
@@ -73,7 +80,6 @@ MinGW::MinGW(const Driver &D, const llvm

=C2=A0 =C2=A0Base +=3D llvm::sys::path::get_separator();
=C2=A0 =C2=A0findGccLibDir();
-=C2=A0 Ver =3D llvm::sys::path::filename(GccLibDir);
=C2=A0 =C2=A0// GccLibDir must precede Base/lib so that the
=C2=A0 =C2=A0// correct crtbegin.o ,cetend.o would be found.
=C2=A0 =C2=A0getFilePaths().push_back(GccLibDir);


_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-c= ommits

--089e0118377af755f0051ba361ff-- --===============6587003143097374481== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits --===============6587003143097374481==--