spack / spack

A flexible package manager that supports multiple versions, configurations, platforms, and compilers.
https://spack.io
Other
4.26k stars 2.26k forks source link

Naming two compiler specs close to each other causes one to lose its fortran compiler #19332

Closed white238 closed 1 year ago

white238 commented 4 years ago

I renamed a compiler spec to have it's version in the name and noticed that a different compiler spec lost its fortran compiler after doing so. Renaming the second compiler spec to either gcc@8.1_no_fortran or gcc@no_fortran works fine.

Steps to reproduce the issue

Define two compiler specs that are close to each other:

- compiler:
    environment: {}
    extra_rpaths: []
    flags: {}
    modules: []
    operating_system: rhel7
    paths:
      cc:  /usr/tce/packages/gcc/gcc-8.1.0/bin/gcc
      cxx: /usr/tce/packages/gcc/gcc-8.1.0/bin/g++
      f77: /usr/tce/packages/gcc/gcc-8.1.0/bin/gfortran
      fc:  /usr/tce/packages/gcc/gcc-8.1.0/bin/gfortran
    spec: gcc@8.1.0
    target: x86_64
- compiler:
    environment: {}
    extra_rpaths: []
    flags: {}
    modules: []
    operating_system: rhel7
    paths:
      cc:  /usr/tce/packages/gcc/gcc-8.1.0/bin/gcc
      cxx: /usr/tce/packages/gcc/gcc-8.1.0/bin/g++
      f77:
      fc:
    spec: gcc@8.1.0_no_fortran
    target: x86_64

When referencing the fortran compiler in a package the environment variable SPACK_FC ends up being the string "None". We do already guard against the None type but this somehow ends up with a string "None".

Error Message

I get the following error out of Axom's CMake command:

-- The Fortran compiler identification is unknown
CMake Error at CMakeLists.txt:21 (enable_language):
  The CMAKE_Fortran_COMPILER:

    None

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full
  path to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!

Information on your system

rzgenie

alalazo commented 1 year ago

I cannot reproduce with:

What I tried was to use:

compilers:
- compiler:
    spec: gcc@=9.4.0
    paths:
      cc: /usr/bin/gcc
      cxx: /usr/bin/g++
      f77: /usr/bin/gfortran
      fc: /usr/bin/gfortran
    flags: {}
    operating_system: ubuntu20.04
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []
- compiler:
    spec: gcc@=9.4.0_no_fortran
    paths:
      cc: /usr/bin/gcc
      cxx: /usr/bin/g++
      f77: null
      fc: null
    flags: {}
    operating_system: ubuntu20.04
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []

And axom built fine with gcc@=9.4.0 Screenshot from 2023-07-11 10-49-31