Repository: spack/spack

Issue:
Installation issue: grass

[spack-build.txt](https://github.com/spack/spack/files/3131555/spack-build.txt)

`spack install grass ~opengl ~freetype`

```commandline
uname -a 
Linux edi 5.0.6-1.el7.elrepo.x86_64
```

Compiler: gcc@7.3.0
OS: Centos7.6

`spack spec --install-status grass`

<details>
<summary>Details</summary>

```
Input spec
--------------------------------
 -   grass

Concretized
--------------------------------
 -   grass@7.6.1%gcc@7.3.0~blas~bzlib+cairo+cxx+fftw+freetype~geos~lapack~mysql~netcdf~opencl+opengl~openmp+png~postgres~pthread~readline+regex+sqlite+tiff arch=linux-centos7-x86_64
[+]      ^bison@3.0.5%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^diffutils@3.7%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^help2man@1.47.8%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^gettext@0.19.8.1%gcc@7.3.0+bzip2+curses+git~libunistring+libxml2 patches=9acdb4e73f67c241b5ef32505c9ddf7cf6884ca8ea661692f21dca28483b04b8 +tar+xz arch=linux-centos7-x86_64
[+]                  ^bzip2@1.0.6%gcc@7.3.0+shared arch=linux-centos7-x86_64
[+]                  ^libxml2@2.9.8%gcc@7.3.0~python arch=linux-centos7-x86_64
[+]                      ^libiconv@1.15%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^pkgconf@1.6.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^xz@5.2.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^zlib@1.2.11%gcc@7.3.0+optimize+pic+shared arch=linux-centos7-x86_64
[+]                  ^ncurses@6.1%gcc@7.3.0~symlinks~termlib arch=linux-centos7-x86_64
[+]                  ^tar@1.31%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^perl@5.26.2%gcc@7.3.0+cpanm patches=0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac +shared+threads arch=linux-centos7-x86_64
[+]                  ^gdbm@1.18.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^readline@7.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^m4@1.4.18%gcc@7.3.0 patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-centos7-x86_64
[+]              ^libsigsegv@2.11%gcc@7.3.0 arch=linux-centos7-x86_64
[+]      ^cairo@1.16.0%gcc@7.3.0~X~pdf arch=linux-centos7-x86_64
[+]          ^fontconfig@2.12.3%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^font-util@1.3.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^util-macros@1.19.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^freetype@2.9.1%gcc@7.3.0 patches=08466355e8649235ff01f13b3e56bbd551c7cfb2ca97903cc11575c163ea32a3 arch=linux-centos7-x86_64
[+]                  ^libpng@1.6.34%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^gperf@3.0.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^glib@2.56.3%gcc@7.3.0~libmount patches=c325997b72a205ad1638bb3e3ba0e5b73e3d32ce63b2d0d3282f3e3a2ff4663c tracing=none arch=linux-centos7-x86_64
[+]              ^libffi@3.2.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^pcre@8.42%gcc@7.3.0~jit+multibyte+utf arch=linux-centos7-x86_64
[+]              ^python@2.7.16%gcc@7.3.0+bz2+ctypes+dbm+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter~ucs4~uuid+zlib arch=linux-centos7-x86_64
[+]                  ^expat@2.2.5%gcc@7.3.0+libbsd arch=linux-centos7-x86_64
[+]                      ^libbsd@0.9.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^openssl@1.1.1b%gcc@7.3.0+systemcerts arch=linux-centos7-x86_64
[+]                  ^sqlite@3.26.0%gcc@7.3.0~functions arch=linux-centos7-x86_64
[+]          ^pixman@0.38.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]      ^fftw@3.3.8%gcc@7.3.0+double+float~fma+long_double+mpi~openmp~pfft_patches~quad simd=avx,avx2,sse2 arch=linux-centos7-x86_64
[+]          ^openmpi@3.1.4%gcc@7.3.0~cuda+cxx_exceptions fabrics=auto ~java~legacylaunchers~memchecker~pmi schedulers=auto ~sqlite3~thread_multiple+vt arch=linux-centos7-x86_64
[+]              ^hwloc@1.11.11%gcc@7.3.0~cairo~cuda~gl+libxml2~nvml+pci+shared arch=linux-centos7-x86_64
[+]                  ^libpciaccess@0.13.5%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^libtool@2.4.6%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^numactl@2.0.12%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^autoconf@2.69%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^automake@1.16.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]      ^flex@2.6.4%gcc@7.3.0+lex patches=09c22e5c6fef327d3e48eb23f0d610dcd3a35ab9207f12e0f875701c677978d3 arch=linux-centos7-x86_64
[+]      ^gdal@2.3.3%gcc@7.3.0+armadillo+cfitsio+crypto+cryptopp+curl+expat+geos+gif~grib~hdf4~hdf5+jasper+java+jpeg~kea+libiconv+liblzma+libtool+libz+mdb+netcdf~odbc~opencl+openjpeg+pcre+perl+pg+png+poppler+proj+python+qhull+sosi+sqlite3+xerces+xml2+zstd arch=linux-centos7-x86_64
[+]          ^armadillo@8.100.1%gcc@7.3.0 build_type=RelWithDebInfo ~hdf5 patches=59207b14cd147b5e6e75f4d81f29f8371261c740d33401b2d30d8ca71ff30b87 arch=linux-centos7-x86_64
[+]              ^arpack-ng@3.7.0%gcc@7.3.0+mpi+shared arch=linux-centos7-x86_64
[+]                  ^cmake@3.14.2%gcc@7.3.0~doc+ncurses+openssl~ownlibs~qt arch=linux-centos7-x86_64
[+]                      ^curl@7.63.0%gcc@7.3.0~darwinssl~libssh~libssh2~nghttp2 arch=linux-centos7-x86_64
[+]                      ^libarchive@3.3.2%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                          ^lz4@1.9.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                          ^lzo@2.10%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                          ^nettle@3.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                              ^gmp@6.1.2%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^libuv@1.25.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                      ^rhash@1.3.5%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^openblas@0.3.5%gcc@7.3.0+avx2~avx512 cpu_target=auto ~ilp64+pic+shared threads=none ~virtual_machine arch=linux-centos7-x86_64
[+]              ^superlu@5.2.1%gcc@7.3.0+pic arch=linux-centos7-x86_64
[+]          ^cfitsio@3.450%gcc@7.3.0+bzip2+shared arch=linux-centos7-x86_64
[+]          ^cryptopp@7.0.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^gmake@4.2.1%gcc@7.3.0~guile+nls patches=ca60bd9c1a1b35bc0dc58b6a4a19d5c2651f7a94a4b22b2c5ea001a1ca7a8a7f,fe5b60d091c33f169740df8cb718bf4259f84528b42435194ffe0dd5b79cd125 arch=linux-centos7-x86_64
[+]          ^fyba@4.1.1%gcc@7.3.0 patches=de286550a880b139886e3312b78a7192189b20b72e23266ff5cd8e0c68fe2508 arch=linux-centos7-x86_64
[+]          ^geos@3.6.2%gcc@7.3.0~python~ruby arch=linux-centos7-x86_64
[+]          ^giflib@5.1.4%gcc@7.3.0 patches=5cc0447986963199fa6f382ce7ef55dd033344a92d2145277d3c1def8190d258 arch=linux-centos7-x86_64
[+]          ^jackcess@1.2.14.3%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^commons-lang@2.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^jdk@11.0.2_9%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^commons-logging@1.1.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^jasper@1.900.1%gcc@7.3.0 build_type=Release +jpeg~opengl patches=95a654159688eaffdf035a467914c5953068ad0fd62d18229de5779a17ec380b,db104400a2e72f610b8fa4d061a32282254819c70b024ef1cf99fef64aca67e3 +shared arch=linux-centos7-x86_64
[+]              ^libjpeg-turbo@1.5.90%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^nasm@2.13.03%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^json-c@0.13.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^libgeotiff@1.4.2%gcc@7.3.0+jpeg+proj+zlib arch=linux-centos7-x86_64
[+]              ^libtiff@4.0.9%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^proj@5.2.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^netcdf@4.6.3%gcc@7.3.0~dap~hdf4 maxdims=1024 maxvars=8192 +mpi~parallel-netcdf+pic+shared arch=linux-centos7-x86_64
[+]              ^hdf5@1.10.5%gcc@7.3.0~cxx~debug~fortran+hl+mpi+pic+shared~szip~threadsafe arch=linux-centos7-x86_64
[+]          ^openjpeg@2.3.0%gcc@7.3.0 build_type=RelWithDebInfo arch=linux-centos7-x86_64
[+]          ^poppler@0.72.0%gcc@7.3.0 build_type=RelWithDebInfo ~cairo~cms~glib~gobject~iconv~jpeg~libcurl~openjpeg~png~qt5~tiff~zlib arch=linux-centos7-x86_64
[+]              ^poppler-data@0.4.9%gcc@7.3.0 build_type=RelWithDebInfo arch=linux-centos7-x86_64
[+]          ^postgresql@11.2%gcc@7.3.0~client_only~gssapi lineedit=readline ~perl~python~tcl~threadsafe arch=linux-centos7-x86_64
[+]          ^py-numpy@1.16.2%gcc@7.3.0+blas+lapack arch=linux-centos7-x86_64
[+]              ^py-setuptools@40.8.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^qhull@2015.2%gcc@7.3.0 build_type=RelWithDebInfo patches=10ddc62a1600b0ede23fb0502e29dca389d18689fd8dfe7a849e3a989c0e607e arch=linux-centos7-x86_64
[+]          ^xerces-c@3.2.2%gcc@7.3.0 cxxstd=default transcoder=gnuiconv arch=linux-centos7-x86_64
[+]          ^zstd@1.4.0%gcc@7.3.0+pic arch=linux-centos7-x86_64
[+]      ^libx11@1.6.7%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^inputproto@2.3.2%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^kbproto@1.0.7%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^libxcb@1.13%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^libpthread-stubs@0.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^libxau@1.0.8%gcc@7.3.0 arch=linux-centos7-x86_64
[+]                  ^xproto@7.0.31%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^libxdmcp@1.1.2%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^xcb-proto@1.13%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^xextproto@7.3.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^xtrans@1.3.5%gcc@7.3.0 arch=linux-centos7-x86_64
[+]      ^mesa@18.1.2%gcc@7.3.0~hwrender~llvm+swrender arch=linux-centos7-x86_64
[+]          ^binutils@2.31.1%gcc@7.3.0+gold~headers~libiberty+nls~plugins arch=linux-centos7-x86_64
[+]          ^glproto@1.4.17%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^icu4c@60.1%gcc@7.3.0 cxxstd=11 arch=linux-centos7-x86_64
[+]          ^libxdamage@1.1.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^damageproto@1.2.1%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^fixesproto@5.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^libxfixes@5.0.2%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^libxext@1.3.3%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^libxshmfence@1.3%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^libxv@1.0.10%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^videoproto@2.3.3%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^libxvmc@1.0.9%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^presentproto@1.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^py-argparse@1.4.0%gcc@7.3.0 arch=linux-centos7-x86_64
[+]          ^py-mako@1.0.4%gcc@7.3.0 arch=linux-centos7-x86_64
[+]              ^py-markupsafe@1.0%gcc@7.3.0 arch=linux-centos7-x86_64


```


</details>


Discussion:
Looks like your error is here????:
```
: && /opt/spack/lib/spack/env/gcc/gcc -L/tmp/patrick/spack-stage/spack-stage-1t7Wm1/grass-7.6.1/dist.x86_64-pc-linux-gnu/lib -L/tmp/patrick/spack-stage/spack-stage-1t7Wm1/grass-7.6.1/dist.x86_64-pc-linux-gnu/lib -Wl,--export-dynamic -Wl,-rpath-link,/tmp/patrick/spack-stage/spack-stage-1t7Wm1/grass-7.6.1/dist.x86_64-pc-linux-gnu/lib -Wl,-soname,test -o OBJ.x86_64-pc-linux-gnu/test OBJ.x86_64-pc-linux-gnu/test.o    -lgrass_dig2.7.6  -lgrass_gis.7.6 -lgrass_rtree.7.6 -lm  -lm 
/tmp/patrick/spack-stage/spack-stage-1t7Wm1/grass-7.6.1/dist.x86_64-pc-linux-gnu/lib/libgrass_gis.7.6.so: undefined reference to `libiconv'
/tmp/patrick/spack-stage/spack-stage-1t7Wm1/grass-7.6.1/dist.x86_64-pc-linux-gnu/lib/libgrass_gis.7.6.so: undefined reference to `libiconv_open'
/tmp/patrick/spack-stage/spack-stage-1t7Wm1/grass-7.6.1/dist.x86_64-pc-linux-gnu/lib/libgrass_gis.7.6.so: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
```
What OS are you using?

Could your problem be the same as in #6962?

CentOS as stated above.

`glib` is not a dep of `grass`, `libiconv` is pulled in by `libxml2`.

However, the linked issue related to a `glib` issue that lacks `libiconv` support that was fixed in https://github.com/spack/spack/pull/10165.

`libxml2` is required in this build as far as I can see.

But thanks for looking into this here, highly appreciated!
It could be that `libiconv` from Spack conflicts with the `libiconv` support in `glib`: https://trac.osgeo.org/grass/ticket/2940
I was entertaining the idea of using system installation of libxml2 as a workaround via putting the following in ~/.spec/packages.yaml
```
  libxml2:
      paths:
        libxml2@2.9.4: /usr/lib
      buildable: False
```
at first glance this seems to be not working out of the box (giving pkg_config errors). 

P.S: with the latest dev version of spack, I was getting some concreatization errors, which I fixed via specifying certain dependency versions:
```
spack spec --install-status grass ~opengl ~freetype ^proj@5.2.0 ^gdal@2.4.1
```
mentioning this here just in case someone else is also trying to figure this out. 
Have you installed *libxml2-devel *from your yum?

https://centos.pkgs.org/7/centos-x86_64/libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm.html

On Sat, Jul 13, 2019 at 5:29 AM Sinan <notifications@github.com> wrote:

> I was entertaining the idea of using system installation of libxml2 as a
> workaround via putting the following in ~/.spec/packages.yaml
>
>   libxml2:
>       paths:
>         libxml2@2.9.4: /usr/lib
>       buildable: False
>
> at first glance this seems to be not working out of the box (giving
> pkg_config errors).
>
> P.S: with the latest dev version of spack, I was getting some
> concreatization errors, which I fixed via specifying certain dependency
> versions:
>
> spack spec --install-status grass ~opengl ~freetype ^proj@5.2.0 ^gdal@2.4.1
>
> mentioning this here just in case someone else is also trying to figure
> this out.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/spack/spack/issues/11325?email_source=notifications&email_token=AAOVY524AXRPILICV7FPVEDP7GN7VA5CNFSM4HJL4ZO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ3OAQA#issuecomment-511107136>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAOVY5ZYBNKNZD7UGSTNZJTP7GN7VANCNFSM4HJL4ZOQ>
> .
>

Yes, I installed the dev package (actually, I tried this on LinuxMint/Ubuntu)
Can you post your spack-build-out.txt file?

On Sat, Jul 13, 2019 at 14:23 Sinan <notifications@github.com> wrote:

> Yes, I installed the dev package (actually, I tried this on
> LinuxMint/Ubuntu)
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/spack/spack/issues/11325?email_source=notifications&email_token=AAOVY5YUICVXVLTCF454KD3P7IMQRA5CNFSM4HJL4ZO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ3W5EY#issuecomment-511143571>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAOVY55AZLIW5EZ6Q3KJ3F3P7IMQRANCNFSM4HJL4ZOQ>
> .
>

attached is the file. installation is failing during the compilation of the dependency `fontconfig`.
[spack-build-out.txt](https://github.com/spack/spack/files/3389432/spack-build-out.txt)
```
...
==> No patches needed for fontconfig
==> Building fontconfig [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Error: ProcessError: Command exited with status 1:
    '/var/spack/var/spack/stage/fontconfig-2.12.3-55ugie56mi4mv4st2wa6rmecjj4zmjfz/spack-src/configure' '--prefix=/var/spack/opt/spack/linux-linuxmint19-x86_64/gcc-8.2.0/fontconfig-2.12.3-55ugie56mi4mv4st2wa6rmecjj4zmjfz' '--enable-libxml2' '--disable-docs' '--with-default-fonts=/var/spack/opt/spack/linux-linuxmint19-x86_64/gcc-8.2.0/font-util-1.3.1-3stprvkzrninillnvpzv4dcujn4niepi/share/fonts'

1 error found in build log:
     164    checking for FT_Get_X11_Font_Format... yes
     165    checking for FT_Select_Size... yes
     166    checking for FT_Bitmap_Size.y_ppem... yes
     167    checking for TT_OS2.usLowerOpticalPointSize... yes
     168    checking for TT_OS2.usUpperOpticalPointSize... yes
     169    checking for LIBXML2... no
  >> 170    configure: error: Package requirements (libxml-2.0 >= 2.6) were not met:
     171    
     172    Package 'libxml-2.0', required by 'virtual:world', not found
     173    
     174    Consider adjusting the PKG_CONFIG_PATH environment variable if you
     175    installed software in a non-standard prefix.
     176    

See build log for details:
  /var/spack/var/spack/stage/fontconfig-2.12.3-55ugie56mi4mv4st2wa6rmecjj4zmjfz/spack-build-out.txt
```

> I was getting some concreatization errors,

What helped for me was 

`spack install grass@7.4.4 ^libgeotiff@1.2.1` 

but I am running into `libiconv` errors later on.
I think this is related to https://trac.osgeo.org/grass/ticket/2940

It looks like we need to patch the makefile from `ICONVLIB = ` to `ICONVLIB = -liconv`.

@pat-s @Sinan81 could one of y'all try that out and see whether it works?
@becker33 will do in few days. Thanks!
I am not familiar enough with Spack at the moment to implement this change quickly. 
It would be highly appreciated if someone could tackle this. 
Added the following code to the very end of the package file for grass. And it seems now grass compiles (tested on Centos so far!). Will push a PR soon.
```python
    def fix_iconv_linking(self):
        makefile = FileFilter('include/Make/Platform.make')
        makefile.filter('^ICONVLIB\s*=\s*', 'ICONVLIB = -liconv')
        return None

    run_after('configure')(fix_iconv_linking)
```

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/grass/package.py b/var/spack/repos/builtin/packages/grass/package.py
--- a/var/spack/repos/builtin/packages/grass/package.py
+++ b/var/spack/repos/builtin/packages/grass/package.py
@@ -195,3 +195,12 @@ def configure_args(self):
             args.append('--without-geos')
 
         return args
+
+    # see issue: https://github.com/spack/spack/issues/11325
+    # 'Platform.make' is created after configure step
+    # hence invoke the following function afterwards
+    @run_after('configure')
+    def fix_iconv_linking(self):
+        makefile = FileFilter('include/Make/Platform.make')
+        makefile.filter(r'^ICONVLIB\s*=\s*', 'ICONVLIB = -liconv')
+        return None


Test patch: