summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-11-05 09:54:43 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-11-05 09:54:43 -0800
commitb97ee67a4b8ddddf9af8a93c3e8292e34d507467 (patch)
tree842852c0ca27811818b0e5747330fca39c2270da
parenta37828bafba2f594e54e0e7487df909fdeac4c8f (diff)
downloadspack-b97ee67a4b8ddddf9af8a93c3e8292e34d507467.tar.gz
spack-b97ee67a4b8ddddf9af8a93c3e8292e34d507467.tar.bz2
spack-b97ee67a4b8ddddf9af8a93c3e8292e34d507467.tar.xz
spack-b97ee67a4b8ddddf9af8a93c3e8292e34d507467.zip
Working GCC package.
-rw-r--r--lib/spack/llnl/util/filesystem.py23
-rw-r--r--var/spack/packages/gcc/package.py53
2 files changed, 71 insertions, 5 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index dc722297ec..6a04d98a18 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -22,8 +22,9 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-__all__ = ['install', 'expand_user', 'working_dir', 'touch', 'mkdirp',
- 'join_path', 'ancestor', 'can_access', 'filter_file', 'change_sed_delimiter']
+__all__ = ['set_install_permissions', 'install', 'expand_user', 'working_dir',
+ 'touch', 'mkdirp', 'force_remove', 'join_path', 'ancestor',
+ 'can_access', 'filter_file', 'change_sed_delimiter']
import os
import sys
@@ -127,10 +128,19 @@ def change_sed_delimiter(old_delim, new_delim, *filenames):
filter_file(double_quoted, '"%s"' % repl, f)
+def set_install_permissions(path):
+ """Set appropriate permissions on the installed file."""
+ if os.path.isdir(path):
+ os.chmod(path, 0755)
+ else:
+ os.chmod(path, 0644)
+
+
def install(src, dest):
"""Manually install a file to a particular location."""
tty.info("Installing %s to %s" % (src, dest))
shutil.copy(src, dest)
+ set_install_permissions(dest)
def expand_user(path):
@@ -152,6 +162,15 @@ def mkdirp(*paths):
raise OSError(errno.EEXIST, "File alredy exists", path)
+def force_remove(*paths):
+ """Remove files without printing errors. Like rm -f, does NOT
+ remove directories."""
+ for path in paths:
+ try:
+ os.remove(path)
+ except OSError, e:
+ pass
+
@contextmanager
def working_dir(dirname, **kwargs):
if kwargs.get('create', False):
diff --git a/var/spack/packages/gcc/package.py b/var/spack/packages/gcc/package.py
index bb5fee8192..e1f1084c96 100644
--- a/var/spack/packages/gcc/package.py
+++ b/var/spack/packages/gcc/package.py
@@ -24,20 +24,67 @@
##############################################################################
from spack import *
+from contextlib import closing
+from glob import glob
+
class Gcc(Package):
"""The GNU Compiler Collection includes front ends for C, C++,
Objective-C, Fortran, and Java."""
homepage = "https://gcc.gnu.org"
- url = "http://www.netgull.com/gcc/releases/gcc-4.9.1/gcc-4.9.1.tar.bz2"
- version('4.9.1', 'fddf71348546af523353bd43d34919c1')
+ list_url = 'http://mirrors.kernel.org/gnu/gcc/'
+ list_depth = 2
+
+ version('4.9.2', '4df8ee253b7f3863ad0b86359cd39c43',
+ url="http://mirrors.kernel.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2")
+ version('4.9.1', 'fddf71348546af523353bd43d34919c1',
+ url="http://mirrors.kernel.org/gnu/gcc/gcc-4.9.1/gcc-4.9.1.tar.bz2")
depends_on("mpc")
depends_on("mpfr")
depends_on("gmp")
+ depends_on("libelf")
+
def install(self, spec, prefix):
+ # libjava/configure needs a minor fix to install into spack paths.
+ filter_file(r"'@.*@'", "'@[[:alnum:]]*@'", 'libjava/configure', string=True)
+
+ # Rest of install is straightforward.
configure("--prefix=%s" % prefix,
- "--disable-multilib")
+ "--libdir=%s/lib64" % prefix,
+ "--disable-multilib",
+ "--enable-languages=c,c++,fortran,java,objc,go",
+ "--enable-lto",
+ "--with-quad")
make()
make("install")
+
+ 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:
+ tty.warn("Could not install specs for %s." % self.spec.format('$_$@'))
+ return
+
+ gcc = Executable(join_path(self.prefix.bin, 'gcc'))
+ lines = gcc('-dumpspecs', return_output=True).split("\n")
+ for i, line in enumerate(lines):
+ if line.startswith("*link:"):
+ specs_file = join_path(self.spec_dir, 'specs')
+ with closing(open(specs_file, 'w')) as out:
+ out.write(lines[i] + "\n")
+ out.write("-rpath %s/lib:%s/lib64 \\\n"
+ % (self.prefix, self.prefix))
+ out.write(lines[i+1] + "\n")
+ set_install_permissions(specs_file)