Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
8b08db8
i don't know why my editor keeps saving this at utf-16
johnwparent Sep 25, 2025
37bab63
Spack Package side MSVC compiler wrapper support
johnwparent Jun 19, 2025
a0d4db9
Add latest wrapper patch
johnwparent Jun 23, 2025
dfbdbbf
regex update
johnwparent Jun 23, 2025
d611e61
Compiler Wrapper: update Windows patches
johnwparent Jul 17, 2025
b41c943
Compiler wrapper: add new win patches
johnwparent Jul 23, 2025
4561563
Update post package api consolidation
johnwparent Aug 28, 2025
3a77a15
Compiler wrapper add develop temporarily for testing
johnwparent Sep 3, 2025
f9d77a4
compiler-wrapper: add long name support patch
johnwparent Sep 9, 2025
912358e
Actually add patch
johnwparent Sep 9, 2025
5e4ad42
Set spack stage in env
johnwparent Sep 10, 2025
42d74e8
add long name patch
johnwparent Sep 10, 2025
6a62bf4
compielr-wrapper: add c_cxx patch
johnwparent Sep 19, 2025
66aff8f
def handling pass
johnwparent Sep 30, 2025
8a2b426
Better def forwarding patch
johnwparent Sep 30, 2025
a6b8450
Update wrapper pkg
johnwparent Oct 31, 2025
2d7dd69
update package
johnwparent Dec 9, 2025
533f861
wip
johnwparent Jan 20, 2026
09aeff2
churn
johnwparent Jan 27, 2026
ebe2b85
wip
johnwparent Jan 27, 2026
eca3131
wip
johnwparent Mar 9, 2026
3cd0321
wip
johnwparent Mar 9, 2026
09c2d0b
cleanup package
johnwparent May 4, 2026
ca2a08c
restore package
johnwparent May 5, 2026
5330a8f
style
johnwparent May 5, 2026
f9c9153
Proper msvc depend
johnwparent May 5, 2026
8b85fd1
Add myself as maintainer for windows side
johnwparent May 5, 2026
65b1139
style
johnwparent May 5, 2026
3367fba
small reorg
johnwparent May 5, 2026
9bfed84
give msvc a stub version to make audit check happy
johnwparent May 5, 2026
d70adf0
style
johnwparent May 5, 2026
d702a09
REVERT ME: point gl CI at real core wrapper changes
johnwparent May 5, 2026
29c11c9
Fix LD for msvc's without extra attr
johnwparent May 6, 2026
e7cfbc3
Try to disable a spec to see if anything changes
johnwparent May 8, 2026
83d178a
Try more msvc versions?
johnwparent May 8, 2026
85e2053
real basic ci
johnwparent May 8, 2026
b0f49d0
revert me: bump core commit sha
johnwparent May 11, 2026
21a5c6d
Revert me: another ci bump
johnwparent May 11, 2026
546c601
another bump
johnwparent May 11, 2026
4359a98
Try build only dep on msvc
johnwparent May 13, 2026
337d3ea
no msvc at all
johnwparent May 13, 2026
f517aba
conc the compiler
johnwparent May 13, 2026
fa79942
solve
johnwparent May 14, 2026
43d6f3c
Still capture config
johnwparent May 20, 2026
36564f1
big ole sleep
johnwparent May 20, 2026
ccce4b2
move sleep
johnwparent May 20, 2026
9871f85
rm whitespace
johnwparent May 20, 2026
99850dc
try git version
johnwparent May 21, 2026
ade9c03
r/nosleep
johnwparent May 21, 2026
241fed6
restore msvc dep
johnwparent May 21, 2026
df67a4b
new commit sha
johnwparent May 22, 2026
fcc6f5a
mimic old version for now to trick bootstrap
johnwparent May 22, 2026
fee6e75
try 1.0?
johnwparent May 22, 2026
56946c2
Bump core spack sha to capture bootstrap wrapper spec version update
johnwparent May 26, 2026
0461734
support paths with spaces
johnwparent May 26, 2026
3e15c69
quick rebase
johnwparent May 26, 2026
1af0804
quote prefix
johnwparent May 26, 2026
f5531e7
Try to fix install from nmake side
johnwparent May 26, 2026
b8f6c32
bump core again
johnwparent May 26, 2026
6f592a0
boneheaded upstream bug fix commit bump
johnwparent May 26, 2026
d14f3d3
Version bump for better upstream path with space support
johnwparent May 27, 2026
720657e
real vis stack
johnwparent May 27, 2026
ce44368
No solve, artifact too large
johnwparent May 27, 2026
8cad3d6
bump spack sha to grab logger changes
johnwparent May 27, 2026
bc4eda7
no depends on c for win gpg
johnwparent May 27, 2026
85962e7
bump wrapper and sha
johnwparent May 28, 2026
50a5fbd
another wrapper bump
johnwparent May 29, 2026
5bf1c8e
New core change requirement
johnwparent May 31, 2026
6093eee
Make msvc a run dep
johnwparent May 31, 2026
6347fbb
bump spack sha
johnwparent Jun 1, 2026
2ce0753
bump compiler wrapper
johnwparent Jun 1, 2026
3758588
bump wrapper
johnwparent Jun 2, 2026
2258e3c
Add run context for msvc and use properly in spack core
johnwparent Jun 2, 2026
a1dc8f5
bump wrapper to restore dumpbin usage
johnwparent Jun 2, 2026
0fe3db9
style
johnwparent Jun 2, 2026
7645f94
quote ifort invocation
johnwparent Jun 2, 2026
c1b2b40
proper quotes
johnwparent Jun 3, 2026
40a314d
debug the wrapper
johnwparent Jun 3, 2026
4b3c5c3
Support lctg binaries
johnwparent Jun 3, 2026
a34824b
wrapper bump - coff verify write access permissions
johnwparent Jun 3, 2026
072a3f4
bump core for more wrapper debugging
johnwparent Jun 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SPACK_CHECKOUT_VERSION=84cb7ff86b42e7fa45476750b6729144c58f70dc
SPACK_CHECKOUT_VERSION=df98ad4289a7234bd9a443151d70c3f75668fdcf
SPACK_CHECKOUT_REPO=spack/spack
1 change: 1 addition & 0 deletions .ci/gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ default:
- mkdir "${CI_PROJECT_DIR}/jobs_scratch_dir/${SPACK_CI_STACK_NAME}"
- spack
config blame > "${CI_PROJECT_DIR}/jobs_scratch_dir/${SPACK_CI_STACK_NAME}/spack.yaml.blame"
# - spack solve --show all > "${CI_PROJECT_DIR}/jobs_scratch_dir/${SPACK_CI_STACK_NAME}/solve.out"
- spack -v --color=always
ci generate --check-index-only -j ${SPACK_CONCRETIZE_JOBS}
--forward-variable SPACK_CHECKOUT_VERSION
Expand Down
288 changes: 160 additions & 128 deletions repos/spack_repo/builtin/packages/compiler_wrapper/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import sys

