mumps: fixed compilation issues due to scotch not found at link time (#4567)

This commit is contained in:
Massimiliano Culpo 2017-06-21 18:36:18 +02:00 committed by Adam J. Stewart
parent 1f2e56e1f3
commit 59b66b0d27
4 changed files with 38 additions and 7 deletions

View file

@ -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')

View file

@ -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.

View file

@ -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')

View file

@ -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)