blob: 00bf28016eba0c534652c76d3afffb9e31694d8e (
plain)
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
|
From 0384060d2de35ee56aa252cc18eccf773d674d56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Fri, 5 Sep 2014 16:49:35 +0200
Subject: [PATCH] driver: Support obtaining active toolchain from gcc-config on
Gentoo
Author: Richard Yao <ryao@gentoo.org>
Bug: https://bugs.gentoo.org/406163
Bug: https://bugs.gentoo.org/417913
---
lib/Driver/ToolChains.cpp | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 67f165c..0f0d786 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1430,6 +1430,31 @@ void Generic_GCC::GCCInstallationDetector::init(
}
}
+ // Try to respect gcc-config on Gentoo. However, do that only
+ // if --gcc-toolchain is not provided or equal to the Gentoo default.
+ // This avoids accidentally enforcing system GCC version when using
+ // a custom toolchain.
+ if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+ for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
+ llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + CandidateTripleAliases[k].str());
+ if (File)
+ {
+ const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
+ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + CandidateTripleAliases[k].str() + "/" + VersionText;
+ if (llvm::sys::fs::exists(GentooPath + "/crtbegin.o"))
+ {
+ Version = GCCVersion::Parse(VersionText);
+ GCCInstallPath = GentooPath;
+ GCCParentLibPath = GCCInstallPath + "/../../..";
+ GCCTriple.setTriple(CandidateTripleAliases[k]);
+ IsValid = true;
+ return;
+ }
+ }
+ }
+ }
+
// Loop over the various components which exist and select the best GCC
// installation available. GCC installs are ranked by version number.
Version = GCCVersion::Parse("0.0.0");
--
2.10.0
|