from spack_repo.builtin.build_systems.generic import Package
from spack_repo.builtin.build_systems.nmake import NMakeBuilder, NMakePackage

from spack.package import *

IS_WINDOWS = sys.platform == "win32"

class CompilerWrapper(Package):

class CompilerWrapper(Package, NMakePackage):
"""Spack compiler wrapper script.

Compiler commands go through this compiler wrapper in Spack builds.
Expand All @@ -26,125 +29,75 @@ class CompilerWrapper(Package):
3. It provides a mechanism to inject flags from specs
"""

homepage = "https://github.com/spack/spack"
url = "https://github.com/spack/compiler-wrapper/releases/download/v1.0/compiler-wrapper-1.0.tar.gz"
homepage_nix = "https://github.com/spack/spack"
url_nix = "https://github.com/spack/compiler-wrapper/releases/download/v1.0/compiler-wrapper-1.0.tar.gz"

homepage_win = "https://github.com/spack/msvc-wrapper"
url_win = "https://github.com/spack/msvc-wrapper/archive/refs/tags/v0.1.0.tar.gz"
git_win = "https://github.com/spack/msvc-wrapper.git"

homepage = homepage_win if IS_WINDOWS else homepage_nix
url = url_win if IS_WINDOWS else url_nix
if IS_WINDOWS:
git = git_win

# FIXME (compiler as nodes): use a different tag, since this is only to exclude
# this node from auto-generated rules
tags = ["runtime"]

maintainers("haampie")
maintainers("haampie", "johnwparent")

license("Apache-2.0 OR MIT")

