Compare commits

...

2 Commits

Author SHA1 Message Date
Gregory Becker
1be0cf0fdf apple clang package 2023-05-30 16:10:59 -07:00
Gregory Becker
f60cb4090b wip: apple-clang only and now parallelism 2023-05-23 19:57:02 +02:00
2 changed files with 54 additions and 29 deletions

View File

@ -233,38 +233,25 @@ def find_compilers(path_hints=None):
path_hints = get_path("PATH") path_hints = get_path("PATH")
default_paths = fs.search_paths_for_executables(*path_hints) default_paths = fs.search_paths_for_executables(*path_hints)
# To detect the version of the compilers, we dispatch a certain number pkg_cls_to_check = [spack.repo.path.get_pkg_class(pkg) for pkg in ["apple-clang"]]
# of function calls to different workers. Here we construct the list detected_compilers = spack.detection.by_executable(pkg_cls_to_check, path_hints=default_paths)
# of arguments for each call.
arguments = []
for o in all_os_classes():
search_paths = getattr(o, "compiler_search_paths", default_paths)
arguments.extend(arguments_to_detect_version_fn(o, search_paths))
# Here we map the function arguments to the corresponding calls platform = spack.platforms.host()
tp = multiprocessing.pool.ThreadPool() operating_system = platform.operating_system("default_os")
try: target = platform.target("default_target")
detected_versions = tp.map(detect_version, arguments)
finally:
tp.close()
def valid_version(item): compilers = []
value, error = item for name, detected in detected_compilers.items():
if error is None: for entry in detected:
return True compiler_cls = spack.compilers.class_for_compiler_name(name)
try: spec = spack.spec.CompilerSpec(entry.spec.name, f"={entry.spec.versions}")
# This will fail on Python 2.6 if a non ascii paths = [
# character is in the error entry.spec.extra_attributes["compilers"].get(x, None)
tty.debug(error) for x in ("c", "cxx", "f77", "fc")
except UnicodeEncodeError: ]
pass compilers.append(compiler_cls(spec, str(operating_system), str(target), paths))
return False
def remove_errors(item): return compilers
value, _ = item
return value
return make_compiler_list(map(remove_errors, filter(valid_version, detected_versions)))
def find_new_compilers(path_hints=None, scope=None): def find_new_compilers(path_hints=None, scope=None):

View File

@ -0,0 +1,38 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack.package import *
import spack.compilers.apple_clang
class AppleClang(Package):
def install(self, spec, prefix):
raise NotImplementedError
executables = [r"^clang\+\+", r"^clang"]
@classmethod
def determine_version(cls, exe):
try:
output = spack.compiler.get_compiler_version_output(exe, "--version")
except Exception:
output = ""
version = spack.compilers.apple_clang.AppleClang.extract_version_from_output(output)
if version == "unknown":
return None
return version
@classmethod
def determine_variants(cls, exes, version_str):
compilers = {}
for exe in exes:
basename = os.path.basename(exe)
if basename == "clang":
compilers["c"] = exe
elif basename == "clang++":
compilers["cxx"] = exe
return "", {"compilers": compilers}