From 23474be4b0fe55dc0818c0a334a337e282717b44 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Fri, 2 Jun 2017 08:44:01 -0700 Subject: Add variant to build shared Perl lib (#4416) * Add variant to build shared Perl lib Add a variant that enables Perl's "useshrplib" feature, which builds a shared perl library. This addresses problems like so: ``` /usr/bin/ld: /blah/blah/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/perl-5.24.1-y43dp3p5w66v7qh5xkwgufxohyuodyew/lib/5.24.1/x86_64-linux/CORE/libperl.a(op.o): relocation R_X86_64_32S against `PL_opargs' can not be used when making a shared object; recompile with -fPIC /blah/blah/spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/perl-5.24.1-y43dp3p5w66v7qh5xkwgufxohyuodyew/lib/5.24.1/x86_64-linux/CORE/libperl.a: could not read symbols: Bad value ``` It should also address the Intel compiler issue discussed in #3081 while respecting Perl's configuration machinery. * Rename shared variant and default to True * Use correct variant to add configure arg * Restore bits that set ccflags for intel compilers After some experimentation we've established that setting the flag to build a shared perl library is tightly tied to the use of -fPIC. This commit restores the code that sets ccflags for intel compilers. * Flake8 cleanup --- var/spack/repos/builtin/packages/perl/package.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index ef1c11289f..95b2ae8726 100644 --- a/var/spack/repos/builtin/packages/perl/package.py +++ b/var/spack/repos/builtin/packages/perl/package.py @@ -69,6 +69,9 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package variant('cpanm', default=True, description='Optionally install cpanm with the core packages.') + variant('shared', default=True, + description='Build a shared libperl.so library') + resource( name="cpanm", url="http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7042.tar.gz", @@ -87,14 +90,18 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package '-des', '-Dprefix={0}'.format(prefix), '-Dlocincpth=' + self.spec['gdbm'].prefix.include, - '-Dloclibpth=' + self.spec['gdbm'].prefix.lib + '-Dloclibpth=' + self.spec['gdbm'].prefix.lib, ] # Discussion of -fPIC for Intel at: - # https://github.com/LLNL/spack/pull/3081 + # https://github.com/LLNL/spack/pull/3081 and + # https://github.com/LLNL/spack/pull/4416 if spec.satisfies('%intel'): config_args.append('-Accflags={0}'.format(self.compiler.pic_flag)) + if '+shared' in spec: + config_args.append('-Duseshrplib') + return config_args def configure(self, spec, prefix): -- cgit v1.2.3-70-g09d2