brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 4bce33d Raw
50 lines · python
1import subprocess2 3 4def getRoot(config):5    if not config.parent:6        return config7    return getRoot(config.parent)8 9 10def is_gold_linker_available():11 12    if not config.gold_executable:13        return False14    try:15        ld_cmd = subprocess.Popen(16            [config.gold_executable, "--help"], stdout=subprocess.PIPE17        )18        ld_out = ld_cmd.stdout.read().decode()19        ld_cmd.wait()20    except:21        return False22 23    if not "-plugin" in ld_out:24        return False25 26    # config.clang is not guaranteed to be just the executable!27    clang_cmd = subprocess.Popen(28        " ".join([config.clang, "-fuse-ld=gold", "-xc", "-"]),29        shell=True,30        universal_newlines=True,31        stdin=subprocess.PIPE,32        stdout=subprocess.PIPE,33        stderr=subprocess.PIPE,34    )35    clang_err = clang_cmd.communicate("int main() { return 0; }")[1]36 37    if not "invalid linker" in clang_err:38        return True39 40    return False41 42 43root = getRoot(config)44 45if root.target_os not in ["Linux"] or not is_gold_linker_available():46    config.unsupported = True47 48if config.have_curl:49    config.available_features.add("curl")50