if sys.platform != "win32":
default_builder = "nmake" if IS_WINDOWS else "generic"
build_system("generic", conditional("nmake", when="platform=windows"), default=default_builder)

if not IS_WINDOWS:
version("1.1.0", sha256="a07b35081d14b0729090bc1e5790a5dda2d5b997e064c62da39a1224ee249b2a")
version("1.0", sha256="ac876f7600fa6cb0c74ae172ef1c61661aacff03a6befbc7d87e092e2f2233f9")
else:
version("1.0")
has_code = False
# version("develop", branch="main")
version("1.0", commit="51358dd5c37a77b9a5816b6f9c8e3e4f6e07fb78")

depends_on("msvc", when="platform=windows", type=("build", "run"))

def bin_dir(self) -> pathlib.Path:
# This adds an extra "spack" subdir, so that the script and symlinks don't get
# their way to the default view
return pathlib.Path(str(self.prefix)) / "libexec" / "spack"

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
def setup_dependent_package(self, module, dependent_spec):
def _spack_compiler_attribute(*, language: str) -> str:
compiler_pkg = dependent_spec[language].package
return str(self.bin_dir() / compiler_pkg.compiler_wrapper_link_paths[language])

cc_script = pathlib.Path(self.stage.source_path) / "cc.sh"
bin_dir = self.bin_dir()
if dependent_spec.has_virtual_dependency("c"):
setattr(module, "spack_cc", _spack_compiler_attribute(language="c"))

# Copy the script
bin_dir.mkdir(parents=True)
installed_script = bin_dir / "cc"
shutil.copy(cc_script, str(installed_script))
set_executable(installed_script)
if dependent_spec.has_virtual_dependency("cxx"):
setattr(module, "spack_cxx", _spack_compiler_attribute(language="cxx"))

# Create links to use the script under different names
for name in (
"ld.lld",
"ld.gold",
"ld",
"ftn",
"fc",
"f95",
"f90",
"f77",
"cpp",
"c99",
"c89",
"c++",
):
(bin_dir / name).symlink_to(installed_script)
if dependent_spec.has_virtual_dependency("fortran"):
setattr(module, "spack_fc", _spack_compiler_attribute(language="fortran"))
setattr(module, "spack_f77", _spack_compiler_attribute(language="fortran"))

for subdir, name in (
("aocc", "clang"),
("aocc", "clang++"),
("aocc", "flang"),
("arm", "armclang"),
("arm", "armclang++"),
("arm", "armflang"),
("case-insensitive", "CC"),
("cce", "cc"),
("cce", "craycc"),
("cce", "crayftn"),
("cce", "ftn"),
("clang", "clang"),
("clang", "clang++"),
("clang", "flang"),
("fj", "fcc"),
("fj", "frt"),
("gcc", "gcc"),
("gcc", "g++"),
("gcc", "gfortran"),
("intel", "icc"),
("intel", "icpc"),
("intel", "ifort"),
("nag", "nagfor"),
("nvhpc", "nvc"),
("nvhpc", "nvc++"),
("nvhpc", "nvfortran"),
("oneapi", "icx"),
("oneapi", "icpx"),
("oneapi", "ifx"),
("rocmcc", "amdclang"),
("rocmcc", "amdclang++"),
("rocmcc", "amdflang"),
("xl", "xlc"),
("xl", "xlc++"),
("xl", "xlf"),
("xl", "xlf90"),
("xl_r", "xlc_r"),
("xl_r", "xlc++_r"),
("xl_r", "xlf_r"),
("xl_r", "xlf90_r"),
):
(bin_dir / subdir).mkdir(exist_ok=True)
(bin_dir / subdir / name).symlink_to(installed_script)
@property
def disable_new_dtags(self) -> str:
if self.spec.satisfies("platform=darwin"):
return ""
return "--disable-new-dtags"

# Extra symlinks for Cray
cray_dir = bin_dir / "cce" / "case-insensitive"
cray_dir.mkdir(exist_ok=True)
(cray_dir / "crayCC").symlink_to(installed_script)
(cray_dir / "CC").symlink_to(installed_script)
@property
def enable_new_dtags(self) -> str:
if self.spec.satisfies("platform=darwin"):
return ""
return "--enable-new-dtags"

