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
This commit is contained in:
parent
44485c56b6
commit
845df79ac6
@ -5,10 +5,12 @@
|
|||||||
|
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
import fileinput
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
|
import sys
|
||||||
from subprocess import PIPE
|
from subprocess import PIPE
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
|
||||||
@ -56,6 +58,9 @@ class AutotoolsPackage(PackageBase):
|
|||||||
build_system_class = 'AutotoolsPackage'
|
build_system_class = 'AutotoolsPackage'
|
||||||
#: Whether or not to update ``config.guess`` on old architectures
|
#: Whether or not to update ``config.guess`` on old architectures
|
||||||
patch_config_guess = True
|
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`
|
#: Targets for ``make`` during the :py:meth:`~.AutotoolsPackage.build`
|
||||||
#: phase
|
#: phase
|
||||||
@ -148,6 +153,25 @@ def _do_patch_config_guess(self):
|
|||||||
|
|
||||||
raise RuntimeError('Failed to find suitable config.guess')
|
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
|
@property
|
||||||
def configure_directory(self):
|
def configure_directory(self):
|
||||||
"""Returns the directory where 'configure' resides.
|
"""Returns the directory where 'configure' resides.
|
||||||
|
Loading…
Reference in New Issue
Block a user