Repository: spack/spack

Issue:
Installation issue: grpc
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
$ spack install grpc+shared
...
```

### Information on your system

<!-- Please include the output of `spack debug report` -->
* **Spack:** 0.16.2-3512-9a0febab89
* **Python:** 3.8.2
* **Platform:** linux-rhel7-skylake
* **Concretizer:** clingo

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-env.txt](https://github.com/spack/spack/files/6851654/spack-build-env.txt)
* [spack-build-out.txt](https://github.com/spack/spack/files/6851655/spack-build-out.txt)

<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->
@nazavode

Similar errors occur for versions 1.31.0 and newer, but not version 1.30.0

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers
- [x] I have uploaded the build log and environment files
- [x] I have searched the issues of this repo and believe this is not a duplicate



Discussion:

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
@@ -51,8 +51,7 @@ class Grpc(CMakePackage):
     depends_on('zlib')
     depends_on('c-ares')
     depends_on('abseil-cpp', when='@1.27:')
-    depends_on('re2+shared', when='@1.33.1:+shared')
-    depends_on('re2', when='@1.33.1:')
+    depends_on('re2+pic', when='@1.33.1:')
 
     def cmake_args(self):
         args = [
diff --git a/var/spack/repos/builtin/packages/re2/package.py b/var/spack/repos/builtin/packages/re2/package.py
--- a/var/spack/repos/builtin/packages/re2/package.py
+++ b/var/spack/repos/builtin/packages/re2/package.py
@@ -19,9 +19,15 @@ class Re2(CMakePackage):
 
     variant('shared', default=False,
             description='Build shared instead of static libraries')
+    variant('pic', default=True,
+            description='Enable position independent code')
+
+    # shared libs must have position-independent code
+    conflicts('+shared ~pic')
 
     def cmake_args(self):
         args = [
-            self.define_from_variant('BUILD_SHARED_LIBS', 'shared')
+            self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
+            self.define_from_variant('CMAKE_POSITION_INDEPENDENT_CODE', 'pic')
         ]
         return args


Test patch: