2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Diagnose some common system configuration problems on Linux, and
16 """Decorator that defines a diagnostic check."""
18 all_checks
.append((name
, func
))
23 @Check("/usr/bin/ld is not gold")
25 proc
= subprocess
.Popen(['/usr/bin/ld', '-v'], stdout
=subprocess
.PIPE
)
26 stdout
= proc
.communicate()[0]
27 if 'GNU gold' in stdout
:
28 return ("When /usr/bin/ld is gold, system updates can silently\n"
29 "corrupt your graphics drivers.\n"
30 "Try 'sudo apt-get remove binutils-gold'.\n")
34 @Check("random lds are not in the $PATH")
36 proc
= subprocess
.Popen(['which', '-a', 'ld'], stdout
=subprocess
.PIPE
)
37 stdout
= proc
.communicate()[0]
38 instances
= stdout
.split()
39 if len(instances
) > 1:
40 return ("You have multiple 'ld' binaries in your $PATH:\n"
41 + '\n'.join(' - ' + i
for i
in instances
) + "\n"
42 "You should delete all of them but your system one.\n"
43 "gold is hooked into your build via gyp.\n")
47 @Check("/usr/bin/ld doesn't point to gold")
49 # Check /usr/bin/ld* symlinks.
50 for path
in ('ld.bfd', 'ld'):
51 path
= '/usr/bin/' + path
53 target
= os
.readlink(path
)
56 continue # No such file
58 continue # Not a symlink
60 if '/usr/local/gold' in target
:
61 return ("%s is a symlink into /usr/local/gold.\n"
62 "It's difficult to make a recommendation, because you\n"
63 "probably set this up yourself. But you should make\n"
64 "/usr/bin/ld be the standard linker, which you likely\n"
65 "renamed /usr/bin/ld.bfd or something like that.\n" % path
)
70 @Check("random ninja binaries are not in the $PATH")
72 proc
= subprocess
.Popen(['which', 'ninja'], stdout
=subprocess
.PIPE
)
73 stdout
= proc
.communicate()[0]
74 if not 'depot_tools' in stdout
:
75 return ("The ninja binary in your path isn't from depot_tools:\n"
77 "Remove custom ninjas from your path so that the one\n"
78 "in depot_tools is used.\n")
82 @Check("build dependencies are satisfied")
84 script_path
= os
.path
.join(
85 os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))), 'build',
86 'install-build-deps.sh')
87 proc
= subprocess
.Popen([script_path
, '--quick-check'],
88 stdout
=subprocess
.PIPE
)
89 stdout
= proc
.communicate()[0]
90 if 'WARNING' in stdout
:
91 return ("Your build dependencies are out-of-date.\n"
92 "Run '" + script_path
+ "' to update.")
97 for name
, check
in all_checks
:
98 sys
.stdout
.write("* Checking %s: " % name
)
108 if __name__
== '__main__':