Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect compiler env variables if different compiler versions are installed #9

Open
hiker opened this issue Nov 25, 2024 · 4 comments

Comments

@hiker
Copy link
Collaborator

hiker commented Nov 25, 2024

My wsl system had gcc-9 (only, no gfortran), and a full gcc-11* installed. The environmet created the following env variables:

CC=$'/usr/bin/gcc-9\n/usr/bin/gcc'
OMPI_CC=$'/usr/bin/gcc-9\n/usr/bin/gcc'
FC=$'None\n/usr/bin/gfortran'
OMPI_FC=$'None\n/usr/bin/gfortran'

Reason is the following output of spack compiler info:

RUN spack compiler info gcc
[email protected]:
        paths:
                cc = /usr/bin/gcc-9
                cxx = None
                f77 = None
                fc = None
        modules  = []
        operating system  = ubuntu22.04
[email protected]:
        paths:
                cc = /usr/bin/gcc
                cxx = /usr/bin/g++
                f77 = /usr/bin/gfortran
                fc = /usr/bin/gfortran
        modules  = []
        operating system  = ubuntu22.04
 

I have a branch that fixes it, once I have confirmed (by rebuilding I'd guess :( ) that it works, I'll do a PR.

@hiker hiker changed the title Incorrect compiler env variables if different compilers are installed Incorrect compiler env variables if different compiler versions are installed Nov 25, 2024
@hiker
Copy link
Collaborator Author

hiker commented Nov 25, 2024

This patch actually does not work (the script aborts), I assume the script is set to abort on error, and the grep statement fails with an error state.

Verify that it works if two consistent settings are provided (which I believe it does), e.g. I have seen:

[email protected]:
        paths:
                cc = /usr/bin/gcc
                cxx = /usr/bin/g++
                f77 = /usr/bin/gfortran
                fc = /usr/bin/gfortran
        modules  = []
        operating system  = ubuntu24.04
[email protected]:
        paths:
                cc = /usr/bin/x86_64-linux-gnu-gcc-13
                cxx = /usr/bin/x86_64-linux-gnu-g++-13
                f77 = /usr/bin/x86_64-linux-gnu-gfortran-13
                fc = /usr/bin/x86_64-linux-gnu-gfortran-13
        modules  = []
        operating system  = ubuntu24.04

@ScottWales
Copy link
Collaborator

Probably extracting the compiler info isn't sufficiently specific at https://github.com/MetOffice/ngmo-environments/blob/main/utils/install-compiler.sh#L40

If NGMOENVS_COMPILER is just "gcc" then you might get multiple matches, which then pass through to the other stages. Easy fix may be just to pull the first (or last, whichever spack will actually use when compiling with %gcc) matched line from the sed output.

@hiker
Copy link
Collaborator Author

hiker commented Nov 27, 2024

While I have fixed the script (main...handle_multiple_installed_compilers) to handle incomplete compilers, the second issue still exist (no surprise) - which makes the resulting environment not working:
OMPI_FC is set to e.g. /usr/bin/gcc\n/usr/bin/x86_64-linux-gnu-gfortran-13, so mpif90 does not work. Manually fixing the environment variables results in a working environment.

@hiker
Copy link
Collaborator Author

hiker commented Nov 27, 2024

Probably extracting the compiler info isn't sufficiently specific at https://github.com/MetOffice/ngmo-environments/blob/main/utils/install-compiler.sh#L40

If NGMOENVS_COMPILER is just "gcc" then you might get multiple matches, which then pass through to the other stages. Easy fix may be just to pull the first (or last, whichever spack will actually use when compiling with %gcc) matched line from the sed output.

That would certainly work in my case, but on my bom laptop, I have two identical compilers, so I think we need more logic there anyway :( I'll add a check that a compiler is specified with version to the sanity check ticket :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants