Repository: spack/spack

Issue:
upcxx: CROSS warning pollutes all invocations of Spack
Since the addition of `upcxx`, **all** invocations of Spack on systems without `aprun` result in a warning message:
```console
==> Warning: CROSS has not been set, however cannot detect scheduler.
```
This is somewhat sub-optimal to say the least, and results from the invocation of `detect_scheduler()` in order to provide the default of the `scheduler` variant, which is executed whenever the recipes are parsed.

I would suggest that an alternative scheme be found to set the default and verify that the setting is valid for the current system without producing a warning on a large class of non-HPC systems.
upcxx: remove warnings from package
fixes #12800 

Warnings in `detect_scheduler()` print out whenever the package is loaded, which  means you can see them in Spack commands that load all packages but have nothing to do with UPC++ (e.g., `spack clean -a`,  `spack dependents`, and others).

- [x] Remove these and other warnings, since the scheduler is visible in the package variant anyway.

- [x] Also remove the `user` scheduler option from `upcxx`, as it depends on the user's environment in a way that is not likely to be the same across systems.

@bonachea, @mjacquel can you take a look at this one?  The main thing I need feedback on is what the user setting for `CROSS` can be.  Is it needed?  Can it be something other than SLURM or ALPS?  If not we should remove it.  If so, then it should be changed to be a string-valued variant, so the user can set its value in a way Spack will actually understand.   Basically we're trying to avoid environment-dependent things in Spack --  one hash should map to one build.

Just for my own edification, does the UPC++  build link to different libraries depending on what CROSS is set to?  Does it actually affect the final binary somehow, or is that just a build-time thing?


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/upcxx/package.py b/var/spack/repos/builtin/packages/upcxx/package.py
--- a/var/spack/repos/builtin/packages/upcxx/package.py
+++ b/var/spack/repos/builtin/packages/upcxx/package.py
@@ -4,31 +4,15 @@
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
 from spack import *
-import llnl.util.tty as tty
-import os
-
-
-def detect_scheduler():
-    if (os.environ.get('CROSS') is None):
-        srunbin = which('srun')
-        if srunbin is None:
-            aprunbin = which('aprun')
-            if aprunbin is None:
-                tty.warn("CROSS has not been set, however "
-                         "cannot detect scheduler.")
-                return 'none'
-            else:
-                tty.warn("CROSS has not been set, however "
-                         "aprun has been found, assuming alps scheduler.")
-                return 'alps'
-        else:
-            tty.warn("CROSS has not been set, however "
-                     "srun has been found, assuming slurm scheduler.")
-            return 'slurm'
-    else:
-        tty.warn("CROSS has been set to %s by the user."
-                 % os.environ.get('CROSS'))
-        return 'user'
+
+
+def cross_detect():
+    if spack.architecture.platform().name == 'cray':
+        if which('srun'):
+            return 'cray-aries-slurm'
+        if which('alps'):
+            return 'cray-aries-alps'
+    return 'none'
 
 
 class Upcxx(Package):
@@ -40,15 +24,16 @@ class Upcxx(Package):
 
     homepage = "https://upcxx.lbl.gov"
 
+    version('2019.9.0', '7642877e05300e38f6fa0afbc6062788')
     version('2019.3.2', '844722cb0e8c0bc649017fce86469457')
 
     variant('cuda', default=False,
             description='Builds a CUDA-enabled version of UPC++')
 
-    variant('scheduler', values=('slurm', 'alps', 'user', 'none'),
-            default=detect_scheduler(),
-            description="Resource manager to use")
-    conflicts('scheduler=none', when='platform=cray',
+    variant('cross', default=cross_detect(),
+            description="UPC++ cross-compile target (autodetect by default)")
+
+    conflicts('cross=none', when='platform=cray',
               msg='None is unacceptable on Cray.')
 
     depends_on('cuda', when='+cuda')
@@ -63,18 +48,20 @@ def url_for_version(self, version):
     def setup_environment(self, spack_env, run_env):
         if 'platform=cray' in self.spec:
             spack_env.set('GASNET_CONFIGURE_ARGS', '--enable-mpi=probe')
-            if "scheduler=slurm" in self.spec:
-                tty.warn("CROSS has been automatically set to %s."
-                         % 'cray-aries-slurm')
-                spack_env.set('CROSS', 'cray-aries-slurm')
-            elif "scheduler=alps" in self.spec:
-                tty.warn("CROSS has been automatically set to %s."
-                         % 'cray-aries-alps')
-                spack_env.set('CROSS', 'cray-aries-alps')
+
+        if 'cross=none' not in self.spec:
+            spack_env.set('CROSS', self.spec.variants['cross'].value)
+
         if '+cuda' in self.spec:
             spack_env.set('UPCXX_CUDA', '1')
             spack_env.set('UPCXX_CUDA_NVCC', self.spec['cuda'].prefix.bin.nvcc)
 
+        run_env.set('UPCXX_INSTALL', self.prefix)
+        run_env.set('UPCXX', self.prefix.bin.upcxx)
+        if 'platform=cray' in self.spec:
+            run_env.set('UPCXX_GASNET_CONDUIT', 'aries')
+            run_env.set('UPCXX_NETWORK', 'aries')
+
     def setup_dependent_package(self, module, dep_spec):
         dep_spec.upcxx = self.prefix.bin.upcxx
 
@@ -83,7 +70,10 @@ def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
         spack_env.set('UPCXX', self.prefix.bin.upcxx)
         if 'platform=cray' in self.spec:
             spack_env.set('UPCXX_GASNET_CONDUIT', 'aries')
+            spack_env.set('UPCXX_NETWORK', 'aries')
 
     def install(self, spec, prefix):
-        installsh = Executable('./install')
+        env['CC'] = self.compiler.cc
+        env['CXX'] = self.compiler.cxx
+        installsh = Executable("./install")
         installsh(prefix)


Test patch: