Example #1
0
def get(flag='host'):

    if flag == 'host':
        compiler_val = overrides.get('CHPL_HOST_COMPILER', '')

    elif flag == 'target':
        compiler_val = overrides.get('CHPL_TARGET_COMPILER', '')

    else:
        error("Invalid flag: '{0}'".format(flag), ValueError)

    # If compiler_val was not set, look at CC/CXX
    if not compiler_val:
        compiler_val = get_compiler_from_cc_cxx()

    if compiler_val:
        validate(compiler_val)
        return compiler_val

    prgenv_compiler = get_prgenv_compiler()
    has_llvm = 'unset'

    if flag == 'target':
        import chpl_llvm
        has_llvm = chpl_llvm.get()

    if flag == 'target' and (has_llvm == 'bundled' or has_llvm == 'system'):
        # Default to CHPL_TARGET_COMPILER=llvm when CHPL_LLVM!=none
        compiler_val = 'llvm'

    elif prgenv_compiler != 'none':
        # The cray platforms are a special case in that we want to
        # "cross-compile" by default. (the compiler is different between host
        # and target, but the platform is the same).
        if flag == 'host':
            compiler_val = 'gnu'
        else:
            compiler_val = prgenv_compiler

    else:
        platform_val = chpl_platform.get(flag)
        # Normal compilation (not "cross-compiling")
        # inherit the host compiler if the target compiler is not set and
        # the host and target platforms are the same
        if flag == 'target':
            if chpl_platform.get('host') == platform_val:
                compiler_val = get('host')
        elif platform_val.startswith('pwr'):
            compiler_val = 'ibm'
        elif platform_val == 'darwin' or platform_val == 'freebsd':
            if find_executable('clang'):
                compiler_val = 'clang'
            else:
                compiler_val = 'gnu'
        else:
            compiler_val = 'gnu'

    validate(compiler_val)
    return compiler_val
Example #2
0
def get_compiler_command(flag, lang):

    flag_upper = flag.upper()
    lang_upper = lang.upper()

    if lang_upper == 'C++':
        lang_upper = 'CXX'
    elif lang_upper == 'C':
        lang_upper = 'CC'

    if flag_upper == 'HOST' or flag_upper == 'TARGET':
        pass
    else:
        error('unknown flag {0}'.format(flag))

    if lang_upper == 'CC' or lang_upper == 'CXX':
        pass
    else:
        error('unknown lang {0}'.format(lang))

    # construct CHPL_HOST_CC / CHPL_TARGET_CXX etc
    varname = 'CHPL_' + flag_upper + '_' + lang_upper

    command = overrides.get(varname, '')
    if command:
        return command.split()

    compiler_val = get(flag=flag)

    # If other settings allow it, look also at CC/CXX.
    if should_consider_cc_cxx(flag):
        cc_cxx_val = overrides.get(lang_upper, '')
        if cc_cxx_val:
            return cc_cxx_val.split()

    if lang_upper == 'CC':
        command = [get_compiler_name_c(compiler_val)]
    elif lang_upper == 'CXX':
        command = [get_compiler_name_cxx(compiler_val)]

    # Adjust the path in two situations:
    #  CHPL_TARGET_COMPILER=llvm -- means use the selected llvm/clang
    #  CHPL_TARGET_COMPILER=clang with CHPL_LLVM=bundled -- use bundled clang
    if compiler_val == 'clang' or compiler_val == 'llvm':
        import chpl_llvm
        llvm_val = chpl_llvm.get()
        if llvm_val == 'none' and compiler_val == 'llvm':
            error("Cannot use CHPL_TARGET_COMPILER=llvm when CHPL_LLVM=none")
        if llvm_val == 'bundled' or compiler_val == 'llvm':
            if (flag == 'host' and llvm_val == 'bundled'
                    and compiler_val == 'clang'):
                # don't change the prefix in this setting
                # (bundled LLVM might not be built yet)
                pass

            else:
                command = chpl_llvm.get_llvm_clang(lang_upper)

    return command
def get_link_args():
    link_args = third_party_utils.default_get_link_args(
        "qthread", ucp=get_uniq_cfg_path(), libs=["libqthread_chpl.la", "-lchpl", "libqthread.la"]
    )
    compiler_val = chpl_compiler.get("target")
    if compiler_val == "cray-prgenv-cray" or (compiler_is_prgenv(compiler_val) and chpl_llvm.get() != "none"):
        link_args.append("-lrt")
    return link_args
