Exemplo n.º 1
0
def get_clang_prgenv_args():

    platform = chpl_platform.get('target')
    comp_args = []
    link_args = []

    if chpl_compiler.get_prgenv_compiler() != 'none':
        # When running on a PrgEnv system, gather the PrgEnv arguments

        # Set up the environment to make the proper libraries and include
        # files available.
        os.environ['PE_PKGCONFIG_PRODUCTS'] = (
            'PE_CHAPEL:' + os.environ.get('PE_PKGCONFIG_PRODUCTS', ''))

        os.environ['PE_CHAPEL_MODULE_NAME'] = 'chapel'
        os.environ['PE_CHAPEL_PKGCONFIG_LIBS'] = gather_pe_chpl_pkgconfig_libs(
        )

        # Use cc --cray-print-opts=... to get arguments from compiler driver

        # Get compilation arguments
        opts = run_command(['cc', '--cray-print-opts=cflags'])
        comp_args.extend(opts.split())

        # Get link arguments
        opts = run_command(['cc', '--cray-print-opts=libs'])
        link_args.extend(opts.split())

    return (comp_args, link_args)
Exemplo n.º 2
0
def target_compiler_is_prgenv(bypass_llvm=True):
    compiler_val = chpl_compiler.get('target')

    # But for CHPL_TARGET_COMPILER=llvm, look at the original target compiler
    if bypass_llvm:
        if compiler_val == 'llvm':
            compiler_val = chpl_compiler.get_prgenv_compiler()

    isprgenv = chpl_compiler.compiler_is_prgenv(compiler_val)
    return isprgenv
Exemplo n.º 3
0
def gather_pe_chpl_pkgconfig_libs():
    # Don't do anything if we aren't using a PrgEnv compiler
    if chpl_compiler.get_prgenv_compiler() == 'none':
        return ""

    import chpl_comm, chpl_comm_substrate, chpl_aux_filesys, chpl_libfabric

    platform = chpl_platform.get('target')
    comm = chpl_comm.get()
    substrate = chpl_comm_substrate.get()
    auxfs = chpl_aux_filesys.get()

    ret = os.environ.get('PE_CHAPEL_PKGCONFIG_LIBS', '')
    if comm != 'none':
        if platform != 'hpe-cray-ex':
            # Adding -lhugetlbfs gets the PrgEnv driver to add the appropriate
            # linker option for static linking with it. While it's not always
            # used with Chapel programs, it is expected to be the common case
            # when running on a Cray X*, so just always linking it is ok.
            # (We don't add it for HPE Cray EX systems, where it's not needed.)
            ret = 'craype-hugetlbfs:cray-pmi:' + ret

        if platform.startswith('cray-x'):
            ret = 'cray-ugni:' + ret

        if comm == 'gasnet' and substrate == 'aries':
            ret = 'cray-udreg:' + ret

        if comm == 'ofi' and chpl_libfabric.get() == 'system':
            ret = 'libfabric:' + ret

        # on login/compute nodes, lustre requires the devel api to make
        # lustre/lustreapi.h available (it's implicitly available on esl nodes)
        if 'lustre' in auxfs:
            exists, returncode, out, err = try_run_command(
                ['pkg-config', '--exists', 'cray-lustre-api-devel'])
            if exists and returncode == 0:
                ret = 'cray-lustre-api-devel:' + ret

    return ret
Exemplo n.º 4
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))