[clang] [MinGW] Improve detection of libstdc++ headers on Fedora
There's some variation in where different toolchain distributions (and linux distributions) package the mingw sysroots - this is so far handled by adding specific known subdirectory paths to the include and lib directory lists. There are multiple degrees of combinatorics involved here though; the distros may use different locations such as /usr/x86_64-w64-mingw32/include or /usr/x86_64-w64-mingw32/sys-root/mingw/include. So far, this setup has been treated as base=/usr, subdir=x86_64-w64-mingw32, and the driver tries to add further subdirectories such as <base>/<subdir>/include, <base>/<subdir>/sys-root/mingw/include. When it comes to libstdc++ (and libc++), each of these come with a large number of potential subdirectories. Instead of further exploding the combinatorics another step by adding all combinations of all paths, check whether <base>/<subdir>/sys-root/mingw/include exists, and if it does, append that subpath into the subdir variable. This allows finding libstdc++ headers in e.g. /usr/x86_64-w64-mingw32/sys-root/mingw/include/c++/x86_64-w64-mingw32 on Fedora. The same logic (where everything belonging to this target fits under one expanded <subdir> path, with just /include and /lib under it) doesn't seem to apply on Gentoo, where the includes are found in <base>/<subdir>/usr/include while the libraries are in <base>/<subdir>/mingw/lib (see 8e218026). But apparently the libstdc++ headers aren't installed under <base>/<subdir>/usr/include, so that path hierarchy quirk doesn't need to be taken into account in AddClangCXXStdlibIncludeArgs. Differential Revision: https://reviews.llvm.org/D138693
Loading
Please sign in to comment