def get_link_args():
    link_args = \
        third_party_utils.default_get_link_args('qthread',
                                                ucp=get_uniq_cfg_path(),
                                                libs=['libqthread_chpl.la',
                                                      '-lchpl',
                                                      'libqthread.la'])
    if ( chpl_compiler.get('target').startswith('cray-prgenv') and
         chpl_llvm.get() != 'none' ):
        link_args.append('-lrt')
    return link_args
Example #5
0
def get_link_args():
    link_args = \
        third_party_utils.default_get_link_args('qthread',
                                                ucp=get_uniq_cfg_path(),
                                                libs=['libqthread_chpl.la',
                                                      '-lchpl',
                                                      'libqthread.la'])
    if (chpl_compiler.get('target').startswith('cray-prgenv')
            and chpl_llvm.get() != 'none'):
        link_args.append('-lrt')
    return link_args
def get_link_args():
    link_args = \
        third_party_utils.default_get_link_args('qthread',
                                                ucp=get_uniq_cfg_path(),
                                                libs=['libqthread_chpl.la',
                                                      '-lchpl',
                                                      'libqthread.la'])
    compiler_val = chpl_compiler.get('target')
    if ( compiler_val == 'cray-prgenv-cray' or
         (compiler_is_prgenv(compiler_val) and chpl_llvm.get() != 'none' )):
        link_args.append('-lrt')
    return link_args
Example #7
0
def default_to_llvm(flag):
    ret = False

    if flag == 'target':
        import chpl_llvm
        has_llvm = chpl_llvm.get()

        if has_llvm == 'bundled' or has_llvm == 'system':
            # Default to CHPL_TARGET_COMPILER=llvm when CHPL_LLVM!=none
            ret = True

    return ret
def get_link_args():
    link_args = \
        third_party_utils.default_get_link_args('qthread',
                                                ucp=get_uniq_cfg_path(),
                                                libs=['libqthread_chpl.la',
                                                      '-lchpl',
                                                      'libqthread.la'])
    compiler_val = chpl_compiler.get('target')
    if ( compiler_val == 'cray-prgenv-cray' or
         (compiler_is_prgenv(compiler_val) and chpl_llvm.get() != 'none' )):
        link_args.append('-lrt')
    return link_args
Example #9
0
def get_path_component(flag='host'):

    val = get(flag=flag)

    if val == 'clang' and flag == 'target':

        import chpl_llvm
        has_llvm = chpl_llvm.get()

        if has_llvm == 'bundled':
            # selecting the included clang - distinguish that
            # with 'llvm' in the path component.
            val = 'llvm'

    return get(flag)
Example #10
0
        values=['none', 're2'],
        default=chpl_regexp.get(),
        help_text='Regular expression ({var_name}) values to build.',
    ),
    Dimension(
        'localeModel',
        'CHPL_LOCALE_MODEL',
        values=['flat', 'knl', 'numa'],
        default=chpl_locale_model.get(),
        help_text='Locale model ({var_name}) values to build.',
    ),
    Dimension(
        'llvm',
        'CHPL_LLVM',
        values=['none', 'llvm', 'system'],
        default=chpl_llvm.get(),
        help_text='LLVM ({var_name}) values to build.',
    ),
]


class Config(object):
    def __init__(self, *args, **kwargs):
        """Initialize new configuration value. Arguments are based on the dimensions
        object. Order is important and should also be based on the iteration
        order of dimensions.
        """
        for i, dim in enumerate(Dimensions):
            setattr(self, dim.name, args[i])

    def __repr__(self):
Example #11
0
    Dimension(
        'regexp', 'CHPL_REGEXP',
        values=['none', 're2'],
        default=chpl_regexp.get(),
        help_text='Regular expression ({var_name}) values to build.',
    ),
    Dimension(
        'localeModel', 'CHPL_LOCALE_MODEL',
        values=['flat', 'numa'],
        default=chpl_locale_model.get(),
        help_text='Locale model ({var_name}) values to build.',
    ),
    Dimension(
        'llvm', 'CHPL_LLVM',
        values=['none', 'llvm'],
        default=chpl_llvm.get(),
        help_text='LLVM ({var_name}) values to build.',
    ),
]


class Config(object):

    def __init__(self, *args, **kwargs):
        """Initialize new configuration value. Arguments are based on the dimensions
        object. Order is important and should also be based on the iteration
        order of dimensions.
        """
        for i, dim in enumerate(Dimensions):
            setattr(self, dim.name, args[i])
Example #12
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))