Repository: spack/spack

Issue:
Installation issue: gcc@4.8.5 Failed to find suitable config.guess in Arm machine
Hello, I am trying to install gcc 3.8.5 and it dails at the moment of compiling `pkgconf` complaining about the `config.guess` script:

     $ spack install gcc@4.8.5

I get:

     ...
     .../spack/lib/spack/spack/build_systems/autotools.py:154, in 
     do_patch_config_guess:
               151                return
               152            except Exception as e:
               153                tty.debug(e)
         >>    154
               155        raise RuntimeError('Failed to find suitable config.guess')
      ...

The `spack-build-out.txt` says:

     ==> 47811: pkgconf: Executing phase: 'autoreconf'
     ==> [2020-06-17-09:37:54.996860, 47818] FileNotFoundError: [Errno 2] No such file or directory: 'config.guess': 'config.guess'

In the directory `/tmp/.../spack-stage/spack-stage-pkgconf-1.7.3-wzqfkxjzvw2b4soe2pkpoyhqwi6c3bkk/spack-src` the script `config.guess` is present.

Now if I try to install `pkgconf@1.7.3`:

     $ spack install pkgconf@1.7.3
 
I have another message at the beginning:

    sh: 0: getcwd() failed: No such file or directory
 
and after I get the same message as before:
   
     ...
     ==> 47811: pkgconf: Executing phase: 'autoreconf'
     ==> Error: RuntimeError: Failed to find suitable config.guess

     ...
     .../spack/lib/spack/spack/build_systems/autotools.py:154, in 
     do_patch_config_guess:
               151                return
               152            except Exception as e:
               153                tty.debug(e)
         >>    154
               155        raise RuntimeError('Failed to find suitable config.guess')
        ...

- [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
- [ ] 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

* **Spack:** 0.14.2-1442-e28561241
* **Python:** 3.6.9
* **Platform:** linux-ubuntu18.04-aarch64
* **Maintainers:** @michaelkuhn




Discussion:
I  actually had some problems at OLCF because the Spack autotools logic couldn't find a suitable config.guess. And  like you, in my case there was in fact a perfectly fine `config.guess`  provided by the system and and in the Spack tree. I ended up modifying build_systems/autotools.py to use a hardcoded path to config.guess. Obviously that's not a sustainable solution. 

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
@@ -118,13 +118,15 @@ def _do_patch_config_files(self):
             config_file = 'config.{0}'.format(config_name)
             if os.path.exists(config_file):
                 # First search the top-level source directory
-                my_config_files[config_name] = config_file
+                my_config_files[config_name] = os.path.join(
+                    self.configure_directory, config_file)
             else:
                 # Then search in all sub directories recursively.
                 # We would like to use AC_CONFIG_AUX_DIR, but not all packages
                 # ship with their configure.in or configure.ac.
                 config_path = next((os.path.join(r, f)
-                                    for r, ds, fs in os.walk('.') for f in fs
+                                    for r, ds, fs in os.walk(
+                                        self.configure_directory) for f in fs
                                     if f == config_file), None)
                 my_config_files[config_name] = config_path
 


Test patch: