Use a stub compiler wrapper on windows

This commit is contained in:
Massimiliano Culpo 2024-12-23 22:06:37 +01:00
parent 95115d4290
commit 4bd9ff2ef0
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C
3 changed files with 29 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -1506,7 +1506,7 @@ def __init__(self, tests: bool = False):
set
)
self.possible_compilers: List[KnownCompiler] = []
self.possible_compilers: List[spack.spec.Spec] = []
self.possible_oses: Set = set()
self.variant_values_from_specs: Set = set()
self.version_constraints: Set = set()
@ -3151,13 +3151,12 @@ def define_runtime_constraints(self):
# FIXME (compiler as nodes): think of using isinstance(compiler_cls, WrappedCompiler)
# Add a dependency on the compiler wrapper
if sys.platform != "win32":
recorder("*").depends_on(
"compiler-wrapper",
when=f"%{compiler.name}@{compiler.versions}",
type="build",
description=f"Add the compiler wrapper when using {compiler}",
)
recorder("*").depends_on(
"compiler-wrapper",
when=f"%{compiler.name}@{compiler.versions}",
type="build",
description=f"Add the compiler wrapper when using {compiler}",
)
if not using_libc_compatibility():
continue

View File

@ -3,6 +3,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pathlib
import shutil
import sys
from typing import List
import archspec.cpu
@ -39,13 +40,15 @@ class CompilerWrapper(Package):
license("Apache-2.0 OR MIT")
version(
"1.0",
sha256="92924570efbc0f388bbbeb87188e05537008bc25069529f7b519b4e48d7ddfb6",
expand=False,
)
conflicts("platform=windows")
if sys.platform != "win32":
version(
"1.0",
sha256="84a26f8f37329bcdfb41d23a8a4f4c46efbede983eb73737135c95a4c126b5b7",
expand=False,
)
else:
version("1.0")
has_code = False
def bin_dir(self) -> pathlib.Path:
# This adds an extra "spack" subdir, so that the script and symlinks don't get
@ -53,6 +56,14 @@ def bin_dir(self) -> pathlib.Path:
return pathlib.Path(str(self.prefix)) / "spack" / "bin"
def install(self, spec, prefix):
if sys.platform == "win32":
placeholder = self.bin_dir() / "placeholder-wrapper"
placeholder.parent.mkdir(parents=True)
placeholder.write_text(
"This file is a placeholder for the compiler wrapper on Windows."
)
return
cc_script = pathlib.Path(self.stage.source_path) / "cc.sh"
bin_dir = self.bin_dir()
@ -125,6 +136,9 @@ def install(self, spec, prefix):
(bin_dir / subdir / name).symlink_to(installed_script)
def setup_dependent_build_environment(self, env, dependent_spec):
if sys.platform == "win32":
return
_var_list = []
if dependent_spec.dependencies(virtuals=("c",)):
_var_list.append(("c", "cc", "CC", "SPACK_CC"))