[PATCH] D34848: Driver: Don't mix system tools with devtoolset tools on RHEL

Tom Stellard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 12 16:13:33 PDT 2018


tstellar updated this revision to Diff 142294.
tstellar added a comment.

Replaced the if (Distro.isRedhat()) check with a string compare on the
GCC installation lib.  This narrows the scope of the fix and also makes
it possible to write a test case.  The code that detects distros ignores
sysroot and looks in /etc of the test system, which makes it impossible to
write a portable lit test to verify distro specific behavior.


Repository:
  rC Clang

https://reviews.llvm.org/D34848

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===================================================================
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1780,3 +1780,11 @@
 // CHECK-LD-GENTOO-X32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // CHECK-LD-GENTOO-X32: "-lc"
 // CHECK-LD-GENTOO-X32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --gcc-toolchain="%S/Inputs/rhel_7_tree/opt/rh/devtoolset-7/root/usr" \
+// RUN:     --sysroot=%S/Inputs/rhel_7_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-RHEL7-DTS %s
+// CHECK-LD-RHLE7-DTS: Selected GCC installation: [[GCC_INSTALL:/home/tstellar/llvm-project/clang/test/Driver/Inputs/rhel_7_tree/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7]]
+// CHECK-LD-RHEL7-DTS-NOT: /usr/bin/ld
+// CHECK-LD-RHLE7-DTS: [[GCC_INSTALL]/../../../bin/ld
Index: lib/Driver/ToolChains/Linux.cpp
===================================================================
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -237,6 +237,15 @@
     ExtraOpts.push_back("relro");
   }
 
+  if (GCCInstallation.getParentLibPath().find("opt/rh/devtoolset") !=
+      StringRef::npos)
+    // With devtoolset on RHEL, we want to add a bin directory that is relative
+    // to the detected gcc install, because if we are using devtoolset gcc then
+    // we want to use other tools from devtoolset (e.g. ld) instead of the
+    // standard system tools.
+    PPaths.push_back(Twine(GCCInstallation.getParentLibPath() +
+                     "/../bin").str());
+
   if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
     ExtraOpts.push_back("-X");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34848.142294.patch
Type: text/x-patch
Size: 1708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180412/c23745a4/attachment.bin>


More information about the cfe-commits mailing list