spack/share/spack
Harmen Stoppels 4ce80b95f3
spack compiler find --[no]-mixed-toolchain (#40902)
Currently there's some hacky logic in the AppleClang compiler that makes
it also accept `gfortran` as a fortran compiler if `flang` is not found.

This is guarded by `if sys.platform` checks s.t. it only applies to
Darwin.

But on Linux the feature of detecting mixed toolchains is highly
requested too, cause it's rather annoying to run into a failed build of
`openblas` after dozens of minutes of compiling its dependencies, just
because clang doesn't have a fortran compiler.

In particular in CI where the system compilers may change during system
updates, it's typically impossible to fix compilers in a hand-written
compilers.yaml config file: the config will almost certainly be outdated
sooner or later, and maintaining one config file per target machine and
writing logic to select the correct config is rather undesirable too.

---

This PR introduces a flag `spack compiler find --mixed-toolchain` that
fills out missing `fc` and `f77` entries in `clang` / `apple-clang` by
picking the best matching `gcc`.

It is enabled by default on macOS, but not on Linux, matching current
behavior of `spack compiler find`.

The "best matching gcc" logic and compiler path updates are identical to
how compiler path dictionaries are currently flattened "horizontally"
(per compiler id). This just adds logic to do the same "vertically"
(across different compiler ids).

So, with this change on Ubuntu 22.04:

```
$ spack compiler find --mixed-toolchain
==> Added 6 new compilers to /home/harmen/.spack/linux/compilers.yaml
    gcc@13.1.0  gcc@12.3.0  gcc@11.4.0  gcc@10.5.0  clang@16.0.0  clang@15.0.7
==> Compilers are defined in the following files:
    /home/harmen/.spack/linux/compilers.yaml

```

you finally get:

```
compilers:
- compiler:
    spec: clang@=15.0.7
    paths:
      cc: /usr/bin/clang
      cxx: /usr/bin/clang++
      f77: /usr/bin/gfortran
      fc: /usr/bin/gfortran
    flags: {}
    operating_system: ubuntu23.04
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []
- compiler:
    spec: clang@=16.0.0
    paths:
      cc: /usr/bin/clang-16
      cxx: /usr/bin/clang++-16
      f77: /usr/bin/gfortran
      fc: /usr/bin/gfortran
    flags: {}
    operating_system: ubuntu23.04
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []
```

The "best gcc" is automatically default system gcc, since it has no
suffixes / prefixes.
2023-11-06 15:17:31 -08:00
..
bash bugfix: compress aliases for first command in completion (#40890) 2023-11-05 10:15:37 +00:00
bootstrap Update bootstrap buildcache to support Python 3.12 (#40404) 2023-10-11 19:03:17 +02:00
csh macos sip: apply on macos only, dont store LD_LIBRARY_PATH (#38687) 2023-07-04 10:54:13 +02:00
docker license year bump (#34921) 2023-01-18 14:30:17 -08:00
docs/docker/module-file-tutorial license year bump (#34921) 2023-01-18 14:30:17 -08:00
fish Fix suffix of tab completion scripts (#39154) 2023-08-09 08:28:55 -05:00
gitlab hdf5-vol-async: better specify dependency condition (#40882) 2023-11-04 20:31:52 +01:00
keys update tutorial command for v0.18.0 and new gpg key (#30904) 2022-05-28 02:36:20 +00:00
logo add artisanal handcrafted SVG Spack logo. (#6165) 2017-11-06 22:42:16 -08:00
qa spack env activate: create & activate default environment without args (#40756) 2023-11-05 22:53:26 -08:00
templates depfile: deal with empty / non-concrete env (#40816) 2023-11-02 16:04:35 +01:00
setup-env.csh license year bump (#34921) 2023-01-18 14:30:17 -08:00
setup-env.fish Revert "Add style tool to fix fish file formatting (#39155)" (#39680) 2023-08-29 18:12:19 +02:00
setup-env.ps1 Windows: Add PowerShell env support (#37951) 2023-06-27 18:26:51 -07:00
setup-env.sh spack env activate: create & activate default environment without args (#40756) 2023-11-05 22:53:26 -08:00
setup-tutorial-env.sh license year bump (#34921) 2023-01-18 14:30:17 -08:00
spack-completion.bash spack compiler find --[no]-mixed-toolchain (#40902) 2023-11-06 15:17:31 -08:00
spack-completion.fish spack compiler find --[no]-mixed-toolchain (#40902) 2023-11-06 15:17:31 -08:00