Repository: easybuilders/easybuild-framework

Issue:
Error "_set_blas_variables: blas_lib not set" in EasyBuild 3.9.1
I am getting the following error when I am trying to build LAMMPS with EasyBuild 3.9.1. 
For an extended dry run, the following is included in the logs:
```
WARNING: ignoring error '_set_blas_variables: BLAS_LIB not set'
```

Using EasyBuild 3.8.1 the build succeeds. The eb recipe is this https://github.com/eth-cscs/production/blob/master/easybuild/easyconfigs/l/LAMMPS/LAMMPS-22Aug2018-CrayGNU-18.08.eb,


Discussion:
You can find [here](https://gist.github.com/gppezzi/6108ee6ff0e3933b33c0ddd946e9424e) a complete error log.

This build fails in the second build `omp` and has the following `buildopts`:
```
buildopts = [ ' mpi ', ' omp ' ]
```
The build seems to work if we build only `omp`:
```
buildopts = [  ' omp ' ]
```
This really sounds like an error related to the introduction of `multi_deps`, I suspect there is some resetting done related to that that is kicking the error. I will dig into it more today.
It took me a while but I can reproduce this problem, I can fix it by overriding some additional internals of the `LinAlg` class in the `LibSci` class:
```
    def _set_blas_variables(self):
        """Skip setting BLAS related variables"""
        pass

    def _set_lapack_variables(self):
        """Skip setting LAPACK related variables"""
        pass
```
This is unlikely to have any breaking impact since there is no way these were being called in the past (as written they would have always failed for Cray).

Having said all that, I cannot find exactly where/why these functions are being called. It is almost certainly to do with the iteration counting that was introduced in `multi_deps` but I cannot source it.

How to proceed @boegel? I will open a PR with the proposed changes but I'm not 100% happy that I couldn't source why this is now being called.

Resolving patch:
diff --git a/easybuild/toolchains/linalg/libsci.py b/easybuild/toolchains/linalg/libsci.py
--- a/easybuild/toolchains/linalg/libsci.py
+++ b/easybuild/toolchains/linalg/libsci.py
@@ -48,8 +48,8 @@ class LibSci(LinAlg):
 
     # no need to specify libraries, compiler driver takes care of linking the right libraries
     # FIXME: need to revisit this, on numpy we ended up with a serial BLAS through the wrapper.
-    BLAS_LIB = []
-    BLAS_LIB_MT = []
+    BLAS_LIB = ['']
+    BLAS_LIB_MT = ['']
     BLAS_FAMILY = TC_CONSTANT_CRAY_LIBSCI
 
     LAPACK_MODULE_NAME = [CRAY_LIBSCI_MODULE_NAME]


Test patch:
diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py
--- a/test/framework/toolchain.py
+++ b/test/framework/toolchain.py
@@ -178,6 +178,26 @@ def test_prepare_iterate(self):
         tc.prepare()
         self.check_vars_foss_usempi(tc)
 
+    def test_cray_reset(self):
+        """Test toolchain preparation after reset for Cray* toolchain."""
+        # cfr. https://github.com/easybuilders/easybuild-framework/issues/2911
+        init_config(build_options={'optarch': 'test', 'silent': True})
+
+        for tcname in ['CrayGNU', 'CrayCCE', 'CrayIntel']:
+            tc = self.get_toolchain(tcname, version='2015.06-XC')
+            tc.set_options({'dynamic': True})
+            tc.prepare()
+            self.assertEqual(os.environ.get('LIBBLAS'), '')
+            tc.reset()
+            tc.prepare()
+            self.assertEqual(os.environ.get('LIBBLAS'), '')
+            tc.reset()
+            tc.prepare()
+            self.assertEqual(os.environ.get('LIBBLAS'), '')
+            tc.reset()
+            tc.prepare()
+            self.assertEqual(os.environ.get('LIBBLAS'), '')
+
     def test_get_variable_seq_compilers(self):
         """Test get_variable function to obtain compiler variables."""
         tc = self.get_toolchain('foss', version='2018a')