Skip to content

handle use of an unconfigured compiler#41213

Merged
rscohn2 merged 5 commits intospack:developfrom
rscohn2:dev/no-compiler
Nov 27, 2023
Merged

handle use of an unconfigured compiler#41213
rscohn2 merged 5 commits intospack:developfrom
rscohn2:dev/no-compiler

Conversation

@rscohn2
Copy link
Copy Markdown
Member

@rscohn2 rscohn2 commented Nov 22, 2023

If you configure a Fortran compiler, but not a C compiler, then spack will not set CC and it can silently use the system compiler. This can happen if you use spack compiler find to configure %intel@2024, which does not have a C compiler.

There is some logic in the wrapper to handle this case:

# If, say, SPACK_CC is set but SPACK_FC is not, we want to know. Compilers do not

But it is not reached because if you do not configure a C compiler, it does not enable a compiler wrapper. This change enables a default compiler wrapper when there is no configured compiler.

Here is what you see in spack-build-out.txt when building a project that uses configure:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for strip... strip
checking for objdump... objdump
checking for objcopy... objcopy
checking for readelf... readelf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /localdisk/work/rscohn1/projects/spack/spack/lib/spack/env/env/c++
checking whether the C compiler works... no
configure: error: in `/tmp/rscohn1/spack-stage/spack-stage-patchelf-0.17.2-xlmkimeitojq5f7ykokllgmma6yvqm5a/spack-src':
configure: error: C compiler cannot create executables
See `config.log' for more details

And the config.log shows:

configure:3700: checking for gcc
configure:3732: result: /localdisk/work/rscohn1/projects/spack/spack/lib/spack/env/c++
configure:4085: checking for C compiler version
configure:4094: /localdisk/work/rscohn1/projects/spack/spack/lib/spack/env/c++ --version >&5
[spack cc] ERROR: Compiler 'intel@=2021.11.0' does not have a C++ compiler configured.
configure:4105: $? = 1

It isn't always convenient to examine the log files, so I also added a warning when adding a configuration with missing compilers:

spack compiler find /opt/intel/oneapi/compiler/2024.0/bin
==> Warning: intel@=2021.11.0 does not have a C compiler
==> Warning: intel@=2021.11.0 does not have a C++ compiler
==> Added 3 new compilers to /nfs/site/home/rscohn1/.spack/linux/compilers.yaml
    [email protected]  [email protected]  [email protected]
==> Compilers are defined in the following files:
    /nfs/site/home/rscohn1/.spack/linux/compilers.yaml

@rscohn2 rscohn2 requested a review from becker33 November 22, 2023 00:13
@spackbot-app spackbot-app bot added build-environment core PR affects Spack core functionality labels Nov 22, 2023
becker33
becker33 previously approved these changes Nov 22, 2023
@rscohn2 rscohn2 enabled auto-merge (squash) November 22, 2023 02:13
@rscohn2 rscohn2 disabled auto-merge November 22, 2023 12:57
@rscohn2 rscohn2 marked this pull request as draft November 22, 2023 12:58
@rscohn2 rscohn2 marked this pull request as ready for review November 22, 2023 13:25
@rscohn2 rscohn2 enabled auto-merge (squash) November 22, 2023 13:26
@rscohn2
Copy link
Copy Markdown
Member Author

rscohn2 commented Nov 22, 2023

@becker33 : you approval was dismissed when I added more changes. Can you look at it again?

Comment on lines +157 to +164
if not compiler.cc:
tty.warn(f"{compiler.spec} does not have a C compiler")
if not compiler.cxx:
tty.warn(f"{compiler.spec} does not have a C++ compiler")
if not compiler.f77:
tty.warn(f"{compiler.spec} does not have a Fortran77 compiler")
if not compiler.fc:
tty.warn(f"{compiler.spec} does not have a Fortran compiler")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to get very verbose for macos users, since they generally have an apple-clang compiler configured with no fortran.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning only comes when you add to your compilers.yaml, which is not too often. I could only warn about a missing C compiler or only about %intel compiler. Would any of those be ok?

@rscohn2 rscohn2 merged commit fbec91e into spack:develop Nov 27, 2023
@rscohn2 rscohn2 deleted the dev/no-compiler branch November 27, 2023 18:57
@haampie
Copy link
Copy Markdown
Member

haampie commented Nov 27, 2023

@becker33 should this be backported as a bug fix?

@becker33
Copy link
Copy Markdown
Member

Yes, do we have an active backport branch at the moment?

@becker33 becker33 added this to the v0.21.1 milestone Nov 27, 2023
@haampie
Copy link
Copy Markdown
Member

haampie commented Nov 27, 2023

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-environment compilers core PR affects Spack core functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants