Restore bootstrapping from sources

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Massimiliano Culpo 2024-10-02 16:33:25 +02:00
parent 94fdd3dc5b
commit 543f830f57
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C
10 changed files with 34 additions and 20 deletions

View File

@ -16,6 +16,8 @@
import archspec.cpu import archspec.cpu
import spack.compilers.config import spack.compilers.config
import spack.compilers.libraries
import spack.config
import spack.platforms import spack.platforms
import spack.spec import spack.spec
import spack.traverse import spack.traverse
@ -45,17 +47,24 @@ def _valid_compiler_or_raise(self):
elif str(self.host_platform) == "windows": elif str(self.host_platform) == "windows":
compiler_name = "msvc" compiler_name = "msvc"
elif str(self.host_platform) == "freebsd": elif str(self.host_platform) == "freebsd":
compiler_name = "clang" compiler_name = "llvm"
else: else:
raise RuntimeError(f"Cannot bootstrap clingo from sources on {self.host_platform}") raise RuntimeError(f"Cannot bootstrap clingo from sources on {self.host_platform}")
candidates = spack.compilers.config.compilers_for_spec(
compiler_name, arch_spec=self.host_architecture candidates = [
) x
for x in spack.compilers.config.CompilerFactory.from_packages_yaml(spack.config.CONFIG)
if x.name == compiler_name
]
if not candidates: if not candidates:
raise RuntimeError( raise RuntimeError(
f"Cannot find any version of {compiler_name} to bootstrap clingo from sources" f"Cannot find any version of {compiler_name} to bootstrap clingo from sources"
) )
candidates.sort(key=lambda x: x.spec.version, reverse=True) candidates.sort(key=lambda x: x.version, reverse=True)
best = candidates[0]
# FIXME (compiler as nodes): we need to find a better place for setting namespaces
best.namespace = "builtin"
# TODO: check it has C and C++, and supports C++14
return candidates[0] return candidates[0]
def _externals_from_yaml( def _externals_from_yaml(
@ -74,9 +83,6 @@ def _externals_from_yaml(
if not s.satisfies(requirements[pkg_name]): if not s.satisfies(requirements[pkg_name]):
continue continue
if not s.intersects(f"%{self.host_compiler.spec}"):
continue
if not s.intersects(f"arch={self.host_architecture}"): if not s.intersects(f"arch={self.host_architecture}"):
continue continue
@ -109,11 +115,10 @@ def concretize(self) -> "spack.spec.Spec":
# Tweak it to conform to the host architecture # Tweak it to conform to the host architecture
for node in s.traverse(): for node in s.traverse():
node.architecture.os = str(self.host_os) node.architecture.os = str(self.host_os)
node.compiler = self.host_compiler.spec
node.architecture = self.host_architecture node.architecture = self.host_architecture
if node.name == "gcc-runtime": if node.name == "gcc-runtime":
node.versions = self.host_compiler.spec.versions node.versions = self.host_compiler.versions
for edge in spack.traverse.traverse_edges([s], cover="edges"): for edge in spack.traverse.traverse_edges([s], cover="edges"):
if edge.spec.name == "python": if edge.spec.name == "python":
@ -125,6 +130,9 @@ def concretize(self) -> "spack.spec.Spec":
if edge.spec.name == "cmake" and self.external_cmake: if edge.spec.name == "cmake" and self.external_cmake:
edge.spec = self.external_cmake edge.spec = self.external_cmake
if edge.spec.name == self.host_compiler.name:
edge.spec = self.host_compiler
if "libc" in edge.virtuals: if "libc" in edge.virtuals:
edge.spec = self.host_libc edge.spec = self.host_libc
@ -140,12 +148,12 @@ def python_external_spec(self) -> "spack.spec.Spec":
return self._external_spec(result) return self._external_spec(result)
def libc_external_spec(self) -> "spack.spec.Spec": def libc_external_spec(self) -> "spack.spec.Spec":
result = self.host_compiler.default_libc detector = spack.compilers.libraries.CompilerPropertyDetector(self.host_compiler)
result = detector.default_libc()
return self._external_spec(result) return self._external_spec(result)
def _external_spec(self, initial_spec) -> "spack.spec.Spec": def _external_spec(self, initial_spec) -> "spack.spec.Spec":
initial_spec.namespace = "builtin" initial_spec.namespace = "builtin"
initial_spec.compiler = self.host_compiler.spec
initial_spec.architecture = self.host_architecture initial_spec.architecture = self.host_architecture
for flag_type in spack.spec.FlagMap.valid_compiler_flags(): for flag_type in spack.spec.FlagMap.valid_compiler_flags():
initial_spec.compiler_flags[flag_type] = [] initial_spec.compiler_flags[flag_type] = []

View File

@ -280,7 +280,12 @@ def try_import(self, module: str, abstract_spec_str: str) -> bool:
# Install the spec that should make the module importable # Install the spec that should make the module importable
with spack.config.override(self.mirror_scope): with spack.config.override(self.mirror_scope):
PackageInstaller([concrete_spec.package], fail_fast=True).install() PackageInstaller(
[concrete_spec.package],
fail_fast=True,
package_use_cache=False,
dependencies_use_cache=False,
).install()
if _try_import_from_store(module, query_spec=concrete_spec, query_info=info): if _try_import_from_store(module, query_spec=concrete_spec, query_info=info):
self.last_search = info self.last_search = info

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2636,6 +2636,7 @@ def setup(
self.register_concrete_spec(reusable_spec, self.pkgs) self.register_concrete_spec(reusable_spec, self.pkgs)
self.concrete_specs() self.concrete_specs()
_ = spack.compilers.config.all_compilers(init_config=True)
self.possible_compilers = possible_compilers(configuration=spack.config.CONFIG) self.possible_compilers = possible_compilers(configuration=spack.config.CONFIG)
self.gen.h1("Generic statements on possible packages") self.gen.h1("Generic statements on possible packages")