rpenacob created this revision. rpenacob added reviewers: rogfer01, MaskRay, sthibaul. rpenacob requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
GCC's compiled with --enable-version-specific-runtime-libs. change the paths where includes and libs are found. This patch adds support for these cases Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D118700 Files: clang/lib/Driver/ToolChains/Gnu.cpp clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/include/c++/.keep clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/lib64/.keep clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32/crtbegin.o clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/include/c++/.keep clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/lib64/.keep clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp clang/test/Driver/gcc-toolchain-rt-libs.cpp Index: clang/test/Driver/gcc-toolchain-rt-libs.cpp =================================================================== --- /dev/null +++ clang/test/Driver/gcc-toolchain-rt-libs.cpp @@ -0,0 +1,9 @@ +// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs --target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s + +int main() {} + +// CHECK: {{[^ ]*}}clang{{[^ ]*}}" -cc1 +// CHECK-SAME: -internal-isystem {{[^ ]*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++ +// CHECK: {{[^ ]*}}ld{{[^ ]*}}" +// CHECK-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0 +// CHECK-SAME: -L{{.*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64 Index: clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp =================================================================== --- /dev/null +++ clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp @@ -0,0 +1,17 @@ +// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib --target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X64 +// RUN: (%clangxx %s -m32 -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib --target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X32 + +int main() {} + +// X64: {{[^ ]*}}clang{{[^ ]*}}" -cc1 +// X64-SAME: -internal-isystem {{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++ +// X64: {{[^ ]*}}ld{{[^ ]*}}" +// X64-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0 +// X64-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64 + +// X32: {{[^ ]*}}clang{{[^ ]*}}" -cc1 +// X32-SAME: -internal-isystem {{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++ +// X32: {{[^ ]*}}ld{{[^ ]*}}" +// X32-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32 +// X32-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib32 + Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -2803,6 +2803,12 @@ D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(), Paths); + // Add lib/gcc/$triple/$libdir + // For GCC built with --enable-version-specific-runtime-libs. + addPathIfExists( + D, GCCInstallation.getInstallPath() + "/../" + OSLibDir, + Paths); + // GCC cross compiling toolchains will install target libraries which ship // as part of the toolchain under <prefix>/<triple>/<libdir> rather than as // any part of the GCC installation in @@ -2981,6 +2987,13 @@ TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args)) return true; + // Try /gcc/$triple/$version/include/c++/ (gcc --print-multiarch is not empty). + // Like above but for GCC built with --enable-version-specific-runtime-libs. + if (addLibStdCXXIncludePaths( + LibDir.str() + "/gcc/" + TripleStr + "/" + Version.Text + "/include/c++/", + TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args)) + return true; + // Detect Debian g++-multiarch-incdir.diff. if (addLibStdCXXIncludePaths(LibDir.str() + "/../include/c++/" + Version.Text, DebianMultiarch, Multilib.includeSuffix(),
Index: clang/test/Driver/gcc-toolchain-rt-libs.cpp =================================================================== --- /dev/null +++ clang/test/Driver/gcc-toolchain-rt-libs.cpp @@ -0,0 +1,9 @@ +// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs --target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s + +int main() {} + +// CHECK: {{[^ ]*}}clang{{[^ ]*}}" -cc1 +// CHECK-SAME: -internal-isystem {{[^ ]*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++ +// CHECK: {{[^ ]*}}ld{{[^ ]*}}" +// CHECK-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0 +// CHECK-SAME: -L{{.*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64 Index: clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp =================================================================== --- /dev/null +++ clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp @@ -0,0 +1,17 @@ +// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib --target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X64 +// RUN: (%clangxx %s -m32 -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib --target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X32 + +int main() {} + +// X64: {{[^ ]*}}clang{{[^ ]*}}" -cc1 +// X64-SAME: -internal-isystem {{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++ +// X64: {{[^ ]*}}ld{{[^ ]*}}" +// X64-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0 +// X64-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64 + +// X32: {{[^ ]*}}clang{{[^ ]*}}" -cc1 +// X32-SAME: -internal-isystem {{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++ +// X32: {{[^ ]*}}ld{{[^ ]*}}" +// X32-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32 +// X32-SAME: -L{{[^ ]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib32 + Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -2803,6 +2803,12 @@ D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(), Paths); + // Add lib/gcc/$triple/$libdir + // For GCC built with --enable-version-specific-runtime-libs. + addPathIfExists( + D, GCCInstallation.getInstallPath() + "/../" + OSLibDir, + Paths); + // GCC cross compiling toolchains will install target libraries which ship // as part of the toolchain under <prefix>/<triple>/<libdir> rather than as // any part of the GCC installation in @@ -2981,6 +2987,13 @@ TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args)) return true; + // Try /gcc/$triple/$version/include/c++/ (gcc --print-multiarch is not empty). + // Like above but for GCC built with --enable-version-specific-runtime-libs. + if (addLibStdCXXIncludePaths( + LibDir.str() + "/gcc/" + TripleStr + "/" + Version.Text + "/include/c++/", + TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args)) + return true; + // Detect Debian g++-multiarch-incdir.diff. if (addLibStdCXXIncludePaths(LibDir.str() + "/../include/c++/" + Version.Text, DebianMultiarch, Multilib.includeSuffix(),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits