Beispiel #1
0
def has_std_atomics(compiler_val):
    try:
        compiler_name = chpl_compiler.get_compiler_name_c(compiler_val)
        if compiler_name == 'unknown-c-compiler':
            return False

        version_key='version'
        atomics_key='atomics'

        cmd_input = '{0}=__STDC_VERSION__\n{1}=__STDC_NO_ATOMICS__'.format(version_key, atomics_key)
        cmd = [compiler_name, '-E', '-x', 'c', '-']
        output = run_command(cmd, cmd_input=cmd_input)
        output = strip_preprocessor_lines(output.splitlines())

        output_dict = dict(line.split('=') for line in output)
        version = output_dict[version_key].rstrip("L")
        atomics = output_dict[atomics_key]

        if version == "__STDC_VERSION__" or int(version) < 201112:
            return False
        # If the atomics macro was expanded, then we do not have support.
        if atomics != "__STDC_NO_ATOMICS__":
            return False
        return True
    except:
        return False
Beispiel #2
0
def get_compiler_version(compiler):
    version_string = '0'
    if 'gnu' in compiler:
        # Asssuming the 'compiler' version matches the gcc version
        # e.g., `mpicc -dumpversion == gcc -dumpversion`
        gcc = chpl_compiler.get_compiler_name_c(compiler)
        version_string = run_command([gcc, '-dumpversion'])
    elif 'cray-prgenv-cray' == compiler:
        version_string = os.environ.get('CRAY_CC_VERSION', '0')
    return CompVersion(version_string)
Beispiel #3
0
def main():

    global chpl_home_dir
    check_file = os.path.relpath(__file__, chpl_home_dir)
    check_path = os.path.join(chpl_home_dir, check_file)
    if not os.path.isfile(check_path):
        sys.stderr.write("Warning: check {0} not found\n".format(check_path))

    if "CHPL_HOME" in os.environ:
        if os.path.abspath(os.environ["CHPL_HOME"]) != chpl_home_dir:
            # to be sure, check that the inode numbers of our check file match
            env_check = os.path.join(os.environ["CHPL_HOME"], check_file)
            rel_check = os.path.join(chpl_home_dir, check_file)
            if os.path.samefile(env_check, rel_check):
                # No warning, it's OK, they are the same file.
                pass
            else:
                sys.stderr.write("Warning: check {0} not found\n".format(check_path))
                sys.stderr.write("Warning: Mismatched CHPL_HOME; got {0} but expected {1}\n".format(os.path.abspath(os.environ["CHPL_HOME"]), chpl_home_dir))

        chpl_home_dir = os.environ["CHPL_HOME"] # use enviro var spelling of it
    else:
        os.environ["CHPL_HOME"] = chpl_home_dir

    os.environ["CHPL_MAKE_HOME"] = chpl_home_dir
    if "CHPL_RUNTIME_LIB" in os.environ:
        os.environ["CHPL_MAKE_RUNTIME_LIB"] = os.environ["CHPL_RUNTIME_LIB"]

    if "CHPL_RUNTIME_INCL" in os.environ:
        os.environ["CHPL_MAKE_RUNTIME_INCL"] = os.environ["CHPL_RUNTIME_INCL"]

    if "CHPL_THIRD_PARTY" in os.environ:
        os.environ["CHPL_MAKE_THIRD_PARTY"] = os.environ["CHPL_THIRD_PARTY"]

    make = chpl_make.get()

    orig_make = make
    # Do not print directory changes.
    make = [make, "--no-print-directory"]

    # Make reasonable defaults for environment settings
    os.environ["COMP_GEN_WARN"] = "0"
    os.environ["COMP_GEN_DEBUG"] = "0"
    os.environ["COMP_GEN_OPT"] = "0"
    os.environ["COMP_GEN_SPECIALIZE"] = "0"
    os.environ["COMP_GEN_IEEE_FLOAT"] = "1"

    actions = parseArguments()

    make_helper = make + ["-f", chpl_home_dir + "/runtime/etc/Makefile.include"]

    for a in actions:
        if a == "home":
            sys.stdout.write("{0}\n".format(chpl_home_dir))
        elif a == "make":
            sys.stdout.write("{0}\n".format(orig_make))
        elif a == "llvm":
            os.environ["CHPL_TARGET_COMPILER_PRGENV"] = chpl_compiler.get_prgenv_compiler()
            os.environ["CHPL_TARGET_COMPILER"] = "llvm"

            llvm = ""
            if "CHPL_LLVM" in os.environ:
                llvm = os.environ["CHPL_LLVM"]
            if "CHPL_MAKE_LLVM" in os.environ:
                llvm = os.environ["CHPL_MAKE_LLVM"]
            if llvm == "":
                llvm = chpl_llvm.get()
            if llvm == "none":
                sys.stderr.write("Cannot get --llvm configuration with CHPL_LLVM=none\n")
                sys.exit(1)
        elif a == "compilecc":
            mysystem(make_helper, "printcompileline")
        elif a == "compilecxx":
            mysystem(make_helper, "printcxxcompileline")
        elif a == "compiler":
            mysystem(make_helper, "printccompiler")
        elif a == "cflags":
            mysystem(make_helper, "printcflags")
        elif a == "cxxflags":
            mysystem(make_helper, "printcxxflags")
        elif a == "includesanddefines":
            mysystem(make_helper, "printincludesanddefines")
        elif a == "libraries":
            mysystem(make_helper, "printlibraries")
        elif a == "linker":
            mysystem(make_helper, "printlinker")
        elif a == "linkershared":
            mysystem(make_helper, "printlinkershared")
        elif a == "maino":
            mysystem(make_helper, "printmaino")
        elif a == "llvminstalldir":
            mysystem(make_helper, "printllvminstall")
        elif a == "clangcc":
            mysystem(make_helper, "printclangcc")
        elif a == "clangcxx":
            mysystem(make_helper, "printclangcxx")
        elif a == "clangsysroot":
            mysystem(make_helper, "printclangcxx")
            llvminstall = myrun(make_helper, "printllvminstall")
            llvminstall = llvminstall.strip()
            fname = os.path.join(llvminstall, "configured-clang-sysroot-arguments")
            if os.path.isfile(fname):
                with open(fname) as f:
                    for line in f:
                        sys.stdout.write(line)
        elif a == "launcherlibdir":
          mysystem(make_helper, "printlauncherlibdir")
        elif a == "multilocale-lib-deps":
          mysystem(make_helper, "printmultilocalelibdeps")
        elif a == "host-c-compiler":
          compiler_family = chpl_compiler.get("host")
          compiler = chpl_compiler.get_compiler_name_c(compiler_family)
          sys.stdout.write("{}\n".format(compiler))
        elif a == "host-cxx-compiler":
          compiler_family = chpl_compiler.get("host")
          compiler = chpl_compiler.get_compiler_name_cxx(compiler_family)
          sys.stdout.write("{}\n".format(compiler))