Fix toolchain detection so we don't default to using cross-compilers

rhbz#1482491
This commit is contained in:
Tom Stellard 2018-03-12 20:39:40 +00:00
parent 5e7e9e3879
commit 63bf60b284
2 changed files with 127 additions and 1 deletions

View File

@ -0,0 +1,120 @@
From 69d981a5d41d481556bd38f8d668d7f1177ac2b4 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Thu, 18 Jan 2018 02:57:51 +0000
Subject: [PATCH] Driver: Prefer vendor supplied gcc toolchain
Summary:
This patch fixes an issue on Fedora where if you had the x86_64 cross
compiler installed on your x86_64 system, then clang would use that compiler
as the default toolchain. This was happening because the cross compiler
is installed to /usr/lib/gcc/x86_64-linux-gnu/ and this directory comes before
the default compiler directory (/usr/lib/gcc/x86_64-redhat-linux/) in the search
list.
This patch re-orders the search list so that vendor supplied gcc toolchains
are selected before toolchains with a generic target, which should prevent
these kind of issues on other OSes too.
Subscribers: srhines, cfe-commits
Differential Revision: https://reviews.llvm.org/D42608
---
lib/Driver/ToolChains/Gnu.cpp | 45 ++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
index 7845781..9cec316 100644
--- a/lib/Driver/ToolChains/Gnu.cpp
+++ b/lib/Driver/ToolChains/Gnu.cpp
@@ -1709,8 +1709,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
// lifetime or initialization issues.
static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const AArch64Triples[] = {
- "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android",
- "aarch64-redhat-linux", "aarch64-suse-linux"};
+ "aarch64-redhat-linux", "aarch64-suse-linux",
+ "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android"};
static const char *const AArch64beLibDirs[] = {"/lib"};
static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
"aarch64_be-linux-gnu"};
@@ -1718,10 +1718,11 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
static const char *const ARMLibDirs[] = {"/lib"};
static const char *const ARMTriples[] = {"arm-linux-gnueabi",
"arm-linux-androideabi"};
- static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
- "armv7hl-redhat-linux-gnueabi",
+ static const char *const ARMHFTriples[] = {"armv7hl-redhat-linux-gnueabi",
"armv6hl-suse-linux-gnueabi",
- "armv7hl-suse-linux-gnueabi"};
+ "armv7hl-suse-linux-gnueabi",
+ "arm-linux-gnueabihf",
+ };
static const char *const ARMebLibDirs[] = {"/lib"};
static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
"armeb-linux-androideabi"};
@@ -1730,19 +1731,19 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
static const char *const X86_64LibDirs[] = {"/lib64", "/lib"};
static const char *const X86_64Triples[] = {
- "x86_64-linux-gnu", "x86_64-unknown-linux-gnu",
- "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E",
- "x86_64-redhat-linux", "x86_64-suse-linux",
- "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
- "x86_64-slackware-linux", "x86_64-linux-android",
+ "x86_64-redhat-linux6E", "x86_64-redhat-linux",
+ "x86_64-suse-linux", "x86_64-slackware-linux",
+ "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
+ "x86_64-unknown-linux-gnu", "x86_64-pc-linux-gnu",
+ "x86_64-linux-gnu", "x86_64-linux-android",
"x86_64-unknown-linux"};
static const char *const X32LibDirs[] = {"/libx32"};
static const char *const X86LibDirs[] = {"/lib32", "/lib"};
static const char *const X86Triples[] = {
- "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu",
- "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux",
- "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux",
- "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+ "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linuxll",
+ "i386-redhat-linux", "i586-suse-linux", "i486-slackware-linux",
+ "i686-montavista-linux", "i686-linux-gnu", "i686-pc-linux-gnu",
+ "i486-linux-gnu", "i386-linux-gnu", "i686-linux-android",
"i586-linux-gnu"};
static const char *const MIPSLibDirs[] = {"/lib"};
@@ -1772,16 +1773,16 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
static const char *const PPCLibDirs[] = {"/lib32", "/lib"};
static const char *const PPCTriples[] = {
- "powerpc-linux-gnu", "powerpc-unknown-linux-gnu", "powerpc-linux-gnuspe",
- "powerpc-suse-linux", "powerpc-montavista-linuxspe"};
+ "powerpc-suse-linux", "powerpc-montavista-linuxspe",
+ "powerpc-linux-gnu", "powerpc-unknown-linux-gnu", "powerpc-linux-gnuspe"};
static const char *const PPC64LibDirs[] = {"/lib64", "/lib"};
static const char *const PPC64Triples[] = {
- "powerpc64-linux-gnu", "powerpc64-unknown-linux-gnu",
- "powerpc64-suse-linux", "ppc64-redhat-linux"};
+ "powerpc64-suse-linux", "ppc64-redhat-linux",
+ "powerpc64-linux-gnu", "powerpc64-unknown-linux-gnu"};
static const char *const PPC64LELibDirs[] = {"/lib64", "/lib"};
static const char *const PPC64LETriples[] = {
- "powerpc64le-linux-gnu", "powerpc64le-unknown-linux-gnu",
- "powerpc64le-suse-linux", "ppc64le-redhat-linux"};
+ "powerpc64le-suse-linux", "ppc64le-redhat-linux",
+ "powerpc64le-linux-gnu", "powerpc64le-unknown-linux-gnu"};
static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
@@ -1792,8 +1793,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
static const char *const SystemZLibDirs[] = {"/lib64", "/lib"};
static const char *const SystemZTriples[] = {
- "s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu",
- "s390x-suse-linux", "s390x-redhat-linux"};
+ "s390x-ibm-linux-gnu", "s390x-suse-linux", "s390x-redhat-linux",
+ "s390x-linux-gnu", "s390x-unknown-linux-gnu"};
// Solaris.
static const char *const SolarisSPARCLibDirs[] = {"/gcc"};
--
1.8.3.1

View File

@ -37,7 +37,7 @@
Name: clang
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
Release: 2%{?dist}
Release: 3%{?dist}
Summary: A C language family front-end for LLVM
License: NCSA
@ -50,6 +50,7 @@ Source100: clang-config.h
Patch0: 0001-lit.cfg-Add-hack-so-lit-can-find-not-and-FileCheck.patch
Patch1: 0001-GCC-compatibility-Ignore-fstack-clash-protection.patch
Patch2: 0001-Driver-Prefer-vendor-supplied-gcc-toolchain.patch
BuildRequires: cmake
BuildRequires: llvm-devel = %{version}
@ -171,6 +172,7 @@ Requires: python2
%setup -q -n %{clang_srcdir}
%patch0 -p1 -b .lit-search-path
%patch1 -p1 -b .fstack-clash-protection
%patch2 -p1 -b .vendor-gcc
mv ../%{clang_tools_srcdir} tools/extra
@ -309,6 +311,10 @@ make %{?_smp_mflags} check || :
%{python2_sitelib}/clang/
%changelog
* Wed Mar 21 2018 Tom Stellard <tstellar@redhat.com> - 6.0.0-3
- Fix toolchain detection so we don't default to using cross-compilers:
rhbz#1482491
* Mon Mar 12 2018 Tom Stellard <tstellar@redhat.com> - 6.0.0-2
- Add Provides: clang(major) rhbz#1547444