easybuilders / easybuild-easyconfigs

A collection of easyconfig files that describe which software to build using which build options with EasyBuild.
https://easybuild.io
GNU General Public License v2.0
373 stars 699 forks source link

Create Custom Toolchain GCC+NAG Fortran #12210

Open mflehmig opened 3 years ago

mflehmig commented 3 years ago

Hi,

we want to create a custom toolchain based on GCC (for C and C++) and NAG Fortran compiler, i.e., replacing gfortran with NAG. Thus, we followed the documentation in Compiler-toolchains and created:

Having this in place, we created and adopted a first easyconfig for a library to be build with the custom toolchain:

$ eb hwloc-2.0.3-gccnagfor-7.eb --include-toolchain=$PREFIX/easybuild/toolchains/gccnagfor.py,$PREFIX/easybuild/toolchains/compiler/nagfor.py
ERROR: Failed to parse configuration options: 'Failed to import easyblock easybuild.toolchains.gccnagfor from /dev/shm/easybuild-tmp/eb-IITjMe/included-toolchains/easybuild/toolchains: cannot import name DUMMY_TOOLCHAIN_NAME'

gccnagfor.py is

import os
from easybuild.toolchains.compiler.gcc import Gcc
from easybuild.toolchains.compiler.nagfor import NAGfor
from easybuild.tools.toolchain import DUMMY_TOOLCHAIN_NAME

TC_CONSTANT_GCCNAGFOR = "GCCNAGfor"

class GccNAGfor(Gcc, NAGfor):
    """Compiler toolchain with GCC and NAG Fortran compilers."""
    NAME = 'GCCNAGfor'
    COMPILER_MODULE_NAME = ['GCC', 'NAGfor']
    COMPILER_FAMILY = TC_CONSTANT_GCCNAGFOR
    SUBTOOLCHAIN = DUMMY_TOOLCHAIN_NAME

Why does easybuild not know DUMMY_TOOLCHAIN_NAME? What are we doing wrong?

And, is there a preferred way to create a custom toolchain with replaced gfortran?

Best regards Martin

boegel commented 3 years ago

@mflehmig The correct import statement would be

from easybuild.tools.toolchain.toolchain import DUMMY_TOOLCHAIN_NAME

Also, you should be using SYSTEM_TOOLCHAIN_NAME instead (see https://github.com/easybuilders/easybuild-framework/pull/2877).