Remove code from Compiler that is not used anymore (#45982)

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Massimiliano Culpo 2024-09-20 10:00:34 +02:00 committed by GitHub
parent f9f6f094c3
commit b28583bc58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 26 additions and 314 deletions

View File

@ -202,18 +202,6 @@ class Compiler:
support for specific compilers, their possible names, arguments, support for specific compilers, their possible names, arguments,
and how to identify the particular type of compiler.""" and how to identify the particular type of compiler."""
# Subclasses use possible names of C compiler
cc_names: List[str] = []
# Subclasses use possible names of C++ compiler
cxx_names: List[str] = []
# Subclasses use possible names of Fortran 77 compiler
f77_names: List[str] = []
# Subclasses use possible names of Fortran 90 compiler
fc_names: List[str] = []
# Optional prefix regexes for searching for this type of compiler. # Optional prefix regexes for searching for this type of compiler.
# Prefixes are sometimes used for toolchains # Prefixes are sometimes used for toolchains
prefixes: List[str] = [] prefixes: List[str] = []
@ -619,18 +607,6 @@ def extract_version_from_output(cls, output):
def cc_version(cls, cc): def cc_version(cls, cc):
return cls.default_version(cc) return cls.default_version(cc)
@classmethod
def cxx_version(cls, cxx):
return cls.default_version(cxx)
@classmethod
def f77_version(cls, f77):
return cls.default_version(f77)
@classmethod
def fc_version(cls, fc):
return cls.default_version(fc)
@classmethod @classmethod
def search_regexps(cls, language): def search_regexps(cls, language):
# Compile all the regular expressions used for files beforehand. # Compile all the regular expressions used for files beforehand.

View File

@ -8,6 +8,7 @@
""" """
import importlib import importlib
import os import os
import re
import sys import sys
import warnings import warnings
from typing import Dict, List, Optional from typing import Dict, List, Optional
@ -631,37 +632,34 @@ def is_mixed_toolchain(compiler):
Args: Args:
compiler (spack.compiler.Compiler): a valid compiler object compiler (spack.compiler.Compiler): a valid compiler object
""" """
cc = os.path.basename(compiler.cc or "") import spack.detection.path
cxx = os.path.basename(compiler.cxx or "")
f77 = os.path.basename(compiler.f77 or "") executables = [
fc = os.path.basename(compiler.fc or "") os.path.basename(compiler.cc or ""),
os.path.basename(compiler.cxx or ""),
os.path.basename(compiler.f77 or ""),
os.path.basename(compiler.fc or ""),
]
toolchains = set() toolchains = set()
for compiler_cls in all_compiler_types(): finder = spack.detection.path.ExecutablesFinder()
# Inspect all the compiler toolchain we know. If a compiler is the
# only compiler supported there it belongs to that toolchain.
def name_matches(name, name_list):
# This is such that 'gcc' matches variations
# like 'ggc-9' etc that are found in distros
name, _, _ = name.partition("-")
return len(name_list) == 1 and name and name in name_list
if any( for pkg_name in spack.repo.PATH.packages_with_tags(COMPILER_TAG):
[ pkg_cls = spack.repo.PATH.get_pkg_class(pkg_name)
name_matches(cc, compiler_cls.cc_names), patterns = finder.search_patterns(pkg=pkg_cls)
name_matches(cxx, compiler_cls.cxx_names), if not patterns:
name_matches(f77, compiler_cls.f77_names), continue
name_matches(fc, compiler_cls.fc_names), joined_pattern = re.compile(r"|".join(patterns))
]
): if any(joined_pattern.search(exe) for exe in executables):
tty.debug("[TOOLCHAIN] MATCH {0}".format(compiler_cls.__name__)) tty.debug(f"[TOOLCHAIN] MATCH {pkg_name}")
toolchains.add(compiler_cls.__name__) toolchains.add(pkg_name)
if len(toolchains) > 1: if len(toolchains) > 1:
if ( if (
toolchains == set(["Clang", "AppleClang", "Aocc"]) toolchains == {"llvm", "apple-clang", "aocc"}
# Msvc toolchain uses Intel ifx # Msvc toolchain uses Intel ifx
or toolchains == set(["Msvc", "Dpcpp", "Oneapi"]) or toolchains == {"msvc", "intel-oneapi-compilers"}
): ):
return False return False
tty.debug("[TOOLCHAINS] {0}".format(toolchains)) tty.debug("[TOOLCHAINS] {0}".format(toolchains))

View File

@ -13,18 +13,6 @@
class Aocc(Compiler): class Aocc(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["clang"]
# Subclasses use possible names of C++ compiler
cxx_names = ["clang++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["flang"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["flang"]
version_argument = "--version" version_argument = "--version"
@property @property

View File

@ -9,18 +9,6 @@
class Arm(spack.compiler.Compiler): class Arm(spack.compiler.Compiler):
# Subclasses use possible names of C compiler
cc_names = ["armclang"]
# Subclasses use possible names of C++ compiler
cxx_names = ["armclang++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["armflang"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["armflang"]
# Named wrapper links within lib/spack/env # Named wrapper links within lib/spack/env
link_paths = { link_paths = {
"cc": os.path.join("arm", "armclang"), "cc": os.path.join("arm", "armclang"),
@ -90,11 +78,3 @@ def fc_pic_flag(self):
return "-fPIC" return "-fPIC"
required_libs = ["libclang", "libflang"] required_libs = ["libclang", "libflang"]
@classmethod
def fc_version(cls, fc):
return cls.default_version(fc)
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)

View File

@ -19,18 +19,6 @@ def __init__(self, *args, **kwargs):
if not self.is_clang_based: if not self.is_clang_based:
self.version_argument = "-V" self.version_argument = "-V"
# Subclasses use possible names of C compiler
cc_names = ["craycc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["crayCC"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["crayftn"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["crayftn"]
# MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes. # MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes.
suffixes = [r"-mp-\d\.\d"] suffixes = [r"-mp-\d\.\d"]

View File

@ -31,18 +31,6 @@
class Clang(Compiler): class Clang(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["clang"]
# Subclasses use possible names of C++ compiler
cxx_names = ["clang++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["flang-new", "flang"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["flang-new", "flang"]
version_argument = "--version" version_argument = "--version"
@property @property

View File

@ -9,18 +9,6 @@
class Fj(spack.compiler.Compiler): class Fj(spack.compiler.Compiler):
# Subclasses use possible names of C compiler
cc_names = ["fcc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["FCC"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["frt"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["frt"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("fj", "fcc"), "cc": os.path.join("fj", "fcc"),

View File

@ -4,7 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os import os
import re
from llnl.util.filesystem import ancestor from llnl.util.filesystem import ancestor
@ -15,18 +14,6 @@
class Gcc(spack.compiler.Compiler): class Gcc(spack.compiler.Compiler):
# Subclasses use possible names of C compiler
cc_names = ["gcc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["g++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["gfortran"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["gfortran"]
# MacPorts builds gcc versions with prefixes and -mp-X or -mp-X.Y suffixes. # MacPorts builds gcc versions with prefixes and -mp-X or -mp-X.Y suffixes.
# Homebrew and Linuxbrew may build gcc with -X, -X.Y suffixes. # Homebrew and Linuxbrew may build gcc with -X, -X.Y suffixes.
# Old compatibility versions may contain XY suffixes. # Old compatibility versions may contain XY suffixes.
@ -181,40 +168,6 @@ def default_version(cls, cc):
version = cls.extract_version_from_output(output) version = cls.extract_version_from_output(output)
return version return version
@classmethod
def fc_version(cls, fc):
"""Older versions of gfortran use the ``-dumpversion`` option.
Output looks like this::
GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
or::
4.8.5
In GCC 7, this option was changed to only return the major
version of the compiler::
7
A new ``-dumpfullversion`` option was added that gives us
what we want::
7.2.0
"""
output = spack.compiler.get_compiler_version_output(fc, "-dumpversion")
match = re.search(r"(?:GNU Fortran \(GCC\) )?([\d.]+)", output)
version = match.group(match.lastindex) if match else "unknown"
if Version(version) >= Version("7"):
output = spack.compiler.get_compiler_version_output(fc, "-dumpfullversion")
version = cls.extract_version_from_output(output)
return version
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)
@property @property
def stdcxx_libs(self): def stdcxx_libs(self):
return ("-lstdc++",) return ("-lstdc++",)

View File

@ -11,18 +11,6 @@
class Intel(Compiler): class Intel(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["icc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["icpc"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["ifort"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["ifort"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("intel", "icc"), "cc": os.path.join("intel", "icc"),

View File

@ -8,7 +8,7 @@
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
from typing import Dict, List from typing import Dict
import archspec.cpu import archspec.cpu
@ -117,18 +117,6 @@ def get_valid_fortran_pth():
class Msvc(Compiler): class Msvc(Compiler):
# Subclasses use possible names of C compiler
cc_names: List[str] = ["cl"]
# Subclasses use possible names of C++ compiler
cxx_names: List[str] = ["cl"]
# Subclasses use possible names of Fortran 77 compiler
f77_names: List[str] = ["ifx"]
# Subclasses use possible names of Fortran 90 compiler
fc_names: List[str] = ["ifx"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
# Due to the challenges of supporting compiler wrappers # Due to the challenges of supporting compiler wrappers
# in Windows, we leave these blank, and dynamically compute # in Windows, we leave these blank, and dynamically compute
@ -393,7 +381,3 @@ def fc_version(cls, fc):
) )
clp = spack.util.executable.which_string("cl", path=sps) clp = spack.util.executable.which_string("cl", path=sps)
return cls.default_version(clp) if clp else fc_ver return cls.default_version(clp) if clp else fc_ver
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)

View File

@ -5,7 +5,6 @@
import os import os
import re import re
from typing import List
import llnl.util.lang import llnl.util.lang
@ -13,18 +12,6 @@
class Nag(spack.compiler.Compiler): class Nag(spack.compiler.Compiler):
# Subclasses use possible names of C compiler
cc_names: List[str] = []
# Subclasses use possible names of C++ compiler
cxx_names: List[str] = []
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["nagfor"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["nagfor"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
# Use default wrappers for C and C++, in case provided in compilers.yaml # Use default wrappers for C and C++, in case provided in compilers.yaml
link_paths = { link_paths = {

View File

@ -9,18 +9,6 @@
class Nvhpc(Compiler): class Nvhpc(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["nvc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["nvc++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["nvfortran"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["nvfortran"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("nvhpc", "nvc"), "cc": os.path.join("nvhpc", "nvc"),

View File

@ -13,18 +13,6 @@
class Oneapi(Compiler): class Oneapi(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["icx"]
# Subclasses use possible names of C++ compiler
cxx_names = ["icpx"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["ifx"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["ifx"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("oneapi", "icx"), "cc": os.path.join("oneapi", "icx"),

View File

@ -10,18 +10,6 @@
class Pgi(Compiler): class Pgi(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["pgcc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["pgc++", "pgCC"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["pgfortran", "pgf77"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["pgfortran", "pgf95", "pgf90"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("pgi", "pgcc"), "cc": os.path.join("pgi", "pgcc"),

View File

@ -11,18 +11,6 @@
class Rocmcc(spack.compilers.clang.Clang): class Rocmcc(spack.compilers.clang.Clang):
# Subclasses use possible names of C compiler
cc_names = ["amdclang"]
# Subclasses use possible names of C++ compiler
cxx_names = ["amdclang++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["amdflang"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["amdflang"]
@property @property
def link_paths(self): def link_paths(self):
link_paths = { link_paths = {
@ -61,14 +49,6 @@ def extract_version_from_output(cls, output):
if match: if match:
return ".".join(match.groups()) return ".".join(match.groups())
@classmethod
def fc_version(cls, fortran_compiler):
return cls.default_version(fortran_compiler)
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)
@property @property
def stdcxx_libs(self): def stdcxx_libs(self):
return ("-lstdc++",) return ("-lstdc++",)

View File

@ -10,18 +10,6 @@
class Xl(Compiler): class Xl(Compiler):
# Subclasses use possible names of C compiler
cc_names = ["xlc"]
# Subclasses use possible names of C++ compiler
cxx_names = ["xlC", "xlc++"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["xlf"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["xlf90", "xlf95", "xlf2003", "xlf2008"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("xl", "xlc"), "cc": os.path.join("xl", "xlc"),
@ -103,31 +91,3 @@ def fflags(self):
# For Fortran 90 and beyond, it is set by default and has not impact. # For Fortran 90 and beyond, it is set by default and has not impact.
# Its use has no negative side effects. # Its use has no negative side effects.
return "-qzerosize" return "-qzerosize"
@classmethod
def fc_version(cls, fc):
# The fortran and C/C++ versions of the XL compiler are always
# two units apart. By this we mean that the fortran release that
# goes with XL C/C++ 11.1 is 13.1. Having such a difference in
# version number is confusing spack quite a lot. Most notably
# if you keep the versions as is the default xl compiler will
# only have fortran and no C/C++. So we associate the Fortran
# compiler with the version associated to the C/C++ compiler.
# One last stumble. Version numbers over 10 have at least a .1
# those under 10 a .0. There is no xlf 9.x or under currently
# available. BG/P and BG/L can such a compiler mix and possibly
# older version of AIX and linux on power.
fortran_version = cls.default_version(fc)
if fortran_version >= 16:
# Starting with version 16.1, the XL C and Fortran compilers
# have the same version. So no need to downgrade the Fortran
# compiler version to match that of the C compiler version.
return str(fortran_version)
c_version = float(fortran_version) - 2
if c_version < 10:
c_version = c_version - 0.1
return str(c_version)
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)

View File

@ -9,18 +9,6 @@
class XlR(spack.compilers.xl.Xl): class XlR(spack.compilers.xl.Xl):
# Subclasses use possible names of C compiler
cc_names = ["xlc_r"]
# Subclasses use possible names of C++ compiler
cxx_names = ["xlC_r", "xlc++_r"]
# Subclasses use possible names of Fortran 77 compiler
f77_names = ["xlf_r"]
# Subclasses use possible names of Fortran 90 compiler
fc_names = ["xlf90_r", "xlf95_r", "xlf2003_r", "xlf2008_r"]
# Named wrapper links within build_env_path # Named wrapper links within build_env_path
link_paths = { link_paths = {
"cc": os.path.join("xl_r", "xlc_r"), "cc": os.path.join("xl_r", "xlc_r"),

View File

@ -130,6 +130,7 @@ def test_arch_spec_container_semantic(item, architecture_str):
], ],
) )
@pytest.mark.filterwarnings("ignore:microarchitecture specific") @pytest.mark.filterwarnings("ignore:microarchitecture specific")
@pytest.mark.not_on_windows("Windows doesn't support the compiler wrapper")
def test_optimization_flags(compiler_spec, target_name, expected_flags, compiler_factory): def test_optimization_flags(compiler_spec, target_name, expected_flags, compiler_factory):
target = spack.target.Target(target_name) target = spack.target.Target(target_name)
compiler_dict = compiler_factory(spec=compiler_spec, operating_system="")["compiler"] compiler_dict = compiler_factory(spec=compiler_spec, operating_system="")["compiler"]

View File

@ -589,6 +589,7 @@ def test_xl_r_flags():
"compiler_spec,expected_result", "compiler_spec,expected_result",
[("gcc@4.7.2", False), ("clang@3.3", False), ("clang@8.0.0", True)], [("gcc@4.7.2", False), ("clang@3.3", False), ("clang@8.0.0", True)],
) )
@pytest.mark.not_on_windows("GCC and LLVM currently not supported on the platform")
def test_detecting_mixed_toolchains( def test_detecting_mixed_toolchains(
compiler_spec, expected_result, mutable_config, compiler_factory compiler_spec, expected_result, mutable_config, compiler_factory
): ):

View File

@ -101,7 +101,7 @@ def edit(self, spec, prefix):
if "+scalapack" in spec: if "+scalapack" in spec:
flags["FC"] = "{0}".format(spec["mpi"].mpifc) flags["FC"] = "{0}".format(spec["mpi"].mpifc)
else: else:
flags["FC"] = self.compiler.fc_names[0] flags["FC"] = self.compiler.fc
# Set FCFLAGS # Set FCFLAGS
if self.compiler.flags.get("fflags") is not None: if self.compiler.flags.get("fflags") is not None: