Skip to content

Commit

Permalink
Remove code from Compiler that is not used anymore (spack#45982)
Browse files Browse the repository at this point in the history
Signed-off-by: Massimiliano Culpo <[email protected]>
  • Loading branch information
alalazo authored Sep 20, 2024
1 parent f9f6f09 commit b28583b
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 315 deletions.
24 changes: 0 additions & 24 deletions lib/spack/spack/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,6 @@ class Compiler:
support for specific compilers, their possible names, arguments,
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.
# Prefixes are sometimes used for toolchains
prefixes: List[str] = []
Expand Down Expand Up @@ -619,18 +607,6 @@ def extract_version_from_output(cls, output):
def cc_version(cls, 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
def search_regexps(cls, language):
# Compile all the regular expressions used for files beforehand.
Expand Down
48 changes: 23 additions & 25 deletions lib/spack/spack/compilers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import importlib
import os
import re
import sys
import warnings
from typing import Dict, List, Optional
Expand Down Expand Up @@ -631,37 +632,34 @@ def is_mixed_toolchain(compiler):
Args:
compiler (spack.compiler.Compiler): a valid compiler object
"""
cc = os.path.basename(compiler.cc or "")
cxx = os.path.basename(compiler.cxx or "")
f77 = os.path.basename(compiler.f77 or "")
fc = os.path.basename(compiler.fc or "")
import spack.detection.path

executables = [
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()
for compiler_cls in all_compiler_types():
# 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(
[
name_matches(cc, compiler_cls.cc_names),
name_matches(cxx, compiler_cls.cxx_names),
name_matches(f77, compiler_cls.f77_names),
name_matches(fc, compiler_cls.fc_names),
]
):
tty.debug("[TOOLCHAIN] MATCH {0}".format(compiler_cls.__name__))
toolchains.add(compiler_cls.__name__)
finder = spack.detection.path.ExecutablesFinder()

for pkg_name in spack.repo.PATH.packages_with_tags(COMPILER_TAG):
pkg_cls = spack.repo.PATH.get_pkg_class(pkg_name)
patterns = finder.search_patterns(pkg=pkg_cls)
if not patterns:
continue
joined_pattern = re.compile(r"|".join(patterns))

if any(joined_pattern.search(exe) for exe in executables):
tty.debug(f"[TOOLCHAIN] MATCH {pkg_name}")
toolchains.add(pkg_name)

if len(toolchains) > 1:
if (
toolchains == set(["Clang", "AppleClang", "Aocc"])
toolchains == {"llvm", "apple-clang", "aocc"}
# Msvc toolchain uses Intel ifx
or toolchains == set(["Msvc", "Dpcpp", "Oneapi"])
or toolchains == {"msvc", "intel-oneapi-compilers"}
):
return False
tty.debug("[TOOLCHAINS] {0}".format(toolchains))
Expand Down
12 changes: 0 additions & 12 deletions lib/spack/spack/compilers/aocc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@


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"

@property
Expand Down
20 changes: 0 additions & 20 deletions lib/spack/spack/compilers/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@


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
link_paths = {
"cc": os.path.join("arm", "armclang"),
Expand Down Expand Up @@ -90,11 +78,3 @@ def fc_pic_flag(self):
return "-fPIC"

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)
12 changes: 0 additions & 12 deletions lib/spack/spack/compilers/cce.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ def __init__(self, *args, **kwargs):
if not self.is_clang_based:
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.
suffixes = [r"-mp-\d\.\d"]

Expand Down
12 changes: 0 additions & 12 deletions lib/spack/spack/compilers/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@


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"

@property
Expand Down
12 changes: 0 additions & 12 deletions lib/spack/spack/compilers/fj.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@


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
link_paths = {
"cc": os.path.join("fj", "fcc"),
Expand Down
47 changes: 0 additions & 47 deletions lib/spack/spack/compilers/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import os
import re

from llnl.util.filesystem import ancestor

Expand All @@ -15,18 +14,6 @@


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.
# Homebrew and Linuxbrew may build gcc with -X, -X.Y suffixes.
# Old compatibility versions may contain XY suffixes.
Expand Down Expand Up @@ -181,40 +168,6 @@ def default_version(cls, cc):
version = cls.extract_version_from_output(output)
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
def stdcxx_libs(self):
return ("-lstdc++",)
Expand Down
12 changes: 0 additions & 12 deletions lib/spack/spack/compilers/intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@


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
link_paths = {
"cc": os.path.join("intel", "icc"),
Expand Down
18 changes: 1 addition & 17 deletions lib/spack/spack/compilers/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import subprocess
import sys
import tempfile
from typing import Dict, List
from typing import Dict

import archspec.cpu

Expand Down Expand Up @@ -117,18 +117,6 @@ def get_valid_fortran_pth():


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
# Due to the challenges of supporting compiler wrappers
# in Windows, we leave these blank, and dynamically compute
Expand Down Expand Up @@ -393,7 +381,3 @@ def fc_version(cls, fc):
)
clp = spack.util.executable.which_string("cl", path=sps)
return cls.default_version(clp) if clp else fc_ver

@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)
13 changes: 0 additions & 13 deletions lib/spack/spack/compilers/nag.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,13 @@

import os
import re
from typing import List

import llnl.util.lang

import spack.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
# Use default wrappers for C and C++, in case provided in compilers.yaml
link_paths = {
Expand Down
12 changes: 0 additions & 12 deletions lib/spack/spack/compilers/nvhpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@


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
link_paths = {
"cc": os.path.join("nvhpc", "nvc"),
Expand Down
Loading

0 comments on commit b28583b

Please sign in to comment.