# Extra symlink for Fujitsu
fj_dir = bin_dir / "fj" / "case-insensitive"
fj_dir.mkdir(exist_ok=True)
(fj_dir / "FCC").symlink_to(installed_script)

class EnvironmentSetup:
def setup_dependent_build_environment(
self, env: EnvironmentModifications, dependent_spec: Spec
) -> None:
if sys.platform == "win32":
return

_var_list = []
if dependent_spec.has_virtual_dependency("c"):
Expand All @@ -156,12 +109,11 @@ def setup_dependent_build_environment(
if dependent_spec.has_virtual_dependency("fortran"):
_var_list.append(("fortran", "fortran", "F77", "SPACK_F77"))
_var_list.append(("fortran", "fortran", "FC", "SPACK_FC"))

# The package is not used as a compiler, so skip this setup
if not _var_list:
return

bin_dir = self.bin_dir()
bin_dir = self.pkg.bin_dir()
implicit_rpaths, env_paths = [], []
extra_rpaths = []
for language, attr_name, wrapper_var_name, spack_var_name in _var_list:
Expand All @@ -172,6 +124,9 @@ def setup_dependent_build_environment(
compiler = getattr(compiler_pkg, attr_name)
env.set(spack_var_name, compiler)

if hasattr(compiler_pkg, "ld"):
env.set("SPACK_LD", compiler_pkg.ld)

# -frandom-seed= is needed for deterministic builds with GCC
if compiler_pkg.name == "gcc" and self.spec.satisfies("@1.1:"):
env.set(f"SPACK_{wrapper_var_name}_HAS_FRANDOM_SEED", "1")
Expand Down Expand Up @@ -229,45 +184,122 @@ def setup_dependent_build_environment(
extra_rpaths = dedupe(extra_rpaths)
env.set("SPACK_COMPILER_EXTRA_RPATHS", ":".join(extra_rpaths))

env.set("SPACK_ENABLE_NEW_DTAGS", self.enable_new_dtags)
env.set("SPACK_DISABLE_NEW_DTAGS", self.disable_new_dtags)
env.set("SPACK_ENABLE_NEW_DTAGS", self.pkg.enable_new_dtags)
env.set("SPACK_DISABLE_NEW_DTAGS", self.pkg.disable_new_dtags)

for item in env_paths:
env.prepend_path("SPACK_COMPILER_WRAPPER_PATH", item)

def setup_dependent_package(self, module, dependent_spec):
def _spack_compiler_attribute(*, language: str) -> str:
compiler_pkg = dependent_spec[language].package
if sys.platform != "win32":
# On non-Windows we return the appropriate path to the compiler wrapper
return str(self.bin_dir() / compiler_pkg.compiler_wrapper_link_paths[language])

# On Windows we return the real compiler
if language == "c":
return compiler_pkg.cc
elif language == "cxx":
return compiler_pkg.cxx
elif language == "fortran":
return compiler_pkg.fortran
env.set("SPACK_CONTEXT_ROOT", dependent_spec.package.stage.source_path)
if IS_WINDOWS:
env.set("SPACK_DEBUG_WRAPPER", "ON")

if dependent_spec.has_virtual_dependency("c"):
setattr(module, "spack_cc", _spack_compiler_attribute(language="c"))

if dependent_spec.has_virtual_dependency("cxx"):
setattr(module, "spack_cxx", _spack_compiler_attribute(language="cxx"))
class GenericBuilder(GenericBuilder, EnvironmentSetup):
def install(self, pkg, spec, prefix):
cc_script = pathlib.Path(self.stage.source_path) / "cc.sh"
bin_dir = pkg.bin_dir()

if dependent_spec.has_virtual_dependency("fortran"):
setattr(module, "spack_fc", _spack_compiler_attribute(language="fortran"))
setattr(module, "spack_f77", _spack_compiler_attribute(language="fortran"))
# Copy the script
bin_dir.mkdir(parents=True)
installed_script = bin_dir / "cc"
shutil.copy(cc_script, str(installed_script))
set_executable(installed_script)

@property
def disable_new_dtags(self) -> str:
if self.spec.satisfies("platform=darwin"):
return ""
return "--disable-new-dtags"
# Create links to use the script under different names
for name in (
"ld.lld",
"ld.gold",
"ld",
"ftn",
"fc",
"f95",
"f90",
"f77",
"cpp",
"c99",
"c89",
"c++",
):
(bin_dir / name).symlink_to(installed_script)

@property
def enable_new_dtags(self) -> str:
if self.spec.satisfies("platform=darwin"):
return ""
return "--enable-new-dtags"
for subdir, name in (
("aocc", "clang"),
("aocc", "clang++"),
("aocc", "flang"),
("arm", "armclang"),
("arm", "armclang++"),
("arm", "armflang"),
("case-insensitive", "CC"),
("cce", "cc"),
("cce", "craycc"),
("cce", "crayftn"),
("cce", "ftn"),
("clang", "clang"),
("clang", "clang++"),
("clang", "flang"),
("fj", "fcc"),
("fj", "frt"),
("gcc", "gcc"),
("gcc", "g++"),
("gcc", "gfortran"),
("intel", "icc"),
("intel", "icpc"),
("intel", "ifort"),
("nag", "nagfor"),
("nvhpc", "nvc"),
("nvhpc", "nvc++"),
("nvhpc", "nvfortran"),
("oneapi", "icx"),
("oneapi", "icpx"),
("oneapi", "ifx"),
("rocmcc", "amdclang"),
("rocmcc", "amdclang++"),
("rocmcc", "amdflang"),
("xl", "xlc"),
("xl", "xlc++"),
("xl", "xlf"),
("xl", "xlf90"),
("xl_r", "xlc_r"),
("xl_r", "xlc++_r"),
("xl_r", "xlf_r"),
("xl_r", "xlf90_r"),
):
(bin_dir / subdir).mkdir(exist_ok=True)
(bin_dir / subdir / name).symlink_to(installed_script)

# Extra symlinks for Cray
cray_dir = bin_dir / "cce" / "case-insensitive"
cray_dir.mkdir(exist_ok=True)
(cray_dir / "crayCC").symlink_to(installed_script)
(cray_dir / "CC").symlink_to(installed_script)

# Extra symlink for Fujitsu
fj_dir = bin_dir / "fj" / "case-insensitive"
fj_dir.mkdir(exist_ok=True)
(fj_dir / "FCC").symlink_to(installed_script)


class NMakeBuilder(NMakeBuilder, EnvironmentSetup):
install_targets = ["install"]
build_targets = ["cl.exe"]

def install(self, pkg, spec, prefix):
bin_dir = pkg.bin_dir()
opts = self.std_nmake_args
opts.append(self.define("PREFIX", str(bin_dir)))
with working_dir(self.build_directory):
nmake(*opts, *self.install_targets, ignore_quotes=self.ignore_quotes)

# Create links to use the script under different names
for name in ("link", "ftn", "fc", "f95", "f90", "f77", "cpp", "c99", "c89", "c++"):
(bin_dir / name).symlink_to(bin_dir / "cl.exe")

for subdir, name in (
("case-insensitive", "CC.exe"),
("intel", "ifort.exe"),
("oneapi", "ifx.exe"),
("msvc", "cl.exe"),
):
(bin_dir / subdir).mkdir(exist_ok=True)
(bin_dir / subdir / name).symlink_to(bin_dir / "cl.exe")
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ index 24bd29d..319153d 100644
+ <Fort_Flags>/D _WIN64=1 /D _AMD64_=1 /D AMD64=1</Fort_Flags>
</PropertyGroup>
- <Exec Command="$(GFORTRAN_BIN)\gfortran.exe -I$(MPI_INC_ROOT) -c %(ForCompile.Identity) $(Fort_Flags) -o $(O)\%(ForCompile.FileName).obj" />
+ <Exec Command="$(IFORT_BIN)\ifx.exe /I$(MPI_INC_ROOT) /c %(ForCompile.Identity) $(Fort_Flags) /names:lowercase /assume:nounderscore /o $(O)\%(ForCompile.FileName).obj" />
+ <Exec Command="$(IFORT_BIN)\ifx.exe /I&quot;$(MPI_INC_ROOT)&quot; /c %(ForCompile.Identity) $(Fort_Flags) /names:lowercase /assume:nounderscore /o $(O)\%(ForCompile.FileName).obj" />
<ItemGroup>
<Lib Condition="'$(ConfigurationType)'=='StaticLibrary'" Include="@(ForCompile->'$(O)\%(Filename).obj')" />
</ItemGroup>
Loading
Loading