Repository: spack/spack

Issue:
gmp build error due to libtoolize / glibtoolize
Summary

I'm trying to build gcc on a mac (darwin) and it fails by looking for libtoolize, while only glibtoolize exists.  This appears to be related to the recent commits on the lilbtool build.  This error occurs with the version of spack pulled from github today.


### Actual Result
[tagardi@s1002808: spack]$ spack install gcc languages=c,c++,fortran,objc
==> Installing libsigsegv
==> Fetching https://ftp.gnu.org/gnu/libsigsegv/libsigsegv-2.11.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/libsigsegv-2.11-5rjv56uui3crfmsgsqgqab52yfhr6t4b/libsigsegv-2.11.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/libsigsegv-2.11-5rjv56uui3crfmsgsqgqab52yfhr6t4b
==> No patches needed for libsigsegv
==> Building libsigsegv [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed libsigsegv
  Fetch: 1.40s.  Build: 9.01s.  Total: 10.40s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/libsigsegv-2.11-5rjv56uui3crfmsgsqgqab52yfhr6t4b
==> Installing m4
==> Fetching https://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/m4-1.4.18-eqbzieloqiwxfe4drksmekvfqia7mqbu/m4-1.4.18.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/m4-1.4.18-eqbzieloqiwxfe4drksmekvfqia7mqbu
==> Applied patch gnulib-pgi.patch
==> Building m4 [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed m4
  Fetch: 2.70s.  Build: 54.10s.  Total: 56.80s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/m4-1.4.18-eqbzieloqiwxfe4drksmekvfqia7mqbu
==> pkgconf is already installed in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/pkgconf-1.4.0-pnl2wwjvk3nrdsl5nt34vssaduo6znhv
==> ncurses is already installed in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/ncurses-6.0-d6qx6anvxhhhb6tcqa5do4phgxjptfib
==> Installing readline
==> Fetching https://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/readline-7.0-hbgnos7jil6bpshxknah6fwfvdq4p4un/readline-7.0.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/readline-7.0-hbgnos7jil6bpshxknah6fwfvdq4p4un
==> No patches needed for readline
==> Building readline [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed readline
  Fetch: 3.53s.  Build: 14.53s.  Total: 18.06s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/readline-7.0-hbgnos7jil6bpshxknah6fwfvdq4p4un
==> Installing gdbm
==> Fetching http://ftp.gnu.org/gnu/gdbm/gdbm-1.14.1.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/gdbm-1.14.1-kvqsm4ij7bnu7ybqxeehytivvetsocot/gdbm-1.14.1.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/gdbm-1.14.1-kvqsm4ij7bnu7ybqxeehytivvetsocot
==> No patches needed for gdbm
==> Building gdbm [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed gdbm
  Fetch: 1.12s.  Build: 14.39s.  Total: 15.51s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/gdbm-1.14.1-kvqsm4ij7bnu7ybqxeehytivvetsocot
==> Installing perl
==> Fetching http://www.cpan.org/src/5.0/perl-5.24.1.tar.gz
######################################################################## 100.0%
==> Fetching http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7042.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/perl-5.24.1.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/resource-cpanm-isjeesiw74rb26pbfxghiwaxbppyjr27/App-cpanminus-1.7042.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/resource-cpanm-isjeesiw74rb26pbfxghiwaxbppyjr27
==> Moving resource stage
	source : /Users/tagardi/opt/spack/var/spack/stage/resource-cpanm-isjeesiw74rb26pbfxghiwaxbppyjr27/App-cpanminus-1.7042/
	destination : /Users/tagardi/opt/spack/var/spack/stage/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/perl-5.24.1/cpanm/cpanm
==> No patches needed for perl
==> Building perl [Package]
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/c2ph
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/corelist
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/cpan
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/cpanm
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/enc2xs
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/encguess
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/h2ph
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/h2xs
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/instmodsh
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/json_pp
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/libnetcfg
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/perlbug
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/perldoc
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/perlivp
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/piconv
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/pl2pm
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/pod2html
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/pod2man
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/pod2text
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/pod2usage
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/podchecker
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/podselect
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/prove
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/ptar
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/ptardiff
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/ptargrep
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/shasum
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/splain
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/xsubpp
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27/bin/zipdetails
==> Successfully installed perl
  Fetch: 9.78s.  Build: 2m 31.89s.  Total: 2m 41.67s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/perl-5.24.1-isjeesiw74rb26pbfxghiwaxbppyjr27
==> Installing autoconf
==> Fetching http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/autoconf-2.69.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo
==> Ran patch() for autoconf
==> Building autoconf [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/bin/autoheader
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/bin/autom4te
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/bin/autoreconf
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/bin/autoscan
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/bin/autoupdate
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo/bin/ifnames
==> Successfully installed autoconf
  Fetch: 2.26s.  Build: 6.37s.  Total: 8.63s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/autoconf-2.69-hqnzhqlvotxg6r7vgrbyybbjsexmpujo
==> Installing automake
==> Fetching http://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/automake-1.15.1-n2jcu5n5rxlwsg6xmbrb55pegifehbk6/automake-1.15.1.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/automake-1.15.1-n2jcu5n5rxlwsg6xmbrb55pegifehbk6
==> Ran patch() for automake
==> Building automake [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/automake-1.15.1-n2jcu5n5rxlwsg6xmbrb55pegifehbk6/bin/aclocal
==> Warning: Patched overlong shebang in /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/automake-1.15.1-n2jcu5n5rxlwsg6xmbrb55pegifehbk6/bin/automake
==> Successfully installed automake
  Fetch: 2.50s.  Build: 6.22s.  Total: 8.72s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/automake-1.15.1-n2jcu5n5rxlwsg6xmbrb55pegifehbk6
==> Installing libtool
==> Fetching http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/libtool-2.4.6-lcjvxlym37f7hwok3hlmzeby6kim7x2f/libtool-2.4.6.tar.gz
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/libtool-2.4.6-lcjvxlym37f7hwok3hlmzeby6kim7x2f
==> No patches needed for libtool
==> Building libtool [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed libtool
  Fetch: 3.45s.  Build: 16.09s.  Total: 19.54s.
[+] /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/libtool-2.4.6-lcjvxlym37f7hwok3hlmzeby6kim7x2f
==> Installing gmp
==> Fetching https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2
######################################################################## 100.0%
==> Staging archive: /Users/tagardi/opt/spack/var/spack/stage/gmp-6.1.2-6sa3bg2dw4bwaw63abtpnfuwlsrqcd6l/gmp-6.1.2.tar.bz2
==> Created stage in /Users/tagardi/opt/spack/var/spack/stage/gmp-6.1.2-6sa3bg2dw4bwaw63abtpnfuwlsrqcd6l
==> No patches needed for gmp
==> Building gmp [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Error: ProcessError: /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/libtool-2.4.6-lcjvxlym37f7hwok3hlmzeby6kim7x2f/bin/libtoolize: No such file or directory
    Command: '/Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/libtool-2.4.6-lcjvxlym37f7hwok3hlmzeby6kim7x2f/bin/libtoolize'
See build log for details:
  /Users/tagardi/opt/spack/var/spack/stage/gmp-6.1.2-6sa3bg2dw4bwaw63abtpnfuwlsrqcd6l/gmp-6.1.2/spack-build.out


[tagardi@s1002808: spack]$ ls /Users/tagardi/opt/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/libtool-2.4.6-lcjvxlym37f7hwok3hlmzeby6kim7x2f/bin/
glibtool    glibtoolize


### Steps to reproduce the issue

On a darwin system:

```console
$ spack install gcc
```

### Information on your system

This problem occurs on OS X El Capitan, version 10.11.6 with a clean checkout of spack.




Discussion:
Hm. Well, this was my doing (twice).

The motivation for installing `libtool{ize}` as `glibtool{ize}` comes from https://github.com/Homebrew/homebrew-core/blob/master/Formula/libtool.rb. OS X has BSD libtool installed, and installing GNU libtool binaries in `libtool{ize}` can sometimes result in linking errors when building other software (e.g., `ld: warning: file was built for archive which is not the architecture being linked (x86_64)`) because the GNU version shadows the BSD version. Unfortunately, this issue seems to be package-dependent -- I ran into this error with `subversion` in #7071.

Looking at https://github.com/Homebrew/homebrew-core/blob/master/Formula/gmp.rb, if you're trying to build GCC with clang from Apple, I'd first try dropping the libtool dependency `when='platform=darwin'`. If that's not what you're trying to do, let me know.
I am trying to build gcc using the clang compiler from Apple.  If I understand correctly, you're suggesting that I modify the libtool/package.py and remove the when('platform=darwin') section that adds the 'g' to the program prefix?
Alternatively, if homebrew is installing libtool{ize} as glibtool{ize}, then doesn't this imply that there's a mechanism to get the gmp build to invoke glibtoolize?

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libtool/package.py b/var/spack/repos/builtin/packages/libtool/package.py
--- a/var/spack/repos/builtin/packages/libtool/package.py
+++ b/var/spack/repos/builtin/packages/libtool/package.py
@@ -56,13 +56,15 @@ def setup_dependent_package(self, module, dependent_spec):
         for name in executables:
             setattr(module, name, self._make_executable(name))
 
-    @when('platform=darwin')
-    def configure_args(self):
+    @run_after('install')
+    def post_install(self):
         # Some platforms name GNU libtool and GNU libtoolize
         # 'glibtool' and 'glibtoolize', respectively, to differentiate
         # them from BSD libtool and BSD libtoolize. On these BSD
         # platforms, build systems sometimes expect to use the assumed
         # GNU commands glibtool and glibtoolize instead of the BSD
         # variant; this happens frequently, for instance, on Darwin
-        args = ['--program-prefix=g']
-        return args
+        symlink(join_path(self.prefix.bin, 'libtool'),
+                join_path(self.prefix.bin, 'glibtool'))
+        symlink(join_path(self.prefix.bin, 'libtoolize'),
+                join_path(self.prefix.bin, 'glibtoolize'))


Test patch: