Skip to content

Mix Clang and GNU Fortran on OS-X #568

@davydden

Description

@davydden

Spack correctly finds compilers on El Capitan

$ ./spack compilers
==> Available compilers
-- gcc ----------------------------------------------------------
gcc@5.3.0  gcc@4.2.1

-- clang --------------------------------------------------------
clang@7.0.2-apple

and the compilers.yaml looks all right

compilers:
  darwin-x86_64:
    clang@7.0.2-apple:
      cc: /usr/bin/clang
      cxx: /usr/bin/clang++
      f77: null
      fc: null
    gcc@4.2.1:
      cc: /usr/bin/gcc
      cxx: /usr/bin/g++
      f77: null
      fc: null
    gcc@5.3.0:
      cc: null
      cxx: null
      f77: /usr/local/bin/gfortran
      fc: /usr/local/bin/gfortran

To use this on OS-X, one really need a way to specify the usage of

cc: /usr/bin/clang
cxx: /usr/bin/clang++

together with

f77: /usr/local/bin/gfortran
fc: /usr/local/bin/gfortran

when building, say, OpenMPI with fortran support. That also includes changing the installation prefix darwin-x86_64/gcc-5.3.0/ to something like darwin-x86_64/gcc-5.3.0-clang-7.0.2/.

As a current workaround I guess one can edit compilers.yaml manually to something like

compilers:
  darwin-x86_64:
    clang@7.0.2-apple:
      cc: /usr/bin/clang
      cxx: /usr/bin/clang++
      f77: /usr/local/bin/gfortran
      fc: /usr/local/bin/gfortran

and then make clang default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions