diff --git a/easybuild/toolchains/gcc.py b/easybuild/toolchains/gcc.py index 0b6b2b96f9..5928e81624 100644 --- a/easybuild/toolchains/gcc.py +++ b/easybuild/toolchains/gcc.py @@ -31,7 +31,7 @@ """ import re -from easybuild.toolchains.gcccore import GCCcore +from easybuild.toolchains.gcccore import GCCcore, GCCCORE_BANNED_LIBRARIES from easybuild.tools import LooseVersion from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME @@ -43,6 +43,16 @@ class GccToolchain(GCCcore): SUBTOOLCHAIN = [GCCcore.NAME, SYSTEM_TOOLCHAIN_NAME] OPTIONAL = False + def banned_linked_shared_libs(self): + """ + List of shared libraries (names, file names, paths) which are + not allowed to be linked in any installed binary/library. + """ + banned_libs = super().banned_linked_shared_libs() + + # Restore libraries that were banned at GCCcore level but ok for GCC + return list(set(banned_libs) - set(GCCCORE_BANNED_LIBRARIES)) + def is_deprecated(self): """Return whether or not this toolchain is deprecated.""" # GCC toolchains older than GCC version 8.x are deprecated since EasyBuild v4.5.0 diff --git a/easybuild/toolchains/gcccore.py b/easybuild/toolchains/gcccore.py index f3ff61dae7..5e3f1b1bb4 100644 --- a/easybuild/toolchains/gcccore.py +++ b/easybuild/toolchains/gcccore.py @@ -35,6 +35,9 @@ from easybuild.tools import LooseVersion from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME +# At GCCcore level we do not allow OpenMP +GCCCORE_BANNED_LIBRARIES = ['libgomp.so'] + class GCCcore(Gcc): """Compiler-only toolchain, including only GCC and binutils.""" @@ -46,6 +49,15 @@ class GCCcore(Gcc): # for old versions of some toolchains (GCC, intel) it is not part of the hierarchy and hence optional OPTIONAL = True + def banned_linked_shared_libs(self): + """ + List of shared libraries (names, file names, paths) which are + not allowed to be linked in any installed binary/library. + """ + banned_libs = super().banned_linked_shared_libs() + + return banned_libs + GCCCORE_BANNED_LIBRARIES + def is_deprecated(self): """Return whether or not this toolchain is deprecated.""" # GCC toolchains older than GCC version 8.x are deprecated since EasyBuild v4.5.0 diff --git a/easybuild/toolchains/linalg/flexiblas.py b/easybuild/toolchains/linalg/flexiblas.py index 73cb3ffe0c..219f70cff6 100644 --- a/easybuild/toolchains/linalg/flexiblas.py +++ b/easybuild/toolchains/linalg/flexiblas.py @@ -34,6 +34,7 @@ from easybuild.tools.toolchain.linalg import LinAlg +from easybuild.tools.options import build_option from easybuild.tools.run import run_shell_cmd from easybuild.tools.systemtools import get_shared_lib_ext @@ -48,18 +49,20 @@ def det_flexiblas_backend_libs(): # System-wide (config directory): # OPENBLAS # library = libflexiblas_openblas.so - res = run_shell_cmd("flexiblas list", hidden=True) - - shlib_ext = get_shared_lib_ext() - flexiblas_lib_regex = re.compile(r'library = (?Plib.*\.%s)' % shlib_ext, re.M) - flexiblas_libs = flexiblas_lib_regex.findall(res.output) - backend_libs = [] - for flexiblas_lib in flexiblas_libs: - # assumption here is that the name of FlexiBLAS library (like 'libflexiblas_openblas.so') - # maps directly to name of the backend library ('libopenblas.so') - backend_lib = 'lib' + flexiblas_lib.replace('libflexiblas_', '') - backend_libs.append(backend_lib) + # in a unittest context the flexiblas command does not exist, but in a normal context it always does + if not build_option('unit_testing_mode'): + res = run_shell_cmd("flexiblas list", hidden=True) + + shlib_ext = get_shared_lib_ext() + flexiblas_lib_regex = re.compile(r'library = (?Plib.*\.%s)' % shlib_ext, re.M) + flexiblas_libs = flexiblas_lib_regex.findall(res.output) + + for flexiblas_lib in flexiblas_libs: + # assumption here is that the name of FlexiBLAS library (like 'libflexiblas_openblas.so') + # maps directly to name of the backend library ('libopenblas.so') + backend_lib = 'lib' + flexiblas_lib.replace('libflexiblas_', '') + backend_libs.append(backend_lib) return backend_libs