xref: /aosp_15_r20/external/compiler-rt/test/profile/Linux/lit.local.cfg (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robotimport subprocess
2*7c3d14c8STreehugger Robot
3*7c3d14c8STreehugger Robotdef getRoot(config):
4*7c3d14c8STreehugger Robot  if not config.parent:
5*7c3d14c8STreehugger Robot    return config
6*7c3d14c8STreehugger Robot  return getRoot(config.parent)
7*7c3d14c8STreehugger Robot
8*7c3d14c8STreehugger Robot
9*7c3d14c8STreehugger Robotdef is_gold_linker_available():
10*7c3d14c8STreehugger Robot
11*7c3d14c8STreehugger Robot  if not config.gold_executable:
12*7c3d14c8STreehugger Robot    return False
13*7c3d14c8STreehugger Robot  try:
14*7c3d14c8STreehugger Robot    ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE)
15*7c3d14c8STreehugger Robot    ld_out = ld_cmd.stdout.read().decode()
16*7c3d14c8STreehugger Robot    ld_cmd.wait()
17*7c3d14c8STreehugger Robot  except:
18*7c3d14c8STreehugger Robot    return False
19*7c3d14c8STreehugger Robot
20*7c3d14c8STreehugger Robot  if not '-plugin' in ld_out:
21*7c3d14c8STreehugger Robot    return False
22*7c3d14c8STreehugger Robot
23*7c3d14c8STreehugger Robot  clang_cmd = subprocess.Popen([config.clang, '-fuse-ld=gold', '-xc', '-'],
24*7c3d14c8STreehugger Robot                               stdin = subprocess.PIPE,
25*7c3d14c8STreehugger Robot                               stdout = subprocess.PIPE,
26*7c3d14c8STreehugger Robot                               stderr = subprocess.PIPE)
27*7c3d14c8STreehugger Robot  clang_err = clang_cmd.communicate('int main() { return 0; }')[1]
28*7c3d14c8STreehugger Robot
29*7c3d14c8STreehugger Robot  if not 'invalid linker' in clang_err:
30*7c3d14c8STreehugger Robot    return True
31*7c3d14c8STreehugger Robot
32*7c3d14c8STreehugger Robot  return False
33*7c3d14c8STreehugger Robot
34*7c3d14c8STreehugger Robotroot = getRoot(config)
35*7c3d14c8STreehugger Robot
36*7c3d14c8STreehugger Robotif root.host_os not in ['Linux'] or not is_gold_linker_available():
37*7c3d14c8STreehugger Robot  config.unsupported = True
38