2 # Copyright 2012 The Chromium Authors
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
9 from __future__ import print_function
18 """Decorator that defines a diagnostic check."""
21 all_checks.append((name, func))
27 @Check("/usr/bin/ld is not gold")
29 proc = subprocess.Popen(['/usr/bin/ld', '-v'], stdout=subprocess.PIPE)
30 stdout = proc.communicate()[0].decode('utf-8')
31 if 'GNU gold' in stdout:
32 return ("When /usr/bin/ld is gold, system updates can silently\n"
33 "corrupt your graphics drivers.\n"
34 "Try 'sudo apt-get remove binutils-gold'.\n")
38 @Check("random lds are not in the $PATH")
40 proc = subprocess.Popen(['which', '-a', 'ld'], stdout=subprocess.PIPE)
41 stdout = proc.communicate()[0].decode('utf-8')
42 instances = stdout.split()
43 if len(instances) > 1:
44 return ("You have multiple 'ld' binaries in your $PATH:\n" +
45 '\n'.join(' - ' + i for i in instances) + "\n"
46 "You should delete all of them but your system one.\n"
47 "gold is hooked into your build via depot tools.\n")
51 @Check("/usr/bin/ld doesn't point to gold")
53 # Check /usr/bin/ld* symlinks.
54 for path in ('ld.bfd', 'ld'):
55 path = '/usr/bin/' + path
57 target = os.readlink(path)
60 continue # No such file
62 continue # Not a symlink
64 if '/usr/local/gold' in target:
65 return ("%s is a symlink into /usr/local/gold.\n"
66 "It's difficult to make a recommendation, because you\n"
67 "probably set this up yourself. But you should make\n"
68 "/usr/bin/ld be the standard linker, which you likely\n"
69 "renamed /usr/bin/ld.bfd or something like that.\n" % path)
74 @Check("random ninja binaries are not in the $PATH")
76 proc = subprocess.Popen(['which', 'ninja'], stdout=subprocess.PIPE)
77 stdout = proc.communicate()[0].decode('utf-8')
78 if not 'depot_tools' in stdout:
79 return ("The ninja binary in your path isn't from depot_tools:\n" + " " +
80 stdout + "Remove custom ninjas from your path so that the one\n"
81 "in depot_tools is used.\n")
85 @Check("build dependencies are satisfied")
87 script_path = os.path.join(
88 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'build',
89 'install-build-deps.sh')
90 proc = subprocess.Popen([script_path, '--quick-check'],
91 stdout=subprocess.PIPE)
92 stdout = proc.communicate()[0].decode('utf-8')
93 if 'WARNING' in stdout:
94 return ("Your build dependencies are out-of-date.\n"
95 "Run '" + script_path + "' to update.")
100 for name, check in all_checks:
101 sys.stdout.write("* Checking %s: " % name)
111 if __name__ == '__main__':