diff options
author | Nick Forrington <nick.forrington@arm.com> | 2019-10-24 10:51:00 -0400 |
---|---|---|
committer | Greg Becker <becker33@llnl.gov> | 2019-10-24 09:51:00 -0500 |
commit | 845df79ac6ff886fdfae7dc72c3d29fb6a496521 (patch) | |
tree | 728ea07405e11757c96aca19d83ed60fe8b04857 | |
parent | 44485c56b602db48567290c6d0abddfee392e617 (diff) | |
download | spack-845df79ac6ff886fdfae7dc72c3d29fb6a496521.tar.gz spack-845df79ac6ff886fdfae7dc72c3d29fb6a496521.tar.bz2 spack-845df79ac6ff886fdfae7dc72c3d29fb6a496521.tar.xz spack-845df79ac6ff886fdfae7dc72c3d29fb6a496521.zip |
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
-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. |