Repository: spack/spack

Issue:
ppc64le:  spack install xextproto fails due to old config.guess and config.sub files
I"m trying to build spack on a power 8 cluster and I'm getting the error below due to the old config.guess and config.sub files that don't have information about the ppc64le platform.

The source for this package hasn't been touched for several years.
I guess the only way to fix this is to create a patch that replaces the config.guess and config.sub configuration files.

I can do the patch, if people agree and there is not another fix that I'm not seeing.
Thanks,
Jim G
```
cat -n /tmp/jeg/spack-stage/spack-stage-82EJxv/xextproto-7.3.0/spack-build.out

   44	This script, last modified 2009-12-30, has failed to recognize
    45	the operating system you are using. It is advised that you
    46	download the most up to date version of the config scripts from
    47	
    48	  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
    49	and
    50	  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
    51	
    52	If the version you run (/home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o/xextproto-7.3.0/config.guess) is already up to date, please
    53	send the following data and any information you think might be
    54	pertinent to <config-patches@gnu.org> in order to provide the needed
    55	information to handle your system.
    56	
    57	config.guess timestamp = 2009-12-30
    58	
    59	uname -m = ppc64le
    60	uname -r = 3.10.0-514.21.2.el7.ppc64le
    61	uname -s = Linux
    62	uname -v = #1 SMP Tue Jun 20 16:35:48 GMT 2017
    63	
    64	/usr/bin/uname -p = ppc64le
    65	/bin/uname -X     = 
    66	
    67	hostinfo               = 
    68	/bin/universe          = 
    69	/usr/bin/arch -k       = 
    70	/bin/arch              = ppc64le
    71	/usr/bin/oslevel       = 
    72	/usr/convex/getsysinfo = 
    73	
    74	UNAME_MACHINE = ppc64le
    75	UNAME_RELEASE = 3.10.0-514.21.2.el7.ppc64le
    76	UNAME_SYSTEM  = Linux
    77	UNAME_VERSION = #1 SMP Tue Jun 20 16:35:48 GMT 2017
    78	configure: error: cannot guess build type; you must specify one
```


Discussion:
Are you using `AutotoolsPackage`? What OS? `_do_patch_config_guess` should do this automatically. @lee218llnl 
Hopefully you've done a git pull somewhat recently. The config.guess patch should be done automatically. The exception is if it is in a subpackage and spack doesn't find it. In that case, I think the best solution is just manually copying a more recent config.guess into var/spack/stage/... and rerunning the install.
Yes, I did just before I built on this power 8 cluster.
Maybe I didn't get the updated sources like I thought.  I will try again.
This is the package source for xextproto: (it is AutotoolsPackage)
from spack import *
class Xextproto(AutotoolsPackage):
    """X Protocol Extensions."""

    homepage = "http://cgit.freedesktop.org/xorg/proto/xextproto"
    url      = "https://www.x.org/archive/individual/proto/xextproto-7.3.0.tar.gz"

    version('7.3.0', '37b700baa8c8ea7964702d948dd13821')

    depends_on('pkg-config@0.9.0:', type='build')
    depends_on('util-macros', type='build')

   paralleo= False


@jgalarowicz I just did a pull of develop and was able to install the xextproto package on a PPC64LeE system. I also confirmed that the config.guess included in the source tar ball is indeed to old to detect the platform, but Spack should automatically detect this and replace it with a newer config.guess. Can you make sure you aren't picking up a staged folder?
@lee218llnl I attached a file that shows a "git pull upstream develop" command and then the failure after trying to install.

