diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/autotools.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index eb237bcc4e..ce0e40b34c 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -5,10 +5,12 @@ import inspect +import fileinput import os import os.path import shutil import stat +import sys from subprocess import PIPE from subprocess import check_call @@ -56,6 +58,9 @@ class AutotoolsPackage(PackageBase): build_system_class = 'AutotoolsPackage' #: Whether or not to update ``config.guess`` on old architectures patch_config_guess = True + #: Whether or not to update ``libtool`` + #: (currently only for Arm/Clang/Fujitsu compilers) + patch_libtool = True #: Targets for ``make`` during the :py:meth:`~.AutotoolsPackage.build` #: phase @@ -148,6 +153,25 @@ class AutotoolsPackage(PackageBase): raise RuntimeError('Failed to find suitable config.guess') + @run_after('configure') + def _do_patch_libtool(self): + """If configure generates a "libtool" script that does not correctly + detect the compiler (and patch_libtool is set), patch in the correct + flags for the Arm, Clang/Flang, and Fujitsu compilers.""" + + libtool = os.path.join(self.build_directory, "libtool") + if self.patch_libtool and os.path.exists(libtool): + if self.spec.satisfies('%arm') or self.spec.satisfies('%clang') \ + or self.spec.satisfies('%fj'): + for line in fileinput.input(libtool, inplace=True): + # Replace missing flags with those for Arm/Clang + if line == 'wl=""\n': + line = 'wl="-Wl,"\n' + if line == 'pic_flag=""\n': + line = 'pic_flag="{0}"\n'\ + .format(self.compiler.pic_flag) + sys.stdout.write(line) + @property def configure_directory(self): """Returns the directory where 'configure' resides. |