Repository: spack/spack

Issue:
R fails to build with zlib@1.2.10
R's configure script has an overly optimistic bit of code to check the zlib version which fails now that the zlib patch version is greater than 9.

I'm passing a suggested fix to the R folks through friends of mine who are "connected".

I don't think that they can do anything to fix the current version, so I think that we'll need to constrain the current R version to depend_on zlib@1.2.8 (or 9, but we don't have a digest for that and 8's apparently be working fine for everyone...).

Feedback, before I patch something?


Discussion:
Yes please!
FWIW, here's the note I sent R-ward.

---

The system that I use to build things (spack) updated its zlib to 1.2.10.

R’s now failing to build, because the test that it uses in it’s configure script assumes that the zlib patch version will be less than 10.

Since I’m a mono-maniacal GitHub zealot and no longer know how to deal with other community systems, I thought I’d see if you could help me get it fixed.

A fix appears to be to change the bit of the test to look at ZLIB_VERNUM instead of ZLIB_VERSION (thanks protobuf!) to something like this:

```
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
int main() {
#ifdef ZLIB_VERNUM
  if (ZLIB_VERNUM < 0x1250) {
    exit(1);
  }
  exit(0);
#else
  exit(1);
#endif
}
]])],
```

This happens around line 3103 in the m4/R.m4 source (I’ve tested it by hacking it into the existing configure script), haven’t done the entire configure dance.

Can you help me get this to where it needs to go?
Ok, seems like the concise thing is:

```
depends_on('zlib@1.2.8', when='@3.3.1:')
depends_on('zlib', when='@:3.3.1)
```

or is there something cleaner (or, is that Just Plain Wrong(tm))?


LGTM
Lets Let Me Finish It First....

Does what I wrote above seem right (before I launch an R build...)?
yes -- Looks Good To Me™ 😄 !  I think there's some ambiguity with Let's Get This Merged™.
Ok maybe I spoke too soon.  the range is inclusive so the second line should probably say `:3.3.0'
(not to mention the missing single quote on the second line...).

I'm confused though.  I want everything up to and including 3.3.1 to use 1.2.8.  I'm hoping (assuming) that anything after 3.3.1 will work with zlib@1.2.10.  

I finally searched my way [to the version spec info](http://spack.readthedocs.io/en/latest/basic_usage.html#version-specifier) and I think that what I want is:

```
    depends_on('zlib@1.2.8', when='@:3.3.1')
    depends_on('zlib', when='@3.3.2:')
```

@hartzell: yep I thought you meant everything above 3.3.1 using 1.2.8.  Sorry -- latest version is correct.
I have a build running.  Will check in on it later this evening.
This will work better:
```python
depends_on('zlib')
depends_on('zlib@:1.2.8', when='@:3.3.1')
```
What it says is R depends on zlib. If R is version 3.3.1 or below, you can't use a version of zlib that is newer than 1.2.8. Your solution also does this, but it introduces an easy to reproduce bug. If you use:
```python
depends_on('zlib@1.2.8', when='@:3.3.1')
depends_on('zlib', when='@3.3.2:')
```
Now try running:
```
$ spack install R ^zlib@1.2.8
```
it will tell you that R doesn't depend on zlib.
> (or 9, but we don't have a digest for that and 8's apparently be working fine for everyone...)

If you check out http://www.zlib.net/, you'll notice that 1.2.10 was released a couple days after 1.2.9. Looks like 1.2.9 was buggy:

> Due to the bug fixes, any installations of 1.2.9 should be immediately replaced with 1.2.10.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/R/package.py b/var/spack/repos/builtin/packages/R/package.py
--- a/var/spack/repos/builtin/packages/R/package.py
+++ b/var/spack/repos/builtin/packages/R/package.py
@@ -63,6 +63,7 @@ class R(Package):
     depends_on('icu4c')
     depends_on('glib')
     depends_on('zlib')
+    depends_on('zlib@:1.2.8', when='@:3.3.1')
     depends_on('bzip2')
     depends_on('libtiff')
     depends_on('jpeg')


Test patch: