• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import subprocess
2
3def getRoot(config):
4  if not config.parent:
5    return config
6  return getRoot(config.parent)
7
8
9def is_gold_linker_available():
10
11  if not config.gold_executable:
12    return False
13  try:
14    ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE)
15    ld_out = ld_cmd.stdout.read().decode()
16    ld_cmd.wait()
17  except:
18    return False
19
20  if not '-plugin' in ld_out:
21    return False
22
23  clang_cmd = subprocess.Popen([config.clang, '-fuse-ld=gold', '-xc', '-'],
24                               stdin = subprocess.PIPE,
25                               stdout = subprocess.PIPE,
26                               stderr = subprocess.PIPE)
27  clang_err = clang_cmd.communicate('int main() { return 0; }')[1]
28
29  if not 'invalid linker' in clang_err:
30    return True
31
32  return False
33
34root = getRoot(config)
35
36if root.host_os not in ['Linux'] or not is_gold_linker_available():
37  config.unsupported = True
38