1 |
In Gentoo Prefix on Mac OS X systems, LLVM/clang is used as the |
2 |
toolchain, so no gcc/gcc-config around. Probe for clang after we failed |
3 |
to locate gcc, so we can show clang version instead. |
4 |
--- |
5 |
pym/_emerge/actions.py | 39 ++++++++++++++++++++++++++++++++++++++- |
6 |
1 file changed, 38 insertions(+), 1 deletion(-) |
7 |
|
8 |
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py |
9 |
index 59626ad..1d324aa 100644 |
10 |
--- a/pym/_emerge/actions.py |
11 |
+++ b/pym/_emerge/actions.py |
12 |
@@ -39,6 +39,7 @@ from portage import os |
13 |
from portage import shutil |
14 |
from portage import eapi_is_supported, _encodings, _unicode_decode |
15 |
from portage.cache.cache_errors import CacheError |
16 |
+from portage.const import EPREFIX |
17 |
from portage.const import GLOBAL_CONFIG_PATH, VCS_DIRS, _DEPCLEAN_LIB_CHECK_DEFAULT |
18 |
from portage.const import SUPPORTED_BINPKG_FORMATS, TIMESTAMP_FORMAT |
19 |
from portage.dbapi.dep_expand import dep_expand |
20 |
@@ -2406,12 +2407,23 @@ def getgccversion(chost=None): |
21 |
gcc_ver_command = ['gcc', '-dumpversion'] |
22 |
gcc_ver_prefix = 'gcc-' |
23 |
|
24 |
+ clang_ver_command = ['clang', '--version'] |
25 |
+ clang_ver_prefix = 'clang-' |
26 |
+ |
27 |
+ ubinpath = os.path.join('/', portage.const.EPREFIX, 'usr', 'bin') |
28 |
+ |
29 |
gcc_not_found_error = red( |
30 |
"!!! No gcc found. You probably need to 'source /etc/profile'\n" + |
31 |
"!!! to update the environment of this terminal and possibly\n" + |
32 |
"!!! other terminals also.\n" |
33 |
) |
34 |
|
35 |
+ def getclangversion(output): |
36 |
+ version = re.search('clang version ([0-9.]+) ', output) |
37 |
+ if version: |
38 |
+ return version.group(1) |
39 |
+ return "unknown" |
40 |
+ |
41 |
if chost: |
42 |
try: |
43 |
proc = subprocess.Popen(["gcc-config", "-c"], |
44 |
@@ -2439,7 +2451,7 @@ def getgccversion(chost=None): |
45 |
return gcc_ver_prefix + myoutput |
46 |
|
47 |
try: |
48 |
- proc = subprocess.Popen(gcc_ver_command, |
49 |
+ proc = subprocess.Popen([ubinpath + "/" + gcc_ver_command[0]] + gcc_ver_command[1:], |
50 |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
51 |
except OSError: |
52 |
myoutput = None |
53 |
@@ -2450,6 +2462,31 @@ def getgccversion(chost=None): |
54 |
if mystatus == os.EX_OK: |
55 |
return gcc_ver_prefix + myoutput |
56 |
|
57 |
+ try: |
58 |
+ proc = subprocess.Popen( |
59 |
+ [ubinpath + "/" + chost + "-" + clang_ver_command[0]] + clang_ver_command[1:], |
60 |
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
61 |
+ except OSError: |
62 |
+ myoutput = None |
63 |
+ mystatus = 1 |
64 |
+ else: |
65 |
+ myoutput = _unicode_decode(proc.communicate()[0]).rstrip("\n") |
66 |
+ mystatus = proc.wait() |
67 |
+ if mystatus == os.EX_OK: |
68 |
+ return clang_ver_prefix + getclangversion(myoutput) |
69 |
+ |
70 |
+ try: |
71 |
+ proc = subprocess.Popen([ubinpath + "/" + clang_ver_command[0]] + clang_ver_command[1:], |
72 |
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
73 |
+ except OSError: |
74 |
+ myoutput = None |
75 |
+ mystatus = 1 |
76 |
+ else: |
77 |
+ myoutput = _unicode_decode(proc.communicate()[0]).rstrip("\n") |
78 |
+ mystatus = proc.wait() |
79 |
+ if mystatus == os.EX_OK: |
80 |
+ return clang_ver_prefix + getclangversion(myoutput) |
81 |
+ |
82 |
portage.writemsg(gcc_not_found_error, noiselevel=-1) |
83 |
return "[unavailable]" |
84 |
|
85 |
-- |
86 |
2.7.0 |