r330244 - [MinGW] Look for a cross sysroot relative to the clang binary

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 18 06:39:36 PDT 2018


Hi Martin,

Your commit is causing a few test failures on the PS4 Windows bot, can you take a look?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16544

Failing Tests (13):
    Clang :: CodeGenCXX/mingw-w64-exceptions.c
    Clang :: Driver/clang-translation.c
    Clang :: Driver/cxa-atexit.cpp
    Clang :: Driver/default-image-name.c
    Clang :: Driver/fsjlj-exceptions.c
    Clang :: Driver/incremental-linker-compatible.c
    Clang :: Driver/mingw-libgcc.c
    Clang :: Driver/mingw-msvcrt.c
    Clang :: Driver/no-integrated-as-win.c
    Clang :: Driver/pic.c
    Clang :: Driver/windows-pic.cpp
    Clang :: Index/index-attrs.c
    Clang :: Index/index-attrs.cpp

Douglas Yung

> -----Original Message-----
> From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org] On Behalf Of
> Martin Storsjo via cfe-commits
> Sent: Wednesday, April 18, 2018 1:47
> To: cfe-commits at lists.llvm.org
> Subject: r330244 - [MinGW] Look for a cross sysroot relative to the clang
> binary
> 
> Author: mstorsjo
> Date: Wed Apr 18 01:47:26 2018
> New Revision: 330244
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=330244&view=rev
> Log:
> [MinGW] Look for a cross sysroot relative to the clang binary
> 
> If found, prefer this over looking for a similar gcc later in the
> system path.
> 
> Differential Revision: https://reviews.llvm.org/D45504
> 
> Modified:
>     cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>     cfe/trunk/lib/Driver/ToolChains/MinGW.h
> 
> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=330244&r1=330243&r2=3302
> 44&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Wed Apr 18 01:47:26 2018
> @@ -275,7 +275,8 @@ void toolchains::MinGW::findGccLibDir()
>    Archs.emplace_back(getTriple().getArchName());
>    Archs[0] += "-w64-mingw32";
>    Archs.emplace_back("mingw32");
> -  Arch = Archs[0].str();
> +  if (Arch.empty())
> +    Arch = Archs[0].str();
>    // lib: Arch Linux, Ubuntu, Windows
>    // lib64: openSUSE Linux
>    for (StringRef CandidateLib : {"lib", "lib64"}) {
> @@ -302,6 +303,24 @@ llvm::ErrorOr<std::string> toolchains::M
>    return make_error_code(std::errc::no_such_file_or_directory);
>  }
> 
> +llvm::ErrorOr<std::string> toolchains::MinGW::findClangRelativeSysroot() {
> +  llvm::SmallVector<llvm::SmallString<32>, 2> Subdirs;
> +  Subdirs.emplace_back(getTriple().str());
> +  Subdirs.emplace_back(getTriple().getArchName());
> +  Subdirs[1] += "-w64-mingw32";
> +  Twine ClangRoot =
> +      llvm::sys::path::parent_path(getDriver().getInstalledDir()) +
> +      llvm::sys::path::get_separator();
> +  for (StringRef CandidateSubdir : Subdirs) {
> +    Twine Subdir = ClangRoot + CandidateSubdir;
> +    if (llvm::sys::fs::is_directory(Subdir)) {
> +      Arch = CandidateSubdir;
> +      return Subdir.str();
> +    }
> +  }
> +  return make_error_code(std::errc::no_such_file_or_directory);
> +}
> +
>  toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
>                           const ArgList &Args)
>      : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
> @@ -309,6 +328,10 @@ toolchains::MinGW::MinGW(const Driver &D
> 
>    if (getDriver().SysRoot.size())
>      Base = getDriver().SysRoot;
> +  // Look for <clang-bin>/../<triplet>; if found, use <clang-bin>/.. as the
> +  // base as it could still be a base for a gcc setup with libgcc.
> +  else if (llvm::ErrorOr<std::string> TargetSubdir =
> findClangRelativeSysroot())
> +    Base = llvm::sys::path::parent_path(TargetSubdir.get());
>    else if (llvm::ErrorOr<std::string> GPPName = findGcc())
>      Base = llvm::sys::path::parent_path(
>          llvm::sys::path::parent_path(GPPName.get()));
> 
> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/Driver/ToolChains/MinGW.h?rev=330244&r1=330243&r2=330244
> &view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Wed Apr 18 01:47:26 2018
> @@ -96,6 +96,7 @@ private:
>    mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
>    void findGccLibDir();
>    llvm::ErrorOr<std::string> findGcc();
> +  llvm::ErrorOr<std::string> findClangRelativeSysroot();
>  };
> 
>  } // end namespace toolchains
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list