Repository: spack/spack

Issue:
swig 3.0.11 failed to build while taking 40Gb of space
subj. 


```
==> Installing swig
==> pcre is already installed in /Users/davydden/spack/opt/spack/darwin-sierra-x86_64/clang-8.0.0-apple/pcre-8.39-nhyefptcom4ey5zjjnyot7no7f6gx67z
==> Fetching http://prdownloads.sourceforge.net/swig/swig-3.0.11.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/davydden/spack/var/spack/stage/swig-3.0.11-iynexulzro2dthcxcsuum3fscpjucvi5/swig-3.0.11.tar.gz
==> Created stage in /Users/davydden/spack/var/spack/stage/swig-3.0.11-iynexulzro2dthcxcsuum3fscpjucvi5
==> Ran patch() for swig
==> Building swig [AutotoolsPackage]
==> Executing phase : 'autoreconf'
==> Executing phase : 'configure'
Process logger_daemon:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/davydden/spack/lib/spack/llnl/util/tty/log.py", line 199, in _spawn_writing_daemon
    log_file.flush()
IOError: [Errno 28] No space left on device
```


Discussion:
switching back from `AutotoolsPackage` to `Package` solved the issue, must be related to `autoreconf` phase, as I don't see what else is different between the above and 

```
==> Building swig [Package]
==> Executing phase : 'install'
==> Successfully installed swig
  Fetch: 0.03s.  Build: 31.82s.  Total: 31.85s.
```

@alalazo ping.

p.s. other `Autotools` packages work fine, e.g.
```
==> Building graphviz [AutotoolsPackage]
==> Executing phase : 'autoreconf'
==> Executing phase : 'configure'
==> Executing phase : 'build'
==> Executing phase : 'install'
==> Successfully installed graphviz
  Fetch: 0.09s.  Build: 2m 37.02s.  Total: 2m 37.11s.
```
@davydden I am not able to reproduce the issue on Ubuntu 14.04.

I don't think it's related to `autoreconf`, as:
  1. it is  a no-op for swig
  2. if `configure` was not there it would trigger an exception as swig does not depend on `autoconf`, `automake`, etc.

I assume the behavior is deterministic on MacOS. Can you check what happens during configure and the size of `build.out` (just a wild guess)?

EDIT: just to have a reference on my Ubuntu `build.out` is 289K.
> I assume the behavior is deterministic on MacOS. Can you check what happens during configure and the size of build.out (just a wild guess)?

unfortunately i have only one mac around that I use for work on daily basis, thereby I can't do it immediately. I probably should have saved the `build.out` before wiping 40Gb stage folder which ate all free space. Maybe i leave it to hang overnight and try to get `build.out`.
> Maybe i leave it to hang overnight and try to get build.out.

