From 59b66b0d27d29f4c7c1db256389331a36ca9fa10 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 21 Jun 2017 18:36:18 +0200 Subject: [PATCH] mumps: fixed compilation issues due to scotch not found at link time (#4567) --- .../repos/builtin/packages/mumps/package.py | 7 +------ .../scotch/esmumps-ldflags-6.0.4.patch | 11 ++++++++++ .../repos/builtin/packages/scotch/package.py | 20 ++++++++++++++++++- .../repos/builtin/packages/zlib/package.py | 7 +++++++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 var/spack/repos/builtin/packages/scotch/esmumps-ldflags-6.0.4.patch diff --git a/var/spack/repos/builtin/packages/mumps/package.py b/var/spack/repos/builtin/packages/mumps/package.py index 5bddeaba5d..55aac441f0 100644 --- a/var/spack/repos/builtin/packages/mumps/package.py +++ b/var/spack/repos/builtin/packages/mumps/package.py @@ -92,14 +92,9 @@ def write_makefile_inc(self): orderings = ['-Dpord'] if '+ptscotch' in self.spec or '+scotch' in self.spec: - join_lib = ' -l%s' % ('pt' if '+ptscotch' in self.spec else '') makefile_conf.extend([ "ISCOTCH = -I%s" % self.spec['scotch'].prefix.include, - "LSCOTCH = -L%s %s%s" % (self.spec['scotch'].prefix.lib, - join_lib, - join_lib.join(['esmumps', - 'scotch', - 'scotcherr'])) + "LSCOTCH = {0}".format(self.spec['scotch'].libs.ld_flags) ]) orderings.append('-Dscotch') diff --git a/var/spack/repos/builtin/packages/scotch/esmumps-ldflags-6.0.4.patch b/var/spack/repos/builtin/packages/scotch/esmumps-ldflags-6.0.4.patch new file mode 100644 index 0000000000..e22ba17b34 --- /dev/null +++ b/var/spack/repos/builtin/packages/scotch/esmumps-ldflags-6.0.4.patch @@ -0,0 +1,11 @@ +--- a/src/esmumps/Makefile 2017-06-21 10:53:31.595758201 +0200 ++++ b/src/esmumps/Makefile 2017-06-21 10:54:30.811757141 +0200 +@@ -44,7 +44,7 @@ + $(CC) $(CFLAGS) $(CLIBFLAGS) -I$(includedir) -c $(<) -o $(@) + + %$(EXE) : %.c +- $(CC) $(CFLAGS) -I$(includedir) $(<) -o $(@) -L$(libdir) $(LDFLAGS) -L. -l$(ESMUMPSLIB) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit -lm ++ $(CC) $(CFLAGS) -I$(includedir) $(<) -o $(@) -L$(libdir) -L. -l$(ESMUMPSLIB) -l$(SCOTCHLIB) -lscotch -l$(SCOTCHLIB)errexit -lm $(LDFLAGS) + + ## + ## Project rules. diff --git a/var/spack/repos/builtin/packages/scotch/package.py b/var/spack/repos/builtin/packages/scotch/package.py index 89d1f8e568..6129db104a 100644 --- a/var/spack/repos/builtin/packages/scotch/package.py +++ b/var/spack/repos/builtin/packages/scotch/package.py @@ -58,6 +58,7 @@ class Scotch(Package): # Version-specific patches patch('nonthreaded-6.0.4.patch', when='@6.0.4') + patch('esmumps-ldflags-6.0.4.patch', when='@6.0.4') # NOTE: In cross-compiling environment parallel build # produces weird linker errors. @@ -74,6 +75,23 @@ def url_for_version(self, version): url = "http://gforge.inria.fr/frs/download.php/latestfile/298/scotch_{0}_esmumps.tar.gz" return url.format(version) + @property + def libs(self): + + shared = '+shared' in self.spec + libraries = ['libscotch', 'libscotcherr'] + + if '+mpi' in self.spec: + libraries = ['libptscotch', 'libptscotcherr'] + libraries + if '+esmumps' in self.spec: + libraries = ['libptesmumps'] + libraries + elif '~mpi+esmumps' in self.spec: + libraries = ['libesmumps'] + libraries + + return find_libraries( + libraries, root=self.prefix, recurse=True, shared=shared + ) + def patch(self): self.configure() @@ -146,7 +164,7 @@ def configure(self): if '+compression' in self.spec: cflags.append('-DCOMMON_FILE_COMPRESS_GZ') - ldflags.append('-L%s -lz' % (self.spec['zlib'].prefix.lib)) + ldflags.append(' {0} '.format(self.spec['zlib'].libs.joined())) cflags.append('-DCOMMON_PTHREAD') diff --git a/var/spack/repos/builtin/packages/zlib/package.py b/var/spack/repos/builtin/packages/zlib/package.py index 43d24c61d1..8971cc0b1b 100644 --- a/var/spack/repos/builtin/packages/zlib/package.py +++ b/var/spack/repos/builtin/packages/zlib/package.py @@ -48,6 +48,13 @@ class Zlib(Package): patch('w_patch.patch', when="@1.2.11%cce") + @property + def libs(self): + shared = '+shared' in self.spec + return find_libraries( + ['libz'], root=self.prefix, recurse=True, shared=shared + ) + def setup_environment(self, spack_env, run_env): if '+pic' in self.spec: spack_env.set('CFLAGS', self.compiler.pic_flag)