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
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) default_llvm = False if not compiler_val: default_llvm = default_to_llvm(flag) # If allowable, look at CC/CXX if should_consider_cc_cxx(flag): compiler_val = get_compiler_from_cc_cxx() if compiler_val: validate_compiler(compiler_val) return compiler_val prgenv_compiler = get_prgenv_compiler() if default_llvm: 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(compiler_val) return compiler_val
def get(flag='host', llvm_mode='default'): if flag == 'host': compiler_val = overrides.get('CHPL_HOST_COMPILER', '') elif flag == 'target': compiler_val = overrides.get('CHPL_TARGET_COMPILER', '') if llvm_mode == 'llvm': compiler_val = 'clang-included' elif llvm_mode == 'default' and "CHPL_LLVM_CODEGEN" in os.environ: compiler_val = 'clang-included' else: error("Invalid flag: '{0}'".format(flag), ValueError) if compiler_val: return compiler_val platform_val = chpl_platform.get(flag) # 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 platform_val.startswith('cray-x'): if flag == 'host': compiler_val = 'gnu' else: subcompiler = os.environ.get('PE_ENV', 'none') if subcompiler == 'none': stderr.write( "Warning: Compiling on {0} without a PrgEnv loaded\n". format(platform_val)) compiler_val = "cray-prgenv-{0}".format(subcompiler.lower()) elif chpl_platform.is_cross_compiling(): if flag == 'host': compiler_val = 'gnu' else: compiler_val = platform_val + '-gnu' else: # 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' return compiler_val
def get(flag='host', llvm_mode='default'): if flag == 'host': compiler_val = overrides.get('CHPL_HOST_COMPILER', '') elif flag == 'target': compiler_val = overrides.get('CHPL_TARGET_COMPILER', '') if llvm_mode == 'llvm': compiler_val = 'clang-included' elif llvm_mode == 'default': if ("CHPL_LLVM_CODEGEN" in os.environ and os.environ["CHPL_LLVM_CODEGEN"] != "0"): compiler_val = 'clang-included' else: error("Invalid flag: '{0}'".format(flag), ValueError) if compiler_val: return compiler_val platform_val = chpl_platform.get(flag) # 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 platform_val.startswith('cray-x'): if flag == 'host': compiler_val = 'gnu' else: subcompiler = os.environ.get('PE_ENV', 'none') if subcompiler == 'none': sys.stderr.write("Warning: Compiling on {0} without a PrgEnv loaded\n".format(platform_val)) compiler_val = "cray-prgenv-{0}".format(subcompiler.lower()) elif chpl_platform.is_cross_compiling(): if flag == 'host': compiler_val = 'gnu' else: compiler_val = platform_val + '-gnu' else: # 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' return compiler_val
def get(): comm_val = os.environ.get("CHPL_COMM") if not comm_val: platform_val = chpl_platform.get("target") compiler_val = chpl_compiler.get("target") # use ugni on cray-x* machines using the module and supported compiler # # Check that target arch is not knc. Don't use chpl_arch.get(), though, # since it already calls into this get() function. This check only # happens for X* systems using the Cray programming environment, so it # is safe to assume the relevant craype module will be used that sets # CRAY_CPU_TARGET. if ( platform_val.startswith("cray-x") and utils.using_chapel_module() and compiler_val in ("cray-prgenv-gnu", "cray-prgenv-intel") and os.getenv("CRAY_CPU_TARGET", "") != "knc" ): comm_val = "ugni" # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith("cray-"): comm_val = "gasnet" else: comm_val = "none" return comm_val
def get(): substrate_val = os.environ.get('CHPL_COMM_SUBSTRATE') if not substrate_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') arch_val = chpl_arch.get('target') if comm_val == 'gasnet': if platform_val == 'cray-xt': substrate_val = 'mpi' elif platform_val == 'cray-xe': substrate_val = 'gemini' elif platform_val == 'cray-xk': substrate_val = 'gemini' elif platform_val == 'cray-xc': if arch_val == 'knc': substrate_val = 'mpi' else: substrate_val = 'aries' elif platform_val == 'marenostrum': substrate_val = 'udp' elif platform_val == 'pwr5': substrate_val = 'lapi' elif platform_val == 'pwr6': substrate_val = 'ibv' else: substrate_val = 'udp' else: substrate_val = 'none' return substrate_val
def get(): comm_val = os.environ.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') # use ugni on cray-x* machines using the module and supported compiler # # Check that target arch is not knc. Don't use chpl_arch.get(), though, # since it already calls into this get() function. This check only # happens for X* systems using the Cray programming environment, so it # is safe to assume the relevant craype module will be used that sets # CRAY_CPU_TARGET. ugni_comp = ('cray-prgenv-gnu', 'cray-prgenv-intel', 'cray-prgenv-cray') if (platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ugni_comp and os.getenv('CRAY_CPU_TARGET', '') != 'knc'): comm_val = 'ugni' # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def get_chpl_venv(): chpl_venv = os.path.join(get_chpl_third_party(), 'chpl-venv') host_platform = chpl_platform.get('host') py_version = 'py{0}'.format(chpl_python_version.get()) uniq_path = os.path.join(host_platform, py_version) venv_dir = os.path.join(chpl_venv, 'install', uniq_path, 'chpl-virtualenv') return venv_dir
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: arch_val = chpl_arch.get('target', get_lcd=True) platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') comm_val = chpl_comm.get() # use muxed on cray-x* machines using the module and supported compiler if (comm_val == 'ugni' and platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ('cray-prgenv-gnu', 'cray-prgenv-intel') and arch_val != 'knc'): tasks_val = 'muxed' elif (arch_val == 'knc' or platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or compiler_val == 'pgi' or compiler_val == 'cray-prgenv-pgi' or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): launcher_val = overrides.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith('cray-x') or chpl_platform.is_cross_compiling(): has_aprun = find_executable('aprun') has_slurm = find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm or platform_val == 'aarch64': launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) sys.stderr.write( 'Warning: Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.\n') elif platform_val == 'marenostrum': launcher_val = 'marenostrum' elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': if platform_val == 'pwr6': # our loadleveler launcher is not yet portable/stable/ # flexible enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' else: launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'lapi': # our loadleveler launcher is not yet portable/stable/flexible # enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def get(): substrate_val = overrides.get('CHPL_COMM_SUBSTRATE') if not substrate_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') if comm_val == 'gasnet': if platform_val == 'cray-xe': substrate_val = 'gemini' elif platform_val == 'cray-xk': substrate_val = 'gemini' elif platform_val == 'cray-xc': substrate_val = 'aries' elif platform_val == 'cray-cs': substrate_val = 'ibv' elif platform_val == 'pwr6': substrate_val = 'ibv' else: substrate_val = 'udp' elif comm_val == 'ofi': if platform_val == 'cray-xc': substrate_val = 'sockets' # substrate_val = 'gni' else: substrate_val = 'sockets' else: substrate_val = 'none' return substrate_val
def get(): substrate_val = os.environ.get('CHPL_COMM_SUBSTRATE') if not substrate_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') arch_val = chpl_arch.get('target', get_lcd=True) if comm_val == 'gasnet': if platform_val == 'cray-xt': substrate_val = 'mpi' elif platform_val == 'cray-xe': substrate_val = 'gemini' elif platform_val == 'cray-xk': substrate_val = 'gemini' elif platform_val == 'cray-xc': substrate_val = 'aries' elif platform_val == 'marenostrum': substrate_val = 'udp' elif platform_val == 'pwr5': substrate_val = 'lapi' elif platform_val == 'pwr6': substrate_val = 'ibv' else: substrate_val = 'udp' else: substrate_val = 'none' return substrate_val
def get_system_llvm_built_sdkroot(): # Homebrew installs of clang configure it with DEFAULT_SYSROOT # set to the SDKROOT being used when building. # # We could alternatively run # dyld_info -platform /usr/local/opt/llvm@12/lib/libLLVM.dylib # (on Monterey or later), or # otool -lL /usr/local/opt/llvm@12/lib/libLLVM.dylib | grep sdk # # and then give that version to xcrun (say it is 12.1): # xcrun --sdk macosx12.1 --show-sdk-path # and this should be the same as the DEFAULT_SYSROOT but # there might be a symlink pointing to the same place. llvm_val = get() host_platform = chpl_platform.get('host') if llvm_val == 'system' and host_platform == 'darwin': llvm_config = get_llvm_config() include_dir = run_command([llvm_config, '--includedir']).strip() if os.path.isdir(include_dir): clang_config = os.path.join(include_dir, 'clang', 'Config', 'config.h') if os.path.exists(clang_config): with open(clang_config) as f: for line in f.readlines(): # Looking for /some/path in #define DEFAULT_SYSROOT "/some/path" if 'DEFAULT_SYSROOT' in line: path = line.split('DEFAULT_SYSROOT')[1].strip() # remove quotes around it path = path.strip('"') return path return None
def get_gcc_prefix(): gcc_prefix = overrides.get('CHPL_LLVM_GCC_PREFIX', '') # allow CHPL_LLVM_GCC_PREFIX=none to disable inferring it if gcc_prefix == 'none': return '' if not gcc_prefix: # darwin and FreeBSD default to clang # so shouldn't need GCC prefix host_platform = chpl_platform.get('host') if host_platform == "darwin" or host_platform == "freebsd": return '' # When 'gcc' is a command other than '/usr/bin/gcc', # compute the 'gcc' prefix that LLVM should use. gcc_path = which('gcc') if gcc_path == '/usr/bin/gcc': # In this common case, nothing else needs to be done, # because we can assume that clang can find this gcc. pass elif gcc_path is None: # Nothing else we can do here pass else: # Try to figure out the GCC prefix by running gcc out, err = run_command(['gcc', '-v'], stdout=True, stderr=True) out = out + err # look for the --prefix= specified when GCC was configured words = out.split() for word in words: if word.startswith('--prefix='): gcc_prefix = word[len('--prefix='):] break # check that directory exists. if gcc_prefix and os.path.isdir(gcc_prefix): # if so, we are done. pass else: # We didn't find a --prefix= flag, so fall back on a heuristic. # try removing bin/gcc from the end mydir = os.path.dirname(os.path.dirname(gcc_path)) if mydir and os.path.isdir(mydir): # then check for mydir/include inc = os.path.join(mydir, "include") if os.path.isdir(inc): gcc_prefix = mydir else: inc = os.path.join(mydir, "snos", "include") if os.path.isdir(inc): gcc_prefix = mydir gcc_prefix = gcc_prefix.strip() if gcc_prefix == '/usr': # clang will be able to figure this out so don't # bother with the argument here. gcc_prefix = '' return gcc_prefix
def default_uniq_cfg_path(): arch_val = chpl_arch.get('target', map_to_compiler=True, get_lcd=using_chapel_module()).arch return '{0}-{1}-{2}-{3}'.format(chpl_platform.get('target'), chpl_compiler.get('target'), arch_val, chpl_lib_pic.get())
def get_link_args(unwind): platform_val = chpl_platform.get('target') osx = platform_val.startswith('darwin') # Mac OS X supports libunwind in the C library # it's not actually a special library. if osx: return [] libs = [] # Get the link arguments (e.g. -lunwind) if unwind == 'system': # Try using pkg-config to get the libraries to link # libunwind with. libs = third_party_utils.pkgconfig_get_link_args('libunwind', system=True, static=True) elif unwind == 'bundled': # the pkg-config file for libunwind is nice, but as of 1.1 # it doesn't include -lzma when it probably should. # So try to get the libraries out of libunwind.la. libs = third_party_utils.default_get_link_args( 'libunwind', libs=['libunwind.la', 'libunwind-x86_64.la']) # add -ldl so that we can call dladdr if "-ldl" not in libs: libs.append("-ldl") return libs
def get(flag='host'): arch_val = chpl_arch.get(flag) platform_val = chpl_platform.get(flag) cygwin = platform_val.startswith('cygwin') mac_arm = platform_val == 'darwin' and arch_val == 'arm64' chpl_host_mem = overrides.get('CHPL_HOST_MEM') chpl_target_mem = overrides.get('CHPL_TARGET_MEM') chpl_mem = overrides.get('CHPL_MEM') if flag == 'target': if cygwin or mac_arm: mem_val = 'cstdlib' elif chpl_target_mem: mem_val = chpl_target_mem if chpl_mem and chpl_target_mem != chpl_mem: warning("CHPL_MEM and CHPL_TARGET_MEM are both set, " "taking value from CHPL_TARGET_MEM") elif chpl_mem: mem_val = chpl_mem else: mem_val = 'jemalloc' elif flag == 'host': if cygwin: mem_val = 'cstdlib' elif chpl_host_mem: mem_val = chpl_host_mem else: mem_val = 'cstdlib' else: error("Invalid flag: '{0}'".format(flag), ValueError) return mem_val
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)
def get(): launcher_val = os.environ.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith('cray-x'): has_aprun = utils.find_executable('aprun') has_slurm = utils.find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm: launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) sys.stderr.write( 'Warning: Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.\n') elif platform_val == 'marenostrum': launcher_val = 'marenostrum' elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': if platform_val == 'pwr6': # our loadleveler launcher is not yet portable/stable/ # flexible enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' else: launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'lapi': # our loadleveler launcher is not yet portable/stable/flexible # enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def get_sysroot_resource_dir_args(): args = [] target_platform = chpl_platform.get('target') llvm_val = get() if (target_platform == "darwin" and llvm_val == "bundled"): # Add -isysroot and -resourcedir based upon what 'clang' uses cfile = os.path.join(get_chpl_home(), "runtime", "include", "sys_basic.h") if not os.path.isfile(cfile): error("error computing isysroot -- sys_basic.h is missing") (out, err) = run_command(['clang', '-###', cfile], stdout=True, stderr=True) out += err found = re.search('"-isysroot" "([^"]+)"', out) if found: args.append('-isysroot') args.append(found.group(1).strip()) found = re.search('"-resource-dir" "([^"]+)"', out) if found: args.append('-resource-dir') args.append(found.group(1).strip()) return args
def get_link_args(): unwind_val = get() platform_val = chpl_platform.get('target') osx = platform_val.startswith('darwin') args = ([ ], [ ]) # Mac OS X supports libunwind in the C library # it's not actually a special library. if osx: return args # Get the link arguments (e.g. -lunwind) if unwind_val == 'bundled': args = third_party_utils.pkgconfig_get_bundled_link_args('libunwind') elif unwind_val == 'system': # Try using pkg-config to get the libraries to link # libunwind with. args = third_party_utils.pkgconfig_get_system_link_args('libunwind', static=True) if unwind_val == 'system' or unwind_val == 'bundled': # add -ldl so that we can call dladdr if "-ldl" not in args[1]: args[1].append("-ldl") return args
def adjust_cpu_for_compiler(cpu, flag, get_lcd): compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = flag == 'target' and target_compiler_is_prgenv() if isprgenv: cray_cpu = os.environ.get('CRAY_CPU_TARGET', 'none') if cpu and (cpu != 'none' and cpu != 'unknown' and cpu != cray_cpu): stderr.write("Warning: Setting the processor type through " "environment variables is not supported for " "cray-prgenv-*. Please use the appropriate craype-* " "module for your processor type.\n") cpu = cray_cpu if cpu == 'none': stderr.write("Warning: No craype-* processor type module was " "detected, please load the appropriate one if you want " "any specialization to occur.\n") if get_lcd: cpu = get_module_lcd_cpu(platform_val, cpu) if cpu == 'none': stderr.write("Warning: Could not detect the lowest common " "denominator processor type for this platform. " "You may be unable to use the Chapel compiler\n") return cpu elif 'pgi' in compiler_val: return 'none' elif 'cray' in compiler_val: return 'none' elif 'ibm' in compiler_val: return 'none' return cpu
def pkgconfig_get_link_args(pkg, ucp='', system=True, static=(chpl_platform.get('target')!='cray-shasta')): havePcFile = pkg.endswith('.pc') pcArg = pkg if not havePcFile: if system: # check that pkg-config knows about the package in question run_command(['pkg-config', '--exists', pkg]) else: # look for a .pc file if ucp == '': ucp = default_uniq_cfg_path() pcfile = pkg + '.pc' # maybe needs to be an argument later? pcArg = os.path.join(get_cfg_install_path(pkg, ucp), 'lib', 'pkgconfig', pcfile) if not os.access(pcArg, os.R_OK): error("Could not find '{0}'".format(pcArg), ValueError) static_arg = [ ] if static: static_arg = ['--static'] libs_line = run_command(['pkg-config', '--libs'] + static_arg + [pcArg]); libs = libs_line.split() return libs
def get(flag='host'): if flag == 'host': mem_val = 'cstdlib' elif flag == 'target': mem_val = os.environ.get('CHPL_MEM') if not mem_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('host') arch_val = chpl_arch.get('target', get_lcd=True) tcmallocCompat = ["gnu", "clang", "intel"] # true if tcmalloc is compatible with the target compiler #if (not (platform_val == 'cray-xc' and arch_val == 'knc') and # (not platform_val.startswith("cygwin")) and # any(sub in chpl_compiler.get('target') for sub in tcmallocCompat)): # return 'tcmalloc' if comm_val == 'gasnet': segment_val = chpl_comm_segment.get() if segment_val == 'fast' or segment_val == 'large': mem_val = 'dlmalloc' else: mem_val = 'cstdlib' elif comm_val == 'ugni': mem_val = 'tcmalloc' else: mem_val = 'cstdlib' else: raise ValueError("Invalid flag: '{0}'".format(flag)) return mem_val
def get(): gmp_val = overrides.get('CHPL_GMP') if not gmp_val: target_compiler = chpl_compiler.get('target') if target_compiler == 'cray-prgenv-cray': gmp_val = 'system' else: target_platform = chpl_platform.get('target') # Detect if gmp has been built for this configuration. third_party = get_chpl_third_party() uniq_cfg_path = get_uniq_cfg_path() gmp_subdir = os.path.join(third_party, 'gmp', 'install', uniq_cfg_path) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'bundled' elif target_platform.startswith('cray-x'): gmp_val = 'system' elif target_platform == 'aarch64': gmp_val = 'system' else: gmp_val = 'none' elif gmp_val == 'gmp': sys.stderr.write("Warning: CHPL_GMP=gmp is deprecated. " "Use CHPL_GMP=bundled instead.\n") gmp_val = 'bundled' return gmp_val
def get(): comm_val = chpl_comm.get() if comm_val == 'ofi': libfabric_val = overrides.get('CHPL_LIBFABRIC') platform_val = chpl_platform.get('target') if not libfabric_val: cmd_exists, returncode = try_run_command( ['pkg-config', '--exists', 'libfabric'])[0:2] if cmd_exists and returncode == 0: libfabric_val = 'system' else: libfabric_val = 'bundled' if libfabric_val == 'none': error("CHPL_LIBFABRIC must not be 'none' when CHPL_COMM is ofi") if platform_val == 'hpe-cray-ex' and libfabric_val != 'system': sys.stderr.write('Warning: CHPL_LIBFABRIC!=system is discouraged ' 'on HPE Cray EX\n') else: libfabric_val = 'none' if libfabric_val == 'libfabric': sys.stderr.write("Warning: CHPL_LIBFABRIC=libfabric is deprecated. " "Use CHPL_LIBFABRIC=bundled instead.\n") libfabric_val = 'bundled' return libfabric_val
def adjust_cpu_for_compiler(cpu, flag, get_lcd): compiler_val = chpl_compiler.get(flag) platform_val = chpl_platform.get(flag) isprgenv = flag == 'target' and target_compiler_is_prgenv() if isprgenv: cray_cpu = os.environ.get('CRAY_CPU_TARGET', 'none') if cpu and (cpu != 'none' and cpu != 'unknown' and cpu != cray_cpu): stderr.write("Warning: Setting the processor type through " "environment variables is not supported for " "cray-prgenv-*. Please use the appropriate craype-* " "module for your processor type.\n") cpu = cray_cpu if cpu == 'none': stderr.write( "Warning: No craype-* processor type module was " "detected, please load the appropriate one if you want " "any specialization to occur.\n") if get_lcd: cpu = get_module_lcd_cpu(platform_val, cpu) if cpu == 'none': stderr.write("Warning: Could not detect the lowest common " "denominator processor type for this platform. " "You may be unable to use the Chapel compiler\n") return cpu elif 'pgi' in compiler_val: return 'none' elif 'cray' in compiler_val: return 'none' elif 'ibm' in compiler_val: return 'none' return cpu
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: raise ValueError("Invalid flag: '{0}'".format(flag)) if compiler_val: return compiler_val platform_val = chpl_platform.get(flag) # 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 platform_val.startswith("cray-x"): if flag == "host": compiler_val = "gnu" else: subcompiler = os.environ.get("PE_ENV", "none") if subcompiler == "none": stderr.write("Warning: Compiling on {0} without a PrgEnv loaded\n".format(platform_val)) compiler_val = "cray-prgenv-{0}".format(subcompiler.lower()) elif chpl_platform.is_cross_compiling(): if flag == "host": compiler_val = "gnu" else: compiler_val = platform_val + "-gnu" else: # 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 == "marenostrum": compiler_val = "ibm" elif platform_val == "darwin": if find_executable("clang"): compiler_val = "clang" else: compiler_val = "gnu" else: compiler_val = "gnu" return compiler_val
def default_uniq_cfg_path(): cpu_val = chpl_cpu.get('target', map_to_compiler=True, get_lcd=using_chapel_module()).cpu compiler_val = chpl_compiler.get_path_component('target') return '{0}-{1}-{2}-{3}-{4}'.format(chpl_platform.get('target'), chpl_arch.get('target'), cpu_val, compiler_val, chpl_lib_pic.get())
def _start_test_default_log(): """Calculate default Logs/ dir (just like start_test).""" test_dir = os.path.join(_chpl_home(), 'test') logs_dir = os.path.join(test_dir, 'Logs') log_filename = '{user}.{target_platform}.log'.format( user=getpass.getuser(), target_platform=chpl_platform.get('target')) log_file = os.path.join(logs_dir, log_filename) return log_file
def get(): launcher_val = overrides.get('CHPL_LAUNCHER') comm_val = chpl_comm.get() substrate_val = chpl_comm_substrate.get() if comm_val == 'gasnet' and substrate_val == 'udp': if not launcher_val: launcher_val = 'amudprun' elif launcher_val not in ('none', 'amudprun'): error('CHPL_LAUNCHER={} is not supported for CHPL_COMM=gasnet ' 'CHPL_COMM_SUBSTRATE=udp, CHPL_LAUNCHER=amudprun is ' 'required'.format(launcher_val)) if not launcher_val: platform_val = chpl_platform.get('target') if platform_val.startswith('cray-x') or platform_val.startswith( 'hpe-cray-'): has_aprun = find_executable('aprun') has_slurm = find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm: launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) warning('Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.') elif comm_val == 'gasnet': if substrate_val == 'smp': launcher_val = 'smp' elif substrate_val == 'mpi': launcher_val = slurm_prefix('gasnetrun_mpi', platform_val) elif substrate_val == 'ibv': launcher_val = slurm_prefix('gasnetrun_ibv', platform_val) elif substrate_val == 'ucx': launcher_val = slurm_prefix('gasnetrun_ucx', platform_val) elif substrate_val == 'ofi': launcher_val = slurm_prefix('gasnetrun_ofi', platform_val) else: if platform_val == 'cray-cs' and find_executable('srun'): launcher_val = 'slurm-srun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def get(): comm_val = os.environ.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') # automatically uses gasnet when on a cray-x* or cray-cs machine if platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: arch_val = chpl_arch.get('target', get_lcd=True) platform_val = chpl_platform.get() if arch_val == 'knc' or platform_val.startswith('cygwin'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def compatible_platform_for_llvm(): target_arch = chpl_arch.get('target') target_platform = chpl_platform.get('target') is32bit = target_platform == "linux32" or target_arch == "i368" mac_arm = target_platform == 'darwin' and target_arch == 'arm64' if is32bit or mac_arm: return False return True
def get(): launcher_val = overrides.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') if platform_val.startswith('cray-') or platform_val.startswith( 'hpe-cray-'): has_aprun = find_executable('aprun') has_slurm = find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm: launcher_val = 'slurm-srun' else: # FIXME: Need to detect aprun/srun differently. On a cray # system with an eslogin node, it is possible that aprun # will not be available on the eslogin node (only on the # login node). # # has_aprun and has_slurm should look other places # (maybe the modules?) to decide. # (thomasvandoren, 2014-08-12) sys.stderr.write( 'Warning: Cannot detect launcher on this system. Please ' 'set CHPL_LAUNCHER in the environment.\n') elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'smp': launcher_val = 'smp' elif substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'ucx': launcher_val = 'gasnetrun_ucx' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'ofi': launcher_val = 'gasnetrun_ofi' elif substrate_val == 'psm': launcher_val = 'gasnetrun_psm' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' if launcher_val is None: launcher_val = 'none' return launcher_val
def get(flag='host'): if flag == 'host': compiler_val = os.environ.get('CHPL_HOST_COMPILER', '') elif flag == 'target': compiler_val = os.environ.get('CHPL_TARGET_COMPILER', '') else: raise ValueError("Invalid flag: '{0}'".format(flag)) if compiler_val: return compiler_val platform_val = chpl_platform.get(flag) # 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 platform_val.startswith('cray-x'): if flag == 'host': compiler_val = 'gnu' else: subcompiler = os.environ.get('PE_ENV', 'none') if subcompiler == 'none': stderr.write("Warning: Compiling on {0} without a PrgEnv loaded\n".format(platform_val)) compiler_val = "cray-prgenv-{0}".format(subcompiler.lower()) else: # 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 == 'marenostrum': compiler_val = 'ibm' elif platform_val == 'darwin': if utils.find_executable('clang'): compiler_val = 'clang' else: compiler_val = 'gnu' else: compiler_val = 'gnu' return compiler_val
def get_prgenv_compiler(): platform_val = chpl_platform.get('target') if platform_val.startswith('cray-x') or platform_val == 'hpe-cray-ex': subcompiler = os.environ.get('PE_ENV', 'none') if subcompiler != 'none': return "cray-prgenv-{0}".format(subcompiler.lower()) else: warning("Compiling on {0} without a PrgEnv loaded".format(platform_val)) return 'none'
def get(flag='target'): chpl_jemalloc = overrides.get('CHPL_JEMALLOC') chpl_host_jemalloc = overrides.get('CHPL_HOST_JEMALLOC') chpl_target_jemalloc = overrides.get('CHPL_TARGET_JEMALLOC') mem_val = chpl_mem.get(flag) platform_val = chpl_platform.get(flag) darwin = platform_val.startswith('darwin') cygwin = platform_val.startswith('cygwin') linux = not darwin and not cygwin if flag == 'target': if chpl_target_jemalloc: jemalloc_val = chpl_target_jemalloc if chpl_jemalloc: warning("CHPL_JEMALLOC and CHPL_TARGET_JEMALLOC are both set, " "taking value from CHPL_TARGET_JEMALLOC") elif chpl_jemalloc: jemalloc_val = chpl_jemalloc elif mem_val == 'jemalloc': jemalloc_val = 'bundled' else: jemalloc_val = 'none' elif flag == 'host': if chpl_host_jemalloc: jemalloc_val = chpl_host_jemalloc elif linux and mem_val == 'jemalloc': jemalloc_val = 'bundled' elif darwin and mem_val == 'jemalloc': jemalloc_val = 'system' else: jemalloc_val = 'none' else: error("Invalid flag: '{0}'".format(flag), ValueError) if flag == 'host': if linux and mem_val == 'jemalloc' and jemalloc_val == 'system': error( "CHPL_HOST_JEMALLOC=system is not supported on Linux for host builds" ) if darwin and mem_val == 'jemalloc' and jemalloc_val == 'bundled': error( "CHPL_HOST_JEMALLOC=bundled is not supported on Mac for host builds" ) if mem_val == 'jemalloc' and jemalloc_val == 'none': error("CHPL_JEMALLOC must not be 'none' when CHPL_MEM is jemalloc") if mem_val != 'jemalloc' and jemalloc_val != 'none': error("CHPL_JEMALLOC must be 'none' when CHPL_MEM is not jemalloc") return jemalloc_val
def check(): platform_val = chpl_platform.get('target') if platform_val.startswith('cray-x'): comm_val = chpl_comm.get() substrate_val = chpl_comm_substrate.get() is_using_hugepages = 'HUGETLB' in os.environ.get('PE_PRODUCT_LIST', '') if comm_val == 'gasnet' and is_using_hugepages: if substrate_val == 'gemini' or substrate_val == 'aries': stderr.write("Warning: compiling with the craype-hugepages module while " "using the GASNet {0} conduit is not supported and " "will lead to link errors\n".format(substrate_val))
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: arch_val = chpl_arch.get('target', get_lcd=True) platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') if (arch_val == 'knc' or platform_val.startswith('cygwin') or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): comm_val = overrides.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') # Use ugni on cray-x* series if platform_val.startswith('cray-x'): comm_val = 'ugni' # Use gasnet on cray-cs elif platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def get(): tasks_val = os.environ.get('CHPL_TASKS') if not tasks_val: platform_val = chpl_platform.get() compiler_val = chpl_compiler.get('target') comm_val = chpl_comm.get() if (platform_val.startswith('cygwin') or platform_val.startswith('netbsd') or compiler_val == 'cray-prgenv-cray'): tasks_val = 'fifo' else: tasks_val = 'qthreads' return tasks_val
def get(): llvm_val = os.environ.get("CHPL_LLVM") if not llvm_val: host_platform = chpl_platform.get("host") host_compiler = chpl_compiler.get("host") chpl_home = utils.get_chpl_home() llvm_target_dir = "{0}-{1}".format(host_platform, host_compiler) llvm_subdir = os.path.join(chpl_home, "third-party", "llvm", "install", llvm_target_dir) llvm_header = os.path.join(llvm_subdir, "include", "llvm", "PassSupport.h") if os.path.exists(llvm_header): llvm_val = "llvm" else: llvm_val = "none" return llvm_val
def get(): make_val = overrides.get('CHPL_MAKE') if not make_val: platform_val = chpl_platform.get() if platform_val.startswith('cygwin') or platform_val == 'darwin': make_val = 'make' elif platform_val.startswith('linux'): if find_executable('gmake'): make_val = 'gmake' else: make_val = 'make' else: make_val = 'gmake' return make_val
def get(): regexp_val = os.environ.get('CHPL_REGEXP') if not regexp_val: target_platform = chpl_platform.get('target') target_compiler = chpl_compiler.get('target') chpl_home = utils.get_chpl_home() regexp_target_dir = '{0}-{1}'.format(target_platform, target_compiler) regexp_subdir = os.path.join(chpl_home, 'third-party', 're2', 'install', regexp_target_dir) regexp_header = os.path.join(regexp_subdir, 'include', 're2', 're2.h') if os.path.exists(regexp_header): regexp_val = 're2' else: regexp_val = 'none' return regexp_val
def get(flag='host'): if flag == 'host': mem_val = 'cstdlib' elif flag == 'target': mem_val = os.environ.get('CHPL_MEM') if not mem_val: platform_val = chpl_platform.get('target') cygwin = platform_val.startswith('cygwin') if cygwin: mem_val = 'cstdlib' else: mem_val = 'jemalloc' else: raise ValueError("Invalid flag: '{0}'".format(flag)) return mem_val
def get(): llvm_val = os.environ.get('CHPL_LLVM') if not llvm_val: host_platform = chpl_platform.get('host') host_compiler = chpl_compiler.get('host') chpl_home = utils.get_chpl_home() llvm_target_dir = '{0}-{1}'.format(host_platform, host_compiler) llvm_subdir = os.path.join(chpl_home, 'third-party', 'llvm', 'install', llvm_target_dir) llvm_header = os.path.join(llvm_subdir, 'include', 'llvm', 'PassSupport.h') if os.path.exists(llvm_header): llvm_val = 'llvm' else: llvm_val = 'none' return llvm_val
def get(): gmp_val = os.environ.get("CHPL_GMP") if not gmp_val: target_platform = chpl_platform.get("target") # Detect if gmp has been built for this configuration. chpl_home = utils.get_chpl_home() uniq_cfg_path = chpl_3p_gmp_configs.get_uniq_cfg_path() gmp_subdir = os.path.join(chpl_home, "third-party", "gmp", "install", uniq_cfg_path) if os.path.exists(os.path.join(gmp_subdir, "include", "gmp.h")): gmp_val = "gmp" elif target_platform.startswith("cray-x"): gmp_val = "system" else: gmp_val = "none" return gmp_val
def get(): launcher_val = os.environ.get('CHPL_LAUNCHER') if not launcher_val: comm_val = chpl_comm.get() platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') if platform_val.startswith('cray-x'): has_aprun = utils.find_executable('aprun') has_slurm = utils.find_executable('srun') if has_aprun and has_slurm: launcher_val = 'none' elif has_aprun: launcher_val = 'aprun' elif has_slurm: launcher_val = 'slurm-srun' elif platform_val == 'marenostrum': launcher_val = 'marenostrum' elif compiler_val == 'tile-cc': launcher_val = 'tile-monitor' elif comm_val == 'gasnet': substrate_val = chpl_comm_substrate.get() if substrate_val == 'udp': launcher_val = 'amudprun' elif substrate_val == 'mpi': launcher_val = 'gasnetrun_mpi' elif substrate_val == 'ibv': if platform_val == 'pwr6': # our loadleveler launcher is not yet portable/stable/ # flexible enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' else: launcher_val = 'gasnetrun_ibv' elif substrate_val == 'mxm': launcher_val = 'gasnetrun_ibv' elif substrate_val == 'lapi': # our loadleveler launcher is not yet portable/stable/flexible # enough to serve as a good default #launcher_val = 'loadleveler' launcher_val = 'none' elif comm_val == 'mpi': launcher_val = 'mpirun' else: launcher_val = 'none' return launcher_val
def get(): gmp_val = os.environ.get('CHPL_GMP') if not gmp_val: target_platform = chpl_platform.get('target') target_compiler = chpl_compiler.get('target') if target_platform.startswith('cray-x'): gmp_val = 'system' else: chpl_home = utils.get_chpl_home() gmp_target_dir = '{0}-{1}'.format(target_platform, target_compiler) gmp_subdir = os.path.join(chpl_home, 'third-party', 'gmp', 'install', gmp_target_dir) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'gmp' else: gmp_val = 'none' return gmp_val
def get(): comm_val = os.environ.get('CHPL_COMM') if not comm_val: platform_val = chpl_platform.get('target') compiler_val = chpl_compiler.get('target') # use ugni on cray-x* machines using the module and supported compiler ugni_comp = ('cray-prgenv-gnu', 'cray-prgenv-intel', 'cray-prgenv-cray') if (platform_val.startswith('cray-x') and utils.using_chapel_module() and compiler_val in ugni_comp): comm_val = 'ugni' # automatically uses gasnet when on a cray-x* or cray-cs machine elif platform_val.startswith('cray-'): comm_val = 'gasnet' else: comm_val = 'none' return comm_val
def get(): gmp_val = os.environ.get('CHPL_GMP') if not gmp_val: target_platform = chpl_platform.get('target') # Detect if gmp has been built for this configuration. chpl_home = utils.get_chpl_home() uniq_cfg_path = chpl_3p_gmp_configs.get_uniq_cfg_path() gmp_subdir = os.path.join(chpl_home, 'third-party', 'gmp', 'install', uniq_cfg_path) if os.path.exists(os.path.join(gmp_subdir, 'include', 'gmp.h')): gmp_val = 'gmp' elif target_platform.startswith('cray-x'): gmp_val = 'system' else: gmp_val = 'none' return gmp_val
def get(): platform_val = chpl_platform.get('target') linux = platform_val.startswith('linux64') osx = platform_val.startswith('darwin') val = overrides.get('CHPL_UNWIND') if linux: if val == 'libunwind': return 'libunwind' elif val == 'system': return 'system' if osx: if val == 'libunwind': error("Using CHPL_UNWIND=libunwind is not supported on Mac OS X." "\nUse CHPL_UNWIND=system instead.", ValueError) elif val == 'system': return 'system' return 'none'
def get(): platform_val = chpl_platform.get('target') linux = platform_val.startswith('linux64') osx = platform_val.startswith('darwin') val = os.environ.get('CHPL_UNWIND') if linux: if val == 'libunwind': return 'libunwind' elif val == 'system': return 'system' if osx: if val == 'libunwind': raise ValueError("Using CHPL_UNWIND=libunwind is not supported"+ " on Mac OS X. Use CHPL_UNWIND=system instead.") elif val == 'system': return 'system' return 'none'