I don't think it's necessary. I was just randomly guessing what could go wrong, because at the moment it doesn't seem anything obvious.
I've definitely seen a build.out eat up the filesystem before. I was installing something and the configuration wasn't right so it ended up indefinitely printing a warning message until I ran out of space. 
just tried to reproduce it and i cant:
```
$ spack install swig@3.0.10
==> Installing swig
==> pcre is already installed in /Users/davydden/spack/opt/spack/darwin-sierra-x86_64/clang-8.0.0-apple/pcre-8.39-nhyefptcom4ey5zjjnyot7no7f6gx67z
==> Using cached archive: /Users/davydden/spack/var/spack/cache/swig/swig-3.0.10.tar.gz
==> Staging archive: /Users/davydden/spack/var/spack/stage/swig-3.0.10-7jnb2aaxy44jiizfd3hx2t3fbr4oywzl/swig-3.0.10.tar.gz
==> Created stage in /Users/davydden/spack/var/spack/stage/swig-3.0.10-7jnb2aaxy44jiizfd3hx2t3fbr4oywzl
==> Ran patch() for swig
==> Building swig [AutotoolsPackage]
==> Executing phase : 'autoreconf'
==> Executing phase : 'configure'
==> Executing phase : 'build'
==> Executing phase : 'install'
==> Warning: Module file already exists : skipping creation
file : /Users/davydden/spack/share/spack/modules/darwin-sierra-x86_64/swig-3.0.10-clang-8.0.0-apple-7jnb2aa
spec : swig@3.0.10%clang@8.0.0-apple arch=darwin-sierra-x86_64 ^pcre@8.39%clang@8.0.0-apple+utf arch=darwin-sierra-x86_64
==> Warning: Module file already exists : skipping creation
file : /Users/davydden/spack/share/spack/dotkit/darwin-sierra-x86_64/swig-3.0.10-clang-8.0.0-apple-7jnb2aa.dk
spec : swig@3.0.10%clang@8.0.0-apple arch=darwin-sierra-x86_64 ^pcre@8.39%clang@8.0.0-apple+utf arch=darwin-sierra-x86_64
==> Successfully installed swig
```
Now idea what was going on but I close this with the hope that I won't see the issue again
I can confirm that I had the same issue on MacOS - it chewed up all of my disc space. It seems like it tried to configure the examples and generated an enormous makefile for one example in the `android` directory.
```
<path>/spack-stage/spack-stage-kQqtoQ/swig-3.0.10/Examples/android/class$ ls -l
total 6503432
-rw-r--r--  1 <user>  staff         611 Jun 12  2016 AndroidManifest.xml
-rw-r--r--  1 <user>  staff  3329729255 Feb 22 12:01 Makefile
-rw-r--r--  1<user>  staff         696 Jun 12  2016 ant.properties
...
```
Its contents are basically a repetition of
```
spack-stage/spack-stage-kQqtoQ/swig-3.0.10/Examples/android/class$ cat Makefile
...
# DO NOT EDIT: instead edit ../../..//Users/<local_path>/spack/var/spack/stage/swig-3.0.^Cjp/Programs/GitHub/Spack/spack/var/spack/stage/swig-3.0.10-66gmnzsnvkqikyk7xecaeuklcm7t6pu7/swig-3.0.10/Examples//android/class/Makefile
# and run (cd ../../../ && ./config.status) to regenerate
TOP_BUILDDIR_TO_TOP_SRCDIR = /Users/<local_path>/spack/var/spack/stage/swig-3.0.10-66gmnzsnvkqikyk7xecaeuklcm7t6pu7/swig-3.0.10/
SRCDIR = ../../..//Users/<local_path>/spack/var/spack/stage/swig-3.0.10-66gmnzsnvkqikyk7xecaeuklcm7t6pu7/swig-3.0.10/Examples//android/class/
```
(Note: In case its important, I've been careful to preserve the path names exactly)
[Log file attached](https://github.com/LLNL/spack/files/793123/spack-build.out.txt)


The problem was fixed by temporarily reverting to the old package.
I now see this problem with `swig@3.0.12` that I tried to add. I have `swig@3.0.11` installed and saw no problems there.
@eschnett does reverting to `Package` helps?
I confirm things are working when I switch to `Package`, and with a trivial `install` method:
```
    def install(self, spec, prefix):
        configure("--prefix=%s" % prefix)
        make()
        make("install")
```

The issue seems to be that the directory mentioned above (`Examples/android/class`) already contains a `Makefile` that is then overwritten by Spack. There is, however, no `Makefile.in` -- this is clearly a hand-written `Makefile`. Other `Makefile`s in the `Examples` subtree look similar.

I assume this is a case where a blanket `autoreconf` simply does the wrong thing.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/swig/package.py b/var/spack/repos/builtin/packages/swig/package.py
--- a/var/spack/repos/builtin/packages/swig/package.py
+++ b/var/spack/repos/builtin/packages/swig/package.py
@@ -36,14 +36,17 @@ class Swig(AutotoolsPackage):
        application."""
 
     homepage = "http://www.swig.org"
-    url      = "http://prdownloads.sourceforge.net/swig/swig-3.0.8.tar.gz"
+    url      = "http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz"
 
+    version('3.0.12', '82133dfa7bba75ff9ad98a7046be687c')
     version('3.0.11', '13732eb0f1ab2123d180db8425c1edea')
     version('3.0.10', 'bb4ab8047159469add7d00910e203124')
-    version('3.0.8', 'c96a1d5ecb13d38604d7e92148c73c97')
-    version('3.0.2', '62f9b0d010cef36a13a010dc530d0d41')
+    version('3.0.8',  'c96a1d5ecb13d38604d7e92148c73c97')
+    version('3.0.2',  '62f9b0d010cef36a13a010dc530d0d41')
     version('2.0.12', 'c3fb0b2d710cc82ed0154b91e43085a4')
-    version('2.0.2', 'eaf619a4169886923e5f828349504a29')
+    version('2.0.2',  'eaf619a4169886923e5f828349504a29')
     version('1.3.40', '2df766c9e03e02811b1ab4bba1c7b9cc')
 
     depends_on('pcre')
+
+    build_directory = 'spack-build'


Test patch: