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

check system compilers to set minimal buildenv #51

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions easybuild/tools/toolchain/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import sys
import tempfile

from distutils.spawn import find_executable

from easybuild.base import fancylogger
from easybuild.tools.build_log import EasyBuildError, dry_run_msg
from easybuild.tools.config import build_option, install_path
Expand Down Expand Up @@ -243,13 +245,19 @@ def set_minimal_build_env(self):

# this is only relevant when using a system toolchain,
# for proper toolchains these variables will get set via the call to set_variables()
env_vars = {
'CC': 'gcc',
'CXX': 'g++',
'F77': 'gfortran',
'F90': 'gfortran',
'FC': 'gfortran',
known_sys_compilers = {
'gcc': ['CC'],
'g++': ['CXX'],
'gfortran': ['F77', 'F90', 'FC'],
}

env_vars = {}
for compiler, flags in known_sys_compilers.items():
# distutils.spawn.find_executable() only returns first hit from $PATH
if find_executable(compiler):
Copy link
Owner

Choose a reason for hiding this comment

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

Why not use the which function we have (in the filetools) module?

It think it also makes sense to add some logging here, to print the path to the command that was found for example.

If we don't set the variable for gfortran (I don't think it makes sense), then we can also print a warning when gcc or g++ is not found?

I'll make this changes myself in my PR easybuilders#3399

Copy link
Author

Choose a reason for hiding this comment

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

I had no idea that EB already had a which function 😆

for flag in flags:
env_vars.update({flag: compiler})

for name, value in env_vars.items():
setvar(name, value)

Expand Down