Repository: spack/spack

Issue:
grpc build failed
`# spack install -v grpc` will fail:

1. It looks some cmake configure cannot match the newest version.
There are lots of error log like that:
```
CMake Error at CMakeLists.txt:12658 (add_executable):
  Target "gen_hpack_tables" links to target "absl::inlined_vector" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
```

2. After I remove the configure defined in grpc package.py, another error printed:
```
1 error found in build log:
     17    CMake Warning at cmake/abseil-cpp.cmake:30 (message):
     18      gRPC_ABSL_PROVIDER is "module" but ABSL_ROOT_DIR is wrong
     19    Call Stack (most recent call first):
     20      CMakeLists.txt:188 (include)
     21
     22
  >> 23    CMake Error at cmake/cares.cmake:25 (add_subdirectory):
     24      The source directory
     25
     26        /tmp/root/spack-stage/spack-stage-grpc-1.27.3-evg7ynhx2wavbgdw7ri5nh4vbac4wo26/spack-src/third_party/cares/cares
     27
     28      does not contain a CMakeLists.txt file.
     29    Call Stack (most recent call first):

See build log for details:
  /tmp/root/spack-stage/spack-stage-grpc-1.27.3-evg7ynhx2wavbgdw7ri5nh4vbac4wo26/spack-build-out.txt
```

After searching on grpc github , it looks like some third-party repo should been clone before we build it by using this command:
`# git submodule update --init`

So I think maybe the grpc package should be refine for the latest version.
And because of the `git command`, maybe it's better to use `git = xxx` instead of `url =xxx` ?

And that's my local patch for testing
```
diff --git a/var/spack/repos/builtin/packages/grpc/package.py b/var/spack/repos/builtin/packages/grpc/package.py
index 8cbfe7732..df04c69ab 100644
--- a/var/spack/repos/builtin/packages/grpc/package.py
+++ b/var/spack/repos/builtin/packages/grpc/package.py
@@ -9,39 +9,27 @@ class Grpc(CMakePackage):
     """A high performance, open-source universal RPC framework."""

     homepage = "https://grpc.io"
-    url      = "https://github.com/grpc/grpc/archive/v1.27.0.tar.gz"
+    git      = "https://github.com/grpc/grpc.git"

-    version('1.27.0', sha256='3ccc4e5ae8c1ce844456e39cc11f1c991a7da74396faabe83d779836ef449bce')
-    version('1.26.0', sha256='2fcb7f1ab160d6fd3aaade64520be3e5446fc4c6fa7ba6581afdc4e26094bd81')
-    version('1.25.0', sha256='ffbe61269160ea745e487f79b0fd06b6edd3d50c6d9123f053b5634737cf2f69')
-    version('1.24.3', sha256='c84b3fa140fcd6cce79b3f9de6357c5733a0071e04ca4e65ba5f8d306f10f033')
-    version('1.23.1', sha256='dd7da002b15641e4841f20a1f3eb1e359edb69d5ccf8ac64c362823b05f523d9')
+    version('master', branch='master')

-    variant('codegen', default=True,
+    variant('codegen', default=False,
             description='Builds code generation plugins for protobuf '
                         'compiler (protoc)')

-    depends_on('protobuf')
     depends_on('openssl')
-    depends_on('zlib')
-    depends_on('c-ares')
+
+    root_cmakelists_dir = 'cmake/build'

     def cmake_args(self):
         args = [
             '-DgRPC_BUILD_CODEGEN:Bool={0}'.format(
                 'ON' if '+codegen' in self.spec else 'OFF'),
-            '-DgRPC_BUILD_CSHARP_EXT:Bool=OFF',
-            '-DgRPC_INSTALL:Bool=ON',
-            # Tell grpc to skip vendoring and look for deps via find_package:
-            '-DgRPC_CARES_PROVIDER:String=package',
-            '-DgRPC_ZLIB_PROVIDER:String=package',
-            '-DgRPC_SSL_PROVIDER:String=package',
-            '-DgRPC_PROTOBUF_PROVIDER:String=package',
-            '-DgRPC_USE_PROTO_LITE:Bool=OFF',
-            '-DgRPC_PROTOBUF_PACKAGE_TYPE:String=CONFIG',
-            # Disable tests:
-            '-DgRPC_BUILD_TESTS:BOOL=OFF',
-            '-DgRPC_GFLAGS_PROVIDER:String=none',
-            '-DgRPC_BENCHMARK_PROVIDER:String=none',
         ]
         return args
+
+    def cmake(self, spec, prefix):
+        git=which('git')
+        git('submodule', 'update', '--init')
+        mkdirp('cmake/build/')
+        cmake('cmake/build')
```


Discussion:
@tldahlgren Is there any suggestion for this issue?
> @tldahlgren Is there any suggestion for this issue?

I *am* able to reproduce the problem and, in case it matters, noticed the `ABSL_ROOT_DIR` warning:

```
[...snip...]
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at cmake/abseil-cpp.cmake:30 (message):
  gRPC_ABSL_PROVIDER is "module" but ABSL_ROOT_DIR is wrong
Call Stack (most recent call first):
  CMakeLists.txt:188 (include)


-- Found c-ares: $SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-4.9.3/c-ares-1.15.0-bcekqetwoijom5cgtdvrw5c3cjwmbpnt/lib/cmake/c-ares/c-ares-config.cmake (found suitable version "1.14.0", minimum required is "1.13.0") 
-- Found ZLIB: $SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-4.9.3/zlib-1.2.11-odisvif7tj74k7ze6wwmcibh2ci2re3a/lib/libz.so (found version "1.2.11") 
-- Found OpenSSL: $SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-4.9.3/openssl-1.1.1f-qenoampfl3acnm7pkyspmk4izip2ohck/lib/libcrypto.so (found version "1.1.1f")  
-- Configuring done
[...snip...]
```

As for your changes, my understanding is "best practice" is to retain previous versions for some undetermined length of time -- in case some codes are relying on them -- and make adjustments as needed for newer versions.

But I will defer to the people more familiar with the package: @figroc , @nazavode , and @adamjstewart .
FWIW. I found another tool -- `or-tools` -- that seemed, at least on the surface,  to have experienced similar issues in the past (see  https://github.com/google/or-tools/issues/1167).

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/grpc/package.py b/var/spack/repos/builtin/packages/grpc/package.py
--- a/var/spack/repos/builtin/packages/grpc/package.py
+++ b/var/spack/repos/builtin/packages/grpc/package.py
@@ -8,6 +8,8 @@
 class Grpc(CMakePackage):
     """A high performance, open-source universal RPC framework."""
 
+    maintainers = ['nazavode']
+
     homepage = "https://grpc.io"
     url      = "https://github.com/grpc/grpc/archive/v1.27.0.tar.gz"
 
@@ -25,6 +27,7 @@ class Grpc(CMakePackage):
     depends_on('openssl')
     depends_on('zlib')
     depends_on('c-ares')
+    depends_on('abseil-cpp', when='@1.27.0:')
 
     def cmake_args(self):
         args = [
@@ -44,4 +47,6 @@ def cmake_args(self):
             '-DgRPC_GFLAGS_PROVIDER:String=none',
             '-DgRPC_BENCHMARK_PROVIDER:String=none',
         ]
+        if self.spec.satisfies('@1.27.0:'):
+            args.append('-DgRPC_ABSL_PROVIDER:String=package')
         return args


Test patch: