[PATCH] D118700: Add support to --gcc-toolchain flag for GCC compiled with --enable-version-specific-runtime-libs.

Raúl Peñacoba via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 1 07:20:28 PST 2022


rpenacob updated this revision to Diff 404930.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118700/new/

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/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(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118700.404930.patch
Type: text/x-patch
Size: 3633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220201/b47e72b4/attachment.bin>


More information about the cfe-commits mailing list