1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
From af4db76e059c1a3f4a7f437001051ccebc8a50fe Mon Sep 17 00:00:00 2001
From: Chandler Carruth <chandlerc@gmail.com>
Date: Sun, 8 May 2016 07:59:56 +0000
Subject: [PATCH] Teach header search about GCC 4.9 header search paths in
Gentoo, they now use the full GCC version in their weird suffix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268874 91177308-0d34-0410-b5e6-96231b3b80d8
---
lib/Driver/ToolChains.cpp | 1 +
.../Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep | 0
.../usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o | 0
.../x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep | 0
.../usr/x86_64-pc-linux-gnu/lib/.keep | 0
test/Driver/linux-header-search.cpp | 15 +++++++++++++++
6 files changed, 16 insertions(+)
create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep
create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep
diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
index f905b5d..1bf17e4 100644
--- a/tools/clang/lib/Driver/ToolChains.cpp
+++ b/tools/clang/lib/Driver/ToolChains.cpp
@@ -4134,6 +4134,7 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
const std::string LibStdCXXIncludePathCandidates[] = {
// Gentoo is weird and places its headers inside the GCC install,
// so if the first attempt to find the headers fails, try these patterns.
+ InstallDir.str() + "/include/g++-v" + Version.Text,
InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +
Version.MinorStr,
InstallDir.str() + "/include/g++-v" + Version.MajorStr,
diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
new file mode 100644
index 0000000..e69de29
diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tools/clang/test/Driver/linux-header-search.cpp b/tools/clang/test/Driver/linux-header-search.cpp
index 9568bde..5f6ac50 100644
--- a/tools/clang/test/Driver/linux-header-search.cpp
+++ b/tools/clang/test/Driver/linux-header-search.cpp
@@ -285,6 +285,21 @@
// CHECK-GENTOO-4-6-4: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
// CHECK-GENTOO-4-6-4: "-internal-externc-isystem" "[[SYSROOT]]/include"
// CHECK-GENTOO-4-6-4: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.3_tree \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+// CHECK-GENTOO-4-9-3: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-3: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu"
+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+// CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
//
// Check header search on Debian 6 / MIPS64
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
|