Gentoo Archives: gentoo-commits

From: "Richard Yao (ryao)" <ryao@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-devel/clang/files: clang-3.1-gentoo-freebsd-fix-cxx-paths.patch clang-3.1-gentoo-runtime-gcc-detection.patch clang-3.1-gentoo-linux-fix-cxx-include.patch clang-3.1-gentoo-freebsd-fix-lib-path.patch
Date: Sat, 26 May 2012 01:35:08
Message-Id: 20120526013457.5A37C2004C@flycatcher.gentoo.org
1 ryao 12/05/26 01:34:57
2
3 Added: clang-3.1-gentoo-freebsd-fix-cxx-paths.patch
4 clang-3.1-gentoo-runtime-gcc-detection.patch
5 clang-3.1-gentoo-linux-fix-cxx-include.patch
6 clang-3.1-gentoo-freebsd-fix-lib-path.patch
7 Log:
8 Fix bug #406163, bug #409269, bug #417171, bug #417537 and bug #417541 in Clang 3.1
9
10 (Portage version: 2.1.10.49/cvs/Linux x86_64)
11
12 Revision Changes Path
13 1.1 sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch
14
15 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch?rev=1.1&view=markup
16 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch?rev=1.1&content-type=text/plain
17
18 Index: clang-3.1-gentoo-freebsd-fix-cxx-paths.patch
19 ===================================================================
20 diff --git a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
21 index 1e282f2..1d6835b 100644
22 --- a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
23 +++ b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
24 @@ -2305,6 +2305,161 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
25 }
26 }
27
28 +void FreeBSD::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
29 + ArgStringList &CC1Args) const {
30 + const Driver &D = getDriver();
31 +
32 + if (DriverArgs.hasArg(options::OPT_nostdinc))
33 + return;
34 +
35 + if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
36 + addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/local/include");
37 +
38 + if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
39 + llvm::sys::Path P(D.ResourceDir);
40 + P.appendComponent("include");
41 + addSystemInclude(DriverArgs, CC1Args, P.str());
42 + }
43 +
44 + if (DriverArgs.hasArg(options::OPT_nostdlibinc))
45 + return;
46 +
47 + // Check for configure-time C include directories.
48 + StringRef CIncludeDirs(C_INCLUDE_DIRS);
49 + if (CIncludeDirs != "") {
50 + SmallVector<StringRef, 5> dirs;
51 + CIncludeDirs.split(dirs, ":");
52 + for (SmallVectorImpl<StringRef>::iterator I = dirs.begin(), E = dirs.end();
53 + I != E; ++I) {
54 + StringRef Prefix = llvm::sys::path::is_absolute(*I) ? D.SysRoot : "";
55 + addExternCSystemInclude(DriverArgs, CC1Args, Prefix + *I);
56 + }
57 + return;
58 + }
59 +
60 + // Lacking those, try to detect the correct set of system includes for the
61 + // target triple.
62 +
63 + // Implement generic Debian multiarch support.
64 + const StringRef X86_64MultiarchIncludeDirs[] = {
65 + "/usr/include/x86_64-linux-gnu",
66 +
67 + // FIXME: These are older forms of multiarch. It's not clear that they're
68 + // in use in any released version of Debian, so we should consider
69 + // removing them.
70 + "/usr/include/i686-linux-gnu/64",
71 + "/usr/include/i486-linux-gnu/64"
72 + };
73 + const StringRef X86MultiarchIncludeDirs[] = {
74 + "/usr/include/i386-linux-gnu",
75 +
76 + // FIXME: These are older forms of multiarch. It's not clear that they're
77 + // in use in any released version of Debian, so we should consider
78 + // removing them.
79 + "/usr/include/x86_64-linux-gnu/32",
80 + "/usr/include/i686-linux-gnu",
81 + "/usr/include/i486-linux-gnu"
82 + };
83 + const StringRef ARMMultiarchIncludeDirs[] = {
84 + "/usr/include/arm-linux-gnueabi"
85 + };
86 + const StringRef MIPSMultiarchIncludeDirs[] = {
87 + "/usr/include/mips-linux-gnu"
88 + };
89 + const StringRef MIPSELMultiarchIncludeDirs[] = {
90 + "/usr/include/mipsel-linux-gnu"
91 + };
92 + const StringRef PPCMultiarchIncludeDirs[] = {
93 + "/usr/include/powerpc-linux-gnu"
94 + };
95 + const StringRef PPC64MultiarchIncludeDirs[] = {
96 + "/usr/include/powerpc64-linux-gnu"
97 + };
98 + ArrayRef<StringRef> MultiarchIncludeDirs;
99 + if (getTriple().getArch() == llvm::Triple::x86_64) {
100 + MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
101 + } else if (getTriple().getArch() == llvm::Triple::x86) {
102 + MultiarchIncludeDirs = X86MultiarchIncludeDirs;
103 + } else if (getTriple().getArch() == llvm::Triple::arm) {
104 + MultiarchIncludeDirs = ARMMultiarchIncludeDirs;
105 + } else if (getTriple().getArch() == llvm::Triple::mips) {
106 + MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
107 + } else if (getTriple().getArch() == llvm::Triple::mipsel) {
108 + MultiarchIncludeDirs = MIPSELMultiarchIncludeDirs;
109 + } else if (getTriple().getArch() == llvm::Triple::ppc) {
110 + MultiarchIncludeDirs = PPCMultiarchIncludeDirs;
111 + } else if (getTriple().getArch() == llvm::Triple::ppc64) {
112 + MultiarchIncludeDirs = PPC64MultiarchIncludeDirs;
113 + }
114 + for (ArrayRef<StringRef>::iterator I = MultiarchIncludeDirs.begin(),
115 + E = MultiarchIncludeDirs.end();
116 + I != E; ++I) {
117 + if (llvm::sys::fs::exists(D.SysRoot + *I)) {
118 + addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + *I);
119 + break;
120 + }
121 + }
122 +
123 + if (getTriple().getOS() == llvm::Triple::RTEMS)
124 + return;
125 +
126 + // Add an include of '/include' directly. This isn't provided by default by
127 + // system GCCs, but is often used with cross-compiling GCCs, and harmless to
128 + // add even when Clang is acting as-if it were a system compiler.
129 + addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
130 +
131 + addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/include");
132 +}
133 +
134 +/// \brief Helper to add the thre variant paths for a libstdc++ installation.
135 +/*static*/ bool FreeBSD::addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
136 + const ArgList &DriverArgs,
137 + ArgStringList &CC1Args) {
138 + if (!llvm::sys::fs::exists(Base))
139 + return false;
140 + addSystemInclude(DriverArgs, CC1Args, Base);
141 + addSystemInclude(DriverArgs, CC1Args, Base + "/" + TargetArchDir);
142 + addSystemInclude(DriverArgs, CC1Args, Base + "/backward");
143 + return true;
144 +}
145 +
146 +void FreeBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
147 + ArgStringList &CC1Args) const {
148 + if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
149 + DriverArgs.hasArg(options::OPT_nostdincxx))
150 + return;
151 +
152 + // Check if libc++ has been enabled and provide its include paths if so.
153 + if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
154 + // libc++ is always installed at a fixed path on Linux currently.
155 + addSystemInclude(DriverArgs, CC1Args,
156 + getDriver().SysRoot + "/usr/include/c++/v1");
157 + return;
158 + }
159 +
160 + // We need a detected GCC installation on Linux to provide libstdc++'s
161 + // headers. We handled the libc++ case above.
162 + if (!GCCInstallation.isValid())
163 + return;
164 +
165 + // By default, look for the C++ headers in an include directory adjacent to
166 + // the lib directory of the GCC installation. Note that this is expect to be
167 + // equivalent to '/usr/include/c++/X.Y' in almost all cases.
168 + StringRef LibDir = GCCInstallation.getParentLibPath();
169 + StringRef InstallDir = GCCInstallation.getInstallPath();
170 + StringRef Version = GCCInstallation.getVersion();
171 + if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version,
172 + (GCCInstallation.getTriple().str() +
173 + GCCInstallation.getMultiarchSuffix()),
174 + DriverArgs, CC1Args)) {
175 + // Gentoo is weird and places its headers inside the GCC install, so if the
176 + // first attempt to find the headers fails, try this pattern.
177 + addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
178 + getDriver().DefaultTargetTriple,
179 + DriverArgs, CC1Args);
180 + }
181 +}
182 +
183 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
184
185 DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
186 diff --git a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h
187 index eaa6be1..bba891e 100644
188 --- a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h
189 +++ b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h
190 @@ -489,6 +489,16 @@ public:
191
192 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
193 const ActionList &Inputs) const;
194 +
195 + virtual void AddClangSystemIncludeArgs(const ArgList &DriverArgs,
196 + ArgStringList &CC1Args) const;
197 + virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
198 + ArgStringList &CC1Args) const;
199 +
200 +private:
201 + static bool addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
202 + const ArgList &DriverArgs,
203 + ArgStringList &CC1Args);
204 };
205
206 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
207
208
209
210 1.1 sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch
211
212 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch?rev=1.1&view=markup
213 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch?rev=1.1&content-type=text/plain
214
215 Index: clang-3.1-gentoo-runtime-gcc-detection.patch
216 ===================================================================
217 diff -upNr a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
218 --- a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 03:32:31.593191000 -0400
219 +++ b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 03:38:31.733163513 -0400
220 @@ -1145,6 +1145,22 @@ Generic_GCC::GCCInstallationDetector::GC
221 Prefixes.push_back(D.InstalledDir + "/..");
222 }
223
224 + llvm::OwningPtr<llvm::MemoryBuffer> File;
225 + if (!llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + D.DefaultTargetTriple, File))
226 + {
227 + bool Exists;
228 + const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
229 + const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + D.DefaultTargetTriple + "/" + VersionText;
230 + if (!llvm::sys::fs::exists(GentooPath + "/crtbegin.o", Exists) && Exists)
231 + {
232 + Version = GCCVersion::Parse(VersionText);
233 + GCCInstallPath = GentooPath;
234 + GCCParentLibPath = GCCInstallPath + "/../../..";
235 + IsValid = true;
236 + return;
237 + }
238 + }
239 +
240 // Loop over the various components which exist and select the best GCC
241 // installation available. GCC installs are ranked by version number.
242 Version = GCCVersion::Parse("0.0.0");
243
244
245
246 1.1 sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch
247
248 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch?rev=1.1&view=markup
249 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch?rev=1.1&content-type=text/plain
250
251 Index: clang-3.1-gentoo-linux-fix-cxx-include.patch
252 ===================================================================
253 diff -upNr a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
254 --- a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-25 20:32:28.859469000 -0400
255 +++ b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-25 20:33:15.988680000 -0400
256 @@ -2305,8 +2305,7 @@ void Linux::AddClangCXXStdlibIncludeArgs
257 // Gentoo is weird and places its headers inside the GCC install, so if the
258 // first attempt to find the headers fails, try this pattern.
259 addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
260 - (GCCInstallation.getTriple().str() +
261 - GCCInstallation.getMultiarchSuffix()),
262 + getDriver().DefaultTargetTriple,
263 DriverArgs, CC1Args);
264 }
265 }
266
267
268
269 1.1 sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch
270
271 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch?rev=1.1&view=markup
272 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch?rev=1.1&content-type=text/plain
273
274 Index: clang-3.1-gentoo-freebsd-fix-lib-path.patch
275 ===================================================================
276 diff -upNr a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
277 --- a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 04:08:48.393073000 -0400
278 +++ b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 04:11:38.113153421 -0400
279 @@ -1635,6 +1635,8 @@ FreeBSD::FreeBSD(const Driver &D, const
280 getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
281 else
282 getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
283 +
284 + getFilePaths().push_back(GCCInstallation.getInstallPath());
285 }
286
287 Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA,