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