r241432 - Teach mingw toolchain the msys2 mingw-w64 distribution C++ dirs.
Yaron Keren
yaron.keren at gmail.com
Mon Jul 13 08:54:50 PDT 2015
OK, there are sys-root include and library directories.
Try the attached patch which adds both of them.
2015-07-13 8:57 GMT+03:00 İsmail Dönmez <ismail at donmez.ws>:
> Hi,
>
> Please see the attached log files:
>
> try2.log.txt: Looks like /usr/include is in include path messing everything
>
> try3.log.txt: /usr/x86_64-w64-mingw32/sys-root/mingw/include must be
> added as C include path
>
> try4.log.txt: Even after adding
> /usr/x86_64-w64-mingw32/sys-root/mingw/include as include path it
> doesn't find most libraries.
>
>
>
> On Sun, Jul 12, 2015 at 9:20 PM, Yaron Keren <yaron.keren at gmail.com>
> wrote:
> > It should just work... on non-Windows the patch makes the mingw
> toolchain in
> > clang use /usr/lib64/gcc/$ARCH/$VER and /usr as the base paths instead of
> > searching. This makes more sense on Linux then the Windows logic of
> looking
> > for gcc.exe.
> >
> > You can still override this with --sysroot but should not be required.
> >
> >
> >
> >
> > 2015-07-12 21:12 GMT+03:00 İsmail Dönmez <ismail at donmez.ws>:
> >>
> >> Building it now, how shall I test it? With gcc in $PATH or with
> --sysroot
> >> ?
> >>
> >> On Sun, Jul 12, 2015 at 9:05 PM, Yaron Keren <yaron.keren at gmail.com>
> >> wrote:
> >> > Wow, mingw-w64 distributions has endless variations of include and
> >> > library
> >> > locations.
> >> > On base of the current SVN (without any previous patches I sent), try
> >> > the
> >> > attached patch.
> >> >
> >> >
> >> > 2015-07-12 18:33 GMT+03:00 İsmail Dönmez <ismail at donmez.ws>:
> >> >>
> >> >> Hi,
> >> >>
> >> >> See the attached log.
> >> >>
> >> >> On Sun, Jul 12, 2015 at 6:15 PM, Yaron Keren <yaron.keren at gmail.com>
> >> >> wrote:
> >> >> > On Ubuntu 14.04 it's not the same location, it's in /usr/lib/gcc
> and
> >> >> > not
> >> >> > /usr/lib64/gcc
> >> >> >
> >> >> > #include <...> search starts here:
> >> >> > /usr/include/c++/4.8
> >> >> > /usr/include/c++/4.8/x86_64-w64-mingw32
> >> >> > /usr/include/c++/4.8/backward
> >> >> > /usr/lib/gcc/x86_64-w64-mingw32/4.8/include
> >> >> > /usr/lib/gcc/x86_64-w64-mingw32/4.8/include-fixed
> >> >> >
> >> >> >
> >> >> >
> /usr/lib/gcc/x86_64-w64-mingw32/4.8/../../../../x86_64-w64-mingw32/include
> >> >> > End of search list.
> >> >> > GNU C++ (GCC) version 4.8.2 (x86_64-w64-mingw32)
> >> >> >
> >> >> > Can you send the full output of
> >> >> >
> >> >> > /usr/bin/x86_64-w64-mingw32-g++ -c -v a.cpp
> >> >> >
> >> >> > where a.cpp is some source file?
> >> >> >
> >> >> >
> >> >> >
> >> >> > 2015-07-12 16:47 GMT+03:00 İsmail Dönmez <ismail at donmez.ws>:
> >> >> >>
> >> >> >> [snip]
> >> >> >>
> >> >> >> > P.S: The problem on Cygwin side seems to be that my toolchain is
> >> >> >> > missing libgcc_s.a and this seems to be working fine since I
> build
> >> >> >> > the
> >> >> >> > whole toolchain as static. Do you think its reasonable to
> >> >> >> > conditionally add -lgcc_s depending on it exists or not?
> >> >> >>
> >> >> >> Honestly though this is non-standard and not worth adding code
> for.
> >> >> >> The situation on Linux is still a regression though :/
> >> >> >>
> >> >> >> Thanks a lot!
> >> >> >
> >> >> >
> >> >
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150713/16c2cc16/attachment.html>
-------------- next part --------------
Index: tools/clang/lib/Driver/MinGWToolChain.cpp
===================================================================
--- tools/clang/lib/Driver/MinGWToolChain.cpp (revision 242033)
+++ tools/clang/lib/Driver/MinGWToolChain.cpp (working copy)
@@ -24,8 +24,10 @@
: ToolChain(D, Triple, Args) {
getProgramPaths().push_back(getDriver().getInstalledDir());
+ llvm::SmallString<1024> LibDir;
if (getDriver().SysRoot.size())
Base = getDriver().SysRoot;
+#ifdef LLVM_ON_WIN32
else if (llvm::ErrorOr<std::string> GPPName =
llvm::sys::findProgramByName("gcc"))
Base = llvm::sys::path::parent_path(
@@ -33,8 +35,14 @@
else
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
Base += llvm::sys::path::get_separator();
- llvm::SmallString<1024> LibDir(Base);
+ LibDir = Base;
llvm::sys::path::append(LibDir, "lib", "gcc");
+#else
+ else
+ Base = "/usr/";
+ LibDir = Base;
+ llvm::sys::path::append(LibDir, "lib64", "gcc");
+#endif
LibDir += llvm::sys::path::get_separator();
// First look for mingw-w64.
@@ -58,6 +66,9 @@
getFilePaths().push_back(GccLibDir);
getFilePaths().push_back(Base + "lib");
getFilePaths().push_back(Base + Arch + "lib");
+#ifdef LLVM_ON_UNIX
+ getFilePaths().push_back(Base + Arch + "sys-root/mingw/lib");
+#endif
}
bool MinGW::IsIntegratedAssemblerDefault() const { return true; }
@@ -117,6 +128,11 @@
llvm::sys::path::append(IncludeDir, "include");
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
IncludeDir += "-fixed";
+#ifdef LLVM_ON_UNIX
+ // For OpenSUSE.
+ addSystemInclude(DriverArgs, CC1Args,
+ " /usr/x86_64-w64-mingw32/sys-root/mingw/include");
+#endif
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
addSystemInclude(DriverArgs, CC1Args, Base + Arch + "include");
addSystemInclude(DriverArgs, CC1Args, Base + "include");
@@ -129,9 +145,15 @@
return;
// C++ includes may be found in several locations depending on distribution.
+ // Windows
+ // -------
// mingw-w64 mingw-builds: $sysroot/i686-w64-mingw32/include/c++.
// mingw-w64 msys2: $sysroot/include/c++/4.9.2
// mingw.org: GccLibDir/include/c++
+ //
+ // Linux
+ // -----
+ // OpenSUSE: GccLibDir/include/c++
llvm::SmallVector<llvm::SmallString<1024>, 3> CppIncludeBases;
CppIncludeBases.emplace_back(Base);
llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
More information about the cfe-commits
mailing list