diff --git a/lib/spack/docs/getting_started.rst b/lib/spack/docs/getting_started.rst index aabea38b36c..a5431d559bd 100644 --- a/lib/spack/docs/getting_started.rst +++ b/lib/spack/docs/getting_started.rst @@ -474,9 +474,14 @@ assuming the paths to the compiler executables are determinable from the prefix. If the paths to the compiler executable are not determinable from the -prefix, you can add them to the ``extra_attributes`` field. Similarly, -all other fields from the compilers config can be added to the -``extra_attributes`` field for an external representing a compiler. +prefix, you can add them to the ``extra_attributes`` field using the +``compilers`` key. The ``compilers`` key accepts compilers for ``c``, +``cxx``, ``fortran``, and ``f77``. + +For all other fields from the ``compilers`` config, they can be added +to the ``extra_attributes`` field for an external representing a +compiler. These fields are used as-is in the internal representation +of the compiler config. .. code-block:: yaml @@ -493,11 +498,10 @@ all other fields from the compilers config can be added to the - spec: llvm+clang@15.0.0 arch=linux-rhel8-skylake prefix: /usr extra_attributes: - paths: - cc: /usr/bin/clang-with-suffix + compilers: + c: /usr/bin/clang-with-suffix cxx: /usr/bin/clang++-with-extra-info - fc: /usr/bin/gfortran - f77: /usr/bin/gfortran + fortran: /usr/bin/gfortran extra_rpaths: - /usr/lib/llvm/ diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index f967abf548a..6c99fcdf1ad 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -167,7 +167,17 @@ def _compiler_config_from_external(config): prefix = config.get("prefix", None) compiler_class = class_for_compiler_name(compiler_spec.name) - paths = extra_attributes.get("paths", {}) + paths = extra_attributes.get("compilers", {}) + + # compilers format has cc/fc/f77, externals format has "c/fortran" + if "c" in paths: + paths["cc"] = paths.pop("c") + if "fortran" in paths: + fc = paths.pop("fortran") + paths["fc"] = fc + if "f77" not in paths: + paths["f77"] = fc + compiler_langs = ["cc", "cxx", "fc", "f77"] for lang in compiler_langs: if paths.setdefault(lang, None): diff --git a/lib/spack/spack/test/cmd/compiler.py b/lib/spack/spack/test/cmd/compiler.py index c07039e9db4..c7ede0fc369 100644 --- a/lib/spack/spack/test/cmd/compiler.py +++ b/lib/spack/spack/test/cmd/compiler.py @@ -259,11 +259,10 @@ def test_compiler_list_empty(no_compilers_yaml, working_env, compilers_dir): "prefix": "/path/to/fake", "modules": ["gcc/7.7.7", "foobar"], "extra_attributes": { - "paths": { - "cc": "/path/to/fake/gcc", + "compilers": { + "c": "/path/to/fake/gcc", "cxx": "/path/to/fake/g++", - "fc": "/path/to/fake/gfortran", - "f77": "/path/to/fake/gfortran", + "fortran": "/path/to/fake/gfortran", }, "flags": {"fflags": "-ffree-form"}, },