Repository: spack/spack

Issue:
libxml2 fails with Intel 16.0.2
I am now trying to build `amrex` on another machine. I setup spack for intel compilers (to load the proper module, etc.). Lots of packages build just fine (including, e.g. `m4` which failed in #5705 and we had to fix it in spack). But the `libxml2` packages fails with:
```
$ spack install --restage amrex%intel@16.0.2
...
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j32'

4 errors found in build log:
     [ ... ]
     328   icc: command line warning #10006: ignoring unknown option '-Wnested-externs'
     329   icc: command line warning #10006: ignoring unknown option '-Wredundant-decls'
     330   HTMLparser.c(5409): warning #2338: this switch statement does not have a default clause
     331             switch (ctxt->instate) {
     332             ^
     333   
  >> 334   xmlIO.c(1450): error: identifier "LZMA_OK" is undefined
     335         ret =  (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
     336                                                        ^
     337   
     338   xmlIO.c(2044): warning #3179: deprecated conversion of string literal to char* (should be const char*)
     339         char *                 content_type = (char *) "text/xml";
     340                                               ^
     [ ... ]
     342   xmlIO.c(2056): warning #3179: deprecated conversion of string literal to char* (should be const char*)
     343        content_encoding = (char *) "Content-Encoding: gzip";
     344                           ^
     345   
     346   compilation aborted for xmlIO.c (code 2)
     347   Makefile:1248: recipe for target 'xmlIO.lo' failed
  >> 348   make[2]: *** [xmlIO.lo] Error 1
     349   make[2]: *** Waiting for unfinished jobs....
     350   icc: command line warning #10006: ignoring unknown option '-Wno-format-extra-args'
     351   icc: command line warning #10006: ignoring unknown option '-Wcast-align'
     352   icc: command line warning #10006: ignoring unknown option '-Waggregate-return'
     353   icc: command line warning #10006: ignoring unknown option '-Wnested-externs'
     354   icc: command line warning #10006: ignoring unknown option '-Wredundant-decls'
     [ ... ]
     981   trionan.c(218): warning #177: function "trio_is_negative" was declared but never referenced
     982     trio_is_negative
     983     ^
     984   
     985   make[2]: Leaving directory '/home/certik/tmp/spack-stage/spack-stage-dmGFaF/libxml2-2.9.4'
     986   Makefile:1440: recipe for target 'all-recursive' failed
  >> 987   make[1]: *** [all-recursive] Error 1
     988   make[1]: Leaving directory '/home/certik/tmp/spack-stage/spack-stage-dmGFaF/libxml2-2.9.4'
     989   Makefile:859: recipe for target 'all' failed
  >> 990   make: *** [all] Error 2

See build log for details:
  /home/certik/repos/spack/var/spack/stage/libxml2-2.9.4-j26m2sopxpelbb2vhdtbfdb7gdhczbl2/libxml2-2.9.4/spack-build.out
```
The missing `LZMA_OK` symbol I think comes from the `xz` package, that was installed successfully by spack already. Here is the spec:
```
$ spack spec amrex%intel@16.0.2
Input spec
--------------------------------
amrex%intel@16.0.2

Normalized
--------------------------------
amrex%intel@16.0.2
    ^cmake

Concretized
--------------------------------
amrex@17.06%intel@16.0.2 build_type=RelWithDebInfo ~debug dims=3 +fortran+mpi~openmp~particles prec=DOUBLE arch=linux-ubuntu16.04-x86_64 
    ^cmake@3.9.4%intel@16.0.2~doc+ncurses+openssl+ownlibs~qt arch=linux-ubuntu16.04-x86_64 
        ^ncurses@6.0%intel@16.0.2 patches=f84b2708a42777aadcc7f502a261afe10ca5646a51c1ef8b5e60d2070d926b57 ~symlinks arch=linux-ubuntu16.04-x86_64 
            ^pkg-config@0.29.2%intel@16.0.2+internal_glib arch=linux-ubuntu16.04-x86_64 
        ^openssl@1.0.2k%intel@16.0.2 arch=linux-ubuntu16.04-x86_64 
            ^zlib@1.2.11%intel@16.0.2+pic+shared arch=linux-ubuntu16.04-x86_64 
    ^openmpi@2.1.1%intel@16.0.2~cuda fabrics= ~java schedulers= ~sqlite3~thread_multiple+vt arch=linux-ubuntu16.04-x86_64 
        ^hwloc@1.11.7%intel@16.0.2~cuda+libxml2+pci arch=linux-ubuntu16.04-x86_64 
            ^libpciaccess@0.13.5%intel@16.0.2 arch=linux-ubuntu16.04-x86_64 
                ^libtool@2.4.6%intel@16.0.2 arch=linux-ubuntu16.04-x86_64 
                    ^m4@1.4.18%intel@16.0.2 patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00 +sigsegv arch=linux-ubuntu16.04-x86_64 
                        ^libsigsegv@2.11%intel@16.0.2 arch=linux-ubuntu16.04-x86_64 
                ^util-macros@1.19.1%intel@16.0.2 arch=linux-ubuntu16.04-x86_64 
            ^libxml2@2.9.4%intel@16.0.2~python arch=linux-ubuntu16.04-x86_64 
                ^xz@5.2.3%intel@16.0.2 arch=linux-ubuntu16.04-x86_64 
```
Note that `libxml2` builds just fine with Intel 17.0.1 on another machine.


Discussion:
`LZMA_OK` gets defined in `lzma/base.h`, which part of `xz`.

So my guess it that `libxml2` picks up an old system header!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libxml2/package.py b/var/spack/repos/builtin/packages/libxml2/package.py
--- a/var/spack/repos/builtin/packages/libxml2/package.py
+++ b/var/spack/repos/builtin/packages/libxml2/package.py
@@ -48,12 +48,15 @@ class Libxml2(AutotoolsPackage):
 
     def configure_args(self):
         spec = self.spec
+
+        args = ["--with-lzma=%s" % spec['xz'].prefix]
+
         if '+python' in spec:
-            python_args = [
+            args.extend([
                 '--with-python={0}'.format(spec['python'].home),
                 '--with-python-install-dir={0}'.format(site_packages_dir)
-            ]
+            ])
         else:
-            python_args = ['--without-python']
+            args.append('--without-python')
 
-        return python_args
+        return args


Test patch: