Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -317,7 +317,11 @@ if (StringRef(D.Dir).startswith(SysRoot)) { // Even if OSLibDir != "lib", this is needed for Clang in the build // directory (not installed) to find libc++. - addPathIfExists(D, D.Dir + "/../lib", Paths); + // Use the presence of build-specific files to detect whether we are + // dealing with the build tree and avoid adding 32-bit system "lib" + // directory otherwise. + if (D.getVFS().exists(D.Dir + "/../CMakeCache.txt")) + addPathIfExists(D, D.Dir + "/../lib", Paths); if (OSLibDir != "lib") addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); }