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