[power8_xextproto.txt](https://github.com/LLNL/spack/files/1250208/power8_xextproto.txt)

@jgalarowicz I also see this in your output:

==> Already staged xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o in /home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o

Can you remove that directory and rebuild. Also, please make sure you are on the develop branch.
@lee218llnl This is what I'm seeing:
See build log for details:
  /tmp/jeg/spack-stage/spack-stage-bVndsS/xextproto-7.3.0/spack-build.out
[jeg@p8-node packages]$ rm -rf /home/jeg/spack/var/spack/cache/xextproto/xextproto-7.3.0.tar.gz
[jeg@p8-node packages]$ rm -rf /home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o/xextproto-7.3.0.tar.gz
[jeg@p8-node packages]$ rm -rf /home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o
[jeg@p8-node packages]$ spack install openspeedshop
==> flex is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/flex-2.6.4-skx72if6qe7lfx7fxkrsv4xze5yqfmme
==> libtool is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/libtool-2.4.6-37ahgf7zyhrf7pumvrw4knfrhhyrhc6g
==> cmake is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/cmake-3.9.0-tyxqnvgjtjhmfnorho6mqakfmgugft4r
==> freetype is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/freetype-2.7.1-3thidjv3yxs7ric2arus3to2exnnolss
==> kbproto is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/kbproto-1.0.7-zfv74oeykbkkvulxx2t7lyjw5duc66jz
==> util-macros is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/util-macros-1.19.1-imyaktcwkmm6opd3w4gh6kmbptury5bs
==> pkg-config is already installed in /home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/pkg-config-0.29.2-la6vhvtxv46nablpxullwu5ek6rxrld4
==> Installing xextproto
==> Fetching https://www.x.org/archive/individual/proto/xextproto-7.3.0.tar.gz
######################################################################## 100.0%
==> Staging archive: /home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o/xextproto-7.3.0.tar.gz
==> Created stage in /home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o
==> No patches needed for xextproto
==> Building xextproto [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Error: ProcessError: Command exited with status 1:
    '/home/jeg/spack/var/spack/stage/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o/xextproto-7.3.0/configure' '--prefix=/home/jeg/spack/opt/spack/linux-centos7-ppc64le/gcc-4.8.5/xextproto-7.3.0-v6t66lknzc5gb66hy5guqvraldd7ql6o'

1 errors in build log:
     [ ... ]
     74    /usr/convex/getsysinfo =
     75    
     76    UNAME_MACHINE = ppc64le
     77    UNAME_RELEASE = 3.10.0-514.21.2.el7.ppc64le
     78    UNAME_SYSTEM  = Linux
     79    UNAME_VERSION = #1 SMP Tue Jun 20 16:35:48 GMT 2017
  >> 80    configure: error: cannot guess build type; you must specify one

See build log for details:
  /tmp/jeg/spack-stage/spack-stage-fyjQfS/xextproto-7.3.0/spack-build.out
[jeg@p8-node packages]$ 

@jgalarowicz Sorry, but can you grab me one more diagnostic and run `ls -ld /usr/share/automake*` or `rpm -q automake`. Spack's patching looks for config.guess in the automake directory and I believe the necessary config.guess for PPC64LE is in automake 1.13.
@lee218llnl I attached a file with the requested output.   Seems like the information should be in the config files on the system.

[automake.txt](https://github.com/LLNL/spack/files/1250358/automake.txt)

@lee218llnl 
[jeg@p8-node usr]$ 
[jeg@p8-node usr]$ grep ppc64le /usr/./share/automake-1.13/config.guess
    ppc64le:Linux:*:*)
[jeg@p8-node usr]$ grep ppc64le /usr/./share/automake-1.13/config.sub
	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
	ppc64le-* | powerpc64little-*)
[jeg@p8-node usr]$ 

@jgalarowicz that's odd, this version should work. You may want to peek at lib/spack/spack/build_systems/autotools.py and instrument the _do_patch_config_guess routine with some print statements to see if/why it is failing to patch the config.guess with the one on /usr/share/automake-1.13.
@lee218llnl yes, I will do that.  It is also failing on xproto as well as xextproto
@lee218llnl That routine returns right away.

   def _do_patch_config_guess(self):
        """Some packages ship with an older config.guess and need to have
        this updated when installed on a newer architecture. In particular,
        config.guess fails for PPC64LE for version prior to a 2013-06-10
        build date (automake 1.13.4)."""

        print ("DEBUG: in _do_patch_config_guess=:")
        if not self.patch_config_guess or not self.spec.satisfies(
                'arch=linux-rhel7-ppc64le'
        ):
            print ("DEBUG: in _do_patch_config_guess=: RETURN EARLY-1")
            return
        my_config_guess = None

The output:
[jeg@p8-node spack]$ cat /tmp/jeg/spack-stage/spack-stage-wN3YuE/xproto-7.0.31/spack-build.out
==> Executing phase: 'autoreconf'
DEBUG: in _do_patch_config_guess=:
DEBUG: in _do_patch_config_guess=: RETURN EARLY-1
==> Executing phase: 'configure'
==> '/home/jeg/spack/var/spack/stage/xproto-7.0.31-ml73l5ga7z6kyf24
@jgalarowicz can you run `spack arch` and send the output? patch_config_guess should be set to True, so I'm guessing that arch is not "linux-rhel7-ppc64le" on your system, so maybe we need to add another condition in there for your arch. 
@lee218llnl [jeg@p8-node spack]$ spack arch
linux-centos7-ppc64le

OK, then the appropriate fix will probably look something like this:

        if not self.patch_config_guess or not (self.spec.satisfies(
                'arch=linux-rhel7-ppc64le') or self.spec.satisfies(
                'arch=linux-centos7-ppc64le'
        ):
@lee218llnl That is working - just need another ')' character before the colon.
@lee218llnl Hi Greg,   should I do a pull request for this or do you want to?
I can do it

Resolving patch:
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py
--- a/lib/spack/spack/build_systems/autotools.py
+++ b/lib/spack/spack/build_systems/autotools.py
@@ -103,7 +103,7 @@ def _do_patch_config_guess(self):
         build date (automake 1.13.4)."""
 
         if not self.patch_config_guess or not self.spec.satisfies(
-                'arch=linux-rhel7-ppc64le'
+                'target=ppc64le'
         ):
             return
         my_config_guess = None


Test patch: