]> granicus.if.org Git - clang/commitdiff
Driver: Don't mix system tools with devtoolset tools on RHEL
authorTom Stellard <tstellar@redhat.com>
Sat, 30 Jun 2018 02:55:54 +0000 (02:55 +0000)
committerTom Stellard <tstellar@redhat.com>
Sat, 30 Jun 2018 02:55:54 +0000 (02:55 +0000)
Summary:
On RHEL, devtoolset provides a more up-to-date toolchain than the base
install, and we want to make sure all the tools use are from the same
toolchain.

Reviewers: rsmith, bruno

Reviewed By: bruno

Subscribers: bruno, cfe-commits

Differential Revision: https://reviews.llvm.org/D34848

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336037 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 3b99ce581fa4e7639414031dd298a68cb86817c8..9a477556cf095095e57781176aa4cbe7f82f32a7 100644 (file)
@@ -238,6 +238,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
     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");
 
index 431bd9ef14324a7552fb2c0016281c6858b6b50e..7c61cf7b042a0ea8d75da3f9513bb35da0e740f3 100644 (file)
 // 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-RHEL7-DTS: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-RHLE7-DTS: Selected GCC installation: [[GCC_INSTALL:[[SYSROOT]]/lib/gcc/x86_64-redhat-linux/7]]
+// CHECK-LD-RHEL7-DTS-NOT: /usr/bin/ld
+// CHECK-LD-RHLE7-DTS: [[GCC_INSTALL]/../../../bin/ld