Skip to content

Compiler dependencies are not being passed to dependencies if package doesn't depend on the language #51244

@white238

Description

@white238

Steps to reproduce

I ran into an issue where I need to enforce the same compiler chain on all packages built by Spack. Spack lost the use of gfortran on my dependencies and went with just using flang, which I did not want. The important take away is the high level package does not depend on fortran but packages under it do. The quick fix was to add depends_on("fortran", type="build") to the high level package but that is not ideal.

Here is a minimal thing to show what is wrong:

Compiler toolchain:

  toolchains:
    clang_19:
    - spec: '%cxx=llvm'
      when: '%cxx'
    - spec: '%fortran=gcc'
      when: '%fortran'

Minimal Packages:

class TopLevel(CMakePackage):
    depends_on("lowlevel")
    depends_on("cxx", type="build")

class LowLevel(CMakePackage):
    depends_on("fortran", type="build")

Minimal concretization of showing the wrong fortran compiler:

==> Concretized 1 spec:
-   cjd6jhd  serac@develop fflags=-fPIC ~asan~cuda+devtools+enzyme~ipo+openmp~petsc+profiling+raja~rocm~shared~slepc+strumpack+sundials+tribol+umpire build_system=cmake build_type=Release dev_path=/serac/repo generator=make arch=linux-rhel8-ivybridge %c,cxx=clang@19.1.7
-   tnt5ej5      ^adiak@0.4.1 fflags=-fPIC ~ipo+mpi~shared build_system=cmake build_type=Release commit=7ac997111785bee6d9391664b1d18ebc2b3c557b generator=make arch=linux-rhel8-ivybridge %c,cxx,fortran=clang@19.1.7

@scheibelp

Error message

No response

Information on your system

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions