From 845df79ac6ff886fdfae7dc72c3d29fb6a496521 Mon Sep 17 00:00:00 2001 From: Nick Forrington Date: Thu, 24 Oct 2019 10:51:00 -0400 Subject: Patch libtool when using the Arm compiler (#12004) * Patch libtool when using the arm, clang, and fujitsu compilers If libtool does not have values for linker/pic flags, patch them in --- lib/spack/spack/build_systems/autotools.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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. -- cgit v1.2.3-60-g2f50