r243105 - Apparently some of the bots add .svn dirs inside the test/Driver/Inputs

Yaron Keren yaron.keren at gmail.com
Fri Jul 24 13:49:10 PDT 2015


r243153, selecting the highest version found like ScanLibDirForGCCTriple.


2015-07-24 21:43 GMT+03:00 Richard Smith <richard at metafoo.co.uk>:

> On Fri, Jul 24, 2015 at 4:01 AM, Yaron Keren <yaron.keren at gmail.com>
> 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<llvm::SmallString<32>, 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 at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150724/84ee5224/attachment.html>


More information about the cfe-commits mailing list