2016-12-27 16:17:12 +08:00
|
|
|
##############################################################################
|
|
|
|
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
|
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
|
|
|
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
|
|
|
# For details, see https://github.com/llnl/spack
|
|
|
|
# Please also see the LICENSE file for our notice and the LGPL.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License (as
|
|
|
|
# published by the Free Software Foundation) version 2.1, February 1999.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
# conditions of the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
##############################################################################
|
2014-10-09 12:59:47 +08:00
|
|
|
from spack import *
|
|
|
|
|
2014-11-06 01:54:43 +08:00
|
|
|
from contextlib import closing
|
|
|
|
from glob import glob
|
2016-02-13 01:51:43 +08:00
|
|
|
import sys
|
2016-10-03 09:54:43 +08:00
|
|
|
from os.path import isfile
|
2016-05-15 13:35:55 +08:00
|
|
|
|
2014-11-06 01:54:43 +08:00
|
|
|
|
2014-10-09 12:59:47 +08:00
|
|
|
class Gcc(Package):
|
|
|
|
"""The GNU Compiler Collection includes front ends for C, C++,
|
|
|
|
Objective-C, Fortran, and Java."""
|
|
|
|
homepage = "https://gcc.gnu.org"
|
|
|
|
|
2016-08-23 08:26:54 +08:00
|
|
|
url = "http://ftp.gnu.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2"
|
|
|
|
list_url = 'http://ftp.gnu.org/gnu/gcc/'
|
2014-11-06 01:54:43 +08:00
|
|
|
list_depth = 2
|
|
|
|
|
2016-12-26 10:52:58 +08:00
|
|
|
version('6.3.0', '677a7623c7ef6ab99881bc4e048debb6')
|
2016-08-23 08:26:54 +08:00
|
|
|
version('6.2.0', '9768625159663b300ae4de2f4745fcc4')
|
2016-05-04 04:58:14 +08:00
|
|
|
version('6.1.0', '8fb6cb98b8459f5863328380fbf06bd1')
|
2016-07-22 03:36:22 +08:00
|
|
|
version('5.4.0', '4c626ac2a83ef30dfb9260e6f59c2b30')
|
2015-12-08 16:57:07 +08:00
|
|
|
version('5.3.0', 'c9616fd448f980259c31de613e575719')
|
2015-10-06 21:57:17 +08:00
|
|
|
version('5.2.0', 'a51bcfeb3da7dd4c623e27207ed43467')
|
2016-08-23 08:26:54 +08:00
|
|
|
version('5.1.0', 'd5525b1127d07d215960e6051c5da35e')
|
|
|
|
version('4.9.4', '87c24a4090c1577ba817ec6882602491')
|
2015-10-06 21:57:17 +08:00
|
|
|
version('4.9.3', '6f831b4d251872736e8e9cc09746f327')
|
2015-01-23 15:34:39 +08:00
|
|
|
version('4.9.2', '4df8ee253b7f3863ad0b86359cd39c43')
|
|
|
|
version('4.9.1', 'fddf71348546af523353bd43d34919c1')
|
2015-10-06 21:57:17 +08:00
|
|
|
version('4.8.5', '80d2c2982a3392bb0b89673ff136e223')
|
2015-01-23 15:34:39 +08:00
|
|
|
version('4.8.4', '5a84a30839b2aca22a2d723de2a626ec')
|
|
|
|
version('4.7.4', '4c696da46297de6ae77a82797d2abe28')
|
|
|
|
version('4.6.4', 'b407a3d1480c11667f293bfb1f17d1a4')
|
|
|
|
version('4.5.4', '27e459c2566b8209ab064570e1b378f7')
|
2016-01-04 09:22:13 +08:00
|
|
|
|
2016-05-15 13:35:55 +08:00
|
|
|
variant('binutils',
|
|
|
|
default=sys.platform != 'darwin',
|
|
|
|
description="Build via binutils")
|
|
|
|
variant('gold',
|
|
|
|
default=sys.platform != 'darwin',
|
|
|
|
description="Build the gold linker plugin for ld-based LTO")
|
2016-08-18 00:28:21 +08:00
|
|
|
variant('piclibs',
|
|
|
|
default=False,
|
|
|
|
description="Build PIC versions of libgfortran.a and libstdc++.a")
|
2016-01-21 18:40:38 +08:00
|
|
|
|
2014-10-09 12:59:47 +08:00
|
|
|
depends_on("mpfr")
|
|
|
|
depends_on("gmp")
|
2016-02-15 06:40:25 +08:00
|
|
|
depends_on("mpc", when='@4.5:')
|
|
|
|
depends_on("isl", when='@5.0:')
|
2016-02-13 01:51:43 +08:00
|
|
|
depends_on("binutils~libiberty", when='+binutils ~gold')
|
|
|
|
depends_on("binutils~libiberty+gold", when='+binutils +gold')
|
2014-11-06 01:54:43 +08:00
|
|
|
|
2016-03-28 04:18:23 +08:00
|
|
|
# TODO: integrate these libraries.
|
2016-05-15 13:35:55 +08:00
|
|
|
# depends_on("ppl")
|
|
|
|
# depends_on("cloog")
|
2016-03-29 05:28:29 +08:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
patch('darwin/gcc-4.9.patch1', when='@4.9.3')
|
|
|
|
patch('darwin/gcc-4.9.patch2', when='@4.9.3')
|
2016-05-16 01:23:33 +08:00
|
|
|
else:
|
|
|
|
provides('golang', when='@4.7.1:')
|
2014-10-09 12:59:47 +08:00
|
|
|
|
2016-08-18 00:28:21 +08:00
|
|
|
patch('piclibs.patch', when='+piclibs')
|
2016-11-07 07:31:48 +08:00
|
|
|
patch('gcc-backport.patch', when='@4.7:4.9.2,5:5.3')
|
2016-08-18 00:28:21 +08:00
|
|
|
|
2014-10-09 12:59:47 +08:00
|
|
|
def install(self, spec, prefix):
|
2014-11-06 01:54:43 +08:00
|
|
|
# libjava/configure needs a minor fix to install into spack paths.
|
2016-02-13 02:11:45 +08:00
|
|
|
filter_file(r"'@.*@'", "'@[[:alnum:]]*@'", 'libjava/configure',
|
2016-05-15 13:35:55 +08:00
|
|
|
string=True)
|
2014-11-06 01:54:43 +08:00
|
|
|
|
2015-12-31 02:20:27 +08:00
|
|
|
enabled_languages = set(('c', 'c++', 'fortran', 'java', 'objc'))
|
2016-03-29 05:28:29 +08:00
|
|
|
|
2016-10-20 14:29:59 +08:00
|
|
|
if spec.satisfies("@4.7.1:") and sys.platform != 'darwin' and \
|
|
|
|
not (spec.satisfies('@:4.9.3') and 'ppc64le' in spec.architecture):
|
2015-01-23 15:34:39 +08:00
|
|
|
enabled_languages.add('go')
|
|
|
|
|
2016-10-03 09:54:43 +08:00
|
|
|
# Fix a standard header file for OS X Yosemite that
|
|
|
|
# is GCC incompatible by replacing non-GCC compliant macros
|
|
|
|
if 'yosemite' in spec.architecture:
|
|
|
|
if isfile(r'/usr/include/dispatch/object.h'):
|
|
|
|
new_dispatch_dir = join_path(prefix, 'include', 'dispatch')
|
|
|
|
mkdirp(new_dispatch_dir)
|
|
|
|
cp = which('cp')
|
|
|
|
new_header = join_path(new_dispatch_dir, 'object.h')
|
|
|
|
cp(r'/usr/include/dispatch/object.h', new_header)
|
|
|
|
filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)',
|
|
|
|
'typedef void* dispatch_block_t',
|
|
|
|
new_header)
|
|
|
|
|
2015-09-26 16:12:24 +08:00
|
|
|
# Generic options to compile GCC
|
2016-05-15 13:35:55 +08:00
|
|
|
options = ["--prefix=%s" % prefix, "--libdir=%s/lib64" % prefix,
|
2015-09-26 16:12:24 +08:00
|
|
|
"--disable-multilib",
|
|
|
|
"--enable-languages=" + ','.join(enabled_languages),
|
2016-05-15 13:35:55 +08:00
|
|
|
"--with-mpc=%s" % spec['mpc'].prefix, "--with-mpfr=%s" %
|
|
|
|
spec['mpfr'].prefix, "--with-gmp=%s" % spec['gmp'].prefix,
|
|
|
|
"--enable-lto", "--with-quad"]
|
2015-09-26 16:12:24 +08:00
|
|
|
# Binutils
|
2016-02-13 01:51:43 +08:00
|
|
|
if spec.satisfies('+binutils'):
|
|
|
|
static_bootstrap_flags = "-static-libstdc++ -static-libgcc"
|
2016-05-15 13:35:55 +08:00
|
|
|
binutils_options = [
|
|
|
|
"--with-sysroot=/", "--with-stage1-ldflags=%s %s" %
|
|
|
|
(self.rpath_args, static_bootstrap_flags),
|
|
|
|
"--with-boot-ldflags=%s %s" %
|
|
|
|
(self.rpath_args, static_bootstrap_flags), "--with-gnu-ld",
|
|
|
|
"--with-ld=%s/bin/ld" % spec['binutils'].prefix,
|
|
|
|
"--with-gnu-as",
|
|
|
|
"--with-as=%s/bin/as" % spec['binutils'].prefix
|
|
|
|
]
|
2016-02-13 01:51:43 +08:00
|
|
|
options.extend(binutils_options)
|
2015-09-26 16:12:24 +08:00
|
|
|
# Isl
|
2016-02-15 06:40:25 +08:00
|
|
|
if 'isl' in spec:
|
2015-09-26 16:12:24 +08:00
|
|
|
isl_options = ["--with-isl=%s" % spec['isl'].prefix]
|
|
|
|
options.extend(isl_options)
|
|
|
|
|
2016-05-15 13:35:55 +08:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
darwin_options = ["--with-build-config=bootstrap-debug"]
|
2016-03-29 05:28:29 +08:00
|
|
|
options.extend(darwin_options)
|
|
|
|
|
2015-12-08 16:57:07 +08:00
|
|
|
build_dir = join_path(self.stage.path, 'spack-build')
|
2016-05-15 13:35:55 +08:00
|
|
|
configure = Executable(join_path(self.stage.source_path, 'configure'))
|
2015-12-08 16:57:07 +08:00
|
|
|
with working_dir(build_dir, create=True):
|
2015-12-08 07:49:47 +08:00
|
|
|
# Rest of install is straightforward.
|
|
|
|
configure(*options)
|
2016-05-15 13:35:55 +08:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
make("bootstrap")
|
|
|
|
else:
|
|
|
|
make()
|
2015-12-08 07:49:47 +08:00
|
|
|
make("install")
|
2016-01-21 18:40:38 +08:00
|
|
|
|
2014-11-06 01:54:43 +08:00
|
|
|
self.write_rpath_specs()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def spec_dir(self):
|
|
|
|
# e.g. lib64/gcc/x86_64-unknown-linux-gnu/4.9.2
|
|
|
|
spec_dir = glob("%s/lib64/gcc/*/*" % self.prefix)
|
|
|
|
return spec_dir[0] if spec_dir else None
|
|
|
|
|
|
|
|
def write_rpath_specs(self):
|
|
|
|
"""Generate a spec file so the linker adds a rpath to the libs
|
|
|
|
the compiler used to build the executable."""
|
|
|
|
if not self.spec_dir:
|
2016-02-13 02:11:45 +08:00
|
|
|
tty.warn("Could not install specs for %s." %
|
2016-05-15 13:35:55 +08:00
|
|
|
self.spec.format('$_$@'))
|
2014-11-06 01:54:43 +08:00
|
|
|
return
|
|
|
|
|
|
|
|
gcc = Executable(join_path(self.prefix.bin, 'gcc'))
|
2016-01-21 18:40:38 +08:00
|
|
|
lines = gcc('-dumpspecs', output=str).strip().split("\n")
|
2015-10-06 21:57:17 +08:00
|
|
|
specs_file = join_path(self.spec_dir, 'specs')
|
|
|
|
with closing(open(specs_file, 'w')) as out:
|
|
|
|
for line in lines:
|
2015-10-07 00:20:48 +08:00
|
|
|
out.write(line + "\n")
|
2015-10-06 21:57:17 +08:00
|
|
|
if line.startswith("*link:"):
|
2016-02-13 02:11:45 +08:00
|
|
|
out.write("-rpath %s/lib:%s/lib64 \\\n" %
|
2016-05-15 13:35:55 +08:00
|
|
|
(self.prefix, self.prefix))
|
2015-10-06 21:57:17 +08:00
|
|
|
set_install_permissions(specs_file)
|