Repository: spack/spack

Issue:
Spack issue on bluegene : doesn't detect compilers from $PATH
I am quickly trying spack on bg-q. I have xlc/gcc in $PATH but spack doesn't detect it:

```
$ which xlc
/usr/bin/xlc
$ which gcc
/bgsys/local/gcc/4.8.1/bin/gcc
$ spack compiler find
==> Found no new compilers
$ spack compiler add
==> Found no new compilers
$ spack compiler add /bgsys/local/gcc/4.8.1/bin/
==> Found no new compilers
```

For arch, I see following:

```
$ spack arch
bbq-None-powerpc
```

 "None" in arch indicate problem? I have no knowledge of the code but by looking at

```
lib/spack/spack/platforms/bgq.py
```

it seems like "add_operating_system" is missing and whenever there is query for os, this returns None. This might be causing this issue?

If I run any command to install package, it hang somewhere.

Could someone have a look? Am I missing anything?



Discussion:
Getting "None" is definitely a bug and has caused problems for people in the past. @js947 can you take a look at this? I see you're working on better distro detection in #1629. @becker33 may also be able to help.

I see same issue using #1629  (i.e. bgq-None-powerpc).
If there any other suggestions / workarounds, I would be happy to try!

The obvious workaround is to hack the appropriate `get_os()` subroutine (or whatever it's called) to return `'Linux'`

For Cray machine I see front-end and back-end os are added separately and more elaborate handling in :

```
lib/spack/spack/platforms/cray.py
lib/spack/spack/operating_systems/cnl.py
```

I don't have sufficient knowledge to implement workaround.

Suggestion from bluegene users/developers out there?

@tgamblin @becker33 @lee218llnl : if you have seen similar issue, let me know. If you think this is more like the issue with the bg-q system where I am trying this (e.g. mira), I will try to debug this. thank you!

@pramodk: the public BGQ support isn't as robust as the cray support OS-wise right now. I can try to put together a quick configuration that will work on Mira, but I might not get to it until next weak-ish.  Would that work?

@tgamblin : next week is perfectly fine! I work regularly on bg-q systems (mira, juqueen at juelich)  and would love to have spack working on bg-q platform. thank you very much!

This may also be related to #1689 

@tgamblin : let me know once you will have config to try for bg-q. You mentioned that `public` bg-q support is not robust.  On the google group I asked about bg-q but seems like not many people are bg-q users (?). I have following question/comments:
- I assume you might be building many packages on Sequoia. Am I correct?
- specific example is PETSc which require a test on compute node. Do you do anything specific?
- While installing a package, how to specify if some of the dependents needs to be compile for front-end?
  - using something like arch=front_arch on command line for relevant packages?
  - in packages.yaml or architecture specific install/configure method?
- If there are any specific tips about compilers.yaml or packages.yaml to get started on bg-q, it would be great! (from your experience)

I am performance engineer, using performance tools (tau, score-p, scalasca, cube, hpctoolkit, extrae, openspeedshop, omp-p, darshan etc.) on daily basis and I would like use spack to build all these tools on x86, bg-q, cray and KNC/KNL. I will open PR for missing packages in spack soon or some small updates.

If there is any relevant documentation/issues/PR regarding bg-q, cross compiling etc,  please point me.

Thanks!


Resolving patch:
diff --git a/lib/spack/spack/operating_systems/cnk.py b/lib/spack/spack/operating_systems/cnk.py
new file mode 100644
--- /dev/null
+++ b/lib/spack/spack/operating_systems/cnk.py
@@ -0,0 +1,17 @@
+from spack.architecture import OperatingSystem
+
+
+class Cnk(OperatingSystem):
+    """ Compute Node Kernel (CNK) is the node level operating system for
+    the IBM Blue Gene series of supercomputers. The compute nodes of the
+    Blue Gene family of supercomputers run CNK, a lightweight kernel that
+    runs on each node and supports one application running for one user
+    on that node."""
+
+    def __init__(self):
+        name = 'cnk'
+        version = '1'
+        super(Cnk, self).__init__(name, version)
+
+    def __str__(self):
+        return self.name
diff --git a/lib/spack/spack/platforms/bgq.py b/lib/spack/spack/platforms/bgq.py
--- a/lib/spack/spack/platforms/bgq.py
+++ b/lib/spack/spack/platforms/bgq.py
@@ -1,17 +1,32 @@
 import os
 from spack.architecture import Platform, Target
+from spack.operating_systems.linux_distro import LinuxDistro
+from spack.operating_systems.cnk import Cnk
 
 
 class Bgq(Platform):
     priority    = 30
     front_end   = 'power7'
-    back_end    = 'powerpc'
-    default     = 'powerpc'
+    back_end    = 'ppc64'
+    default     = 'ppc64'
 
     def __init__(self):
+        ''' IBM Blue Gene/Q system platform.'''
+
         super(Bgq, self).__init__('bgq')
+
         self.add_target(self.front_end, Target(self.front_end))
-        self.add_target(self.back_end, Target(self.back_end,))
+        self.add_target(self.back_end, Target(self.back_end))
+
+        front_distro = LinuxDistro()
+        back_distro = Cnk()
+
+        self.front_os = str(front_distro)
+        self.back_os = str(back_distro)
+        self.default_os = self.back_os
+
+        self.add_operating_system(str(front_distro), front_distro)
+        self.add_operating_system(str(back_distro), back_distro)
 
     @classmethod
     def detect(self):


Test patch: