autotools: patch 'libtool' recursively in subdirectories (#18620)
Previous version was doing it only in the root build directory.
This commit is contained in:
parent
c8ac61979b
commit
b76189a2e5
@ -5,17 +5,15 @@
|
|||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
import re
|
|
||||||
from subprocess import PIPE
|
from subprocess import PIPE
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
|
import llnl.util.filesystem as fs
|
||||||
from llnl.util.filesystem import working_dir, force_remove
|
from llnl.util.filesystem import working_dir, force_remove
|
||||||
from spack.package import PackageBase, run_after, run_before
|
from spack.package import PackageBase, run_after, run_before
|
||||||
from spack.util.executable import Executable
|
from spack.util.executable import Executable
|
||||||
@ -196,20 +194,25 @@ def _do_patch_libtool(self):
|
|||||||
detect the compiler (and patch_libtool is set), patch in the correct
|
detect the compiler (and patch_libtool is set), patch in the correct
|
||||||
flags for the Arm, Clang/Flang, and Fujitsu compilers."""
|
flags for the Arm, Clang/Flang, and Fujitsu compilers."""
|
||||||
|
|
||||||
libtool = os.path.join(self.build_directory, "libtool")
|
# Exit early if we are required not to patch libtool
|
||||||
if self.patch_libtool and os.path.exists(libtool):
|
if not self.patch_libtool:
|
||||||
if self.spec.satisfies('%arm') or self.spec.satisfies('%clang') \
|
return
|
||||||
or self.spec.satisfies('%fj'):
|
|
||||||
for line in fileinput.input(libtool, inplace=True):
|
for libtool_path in fs.find(
|
||||||
# Replace missing flags with those for Arm/Clang
|
self.build_directory, 'libtool', recursive=True):
|
||||||
if line == 'wl=""\n':
|
self._patch_libtool(libtool_path)
|
||||||
line = 'wl="-Wl,"\n'
|
|
||||||
if line == 'pic_flag=""\n':
|
def _patch_libtool(self, libtool_path):
|
||||||
line = 'pic_flag="{0}"\n'\
|
if self.spec.satisfies('%arm')\
|
||||||
.format(self.compiler.cc_pic_flag)
|
or self.spec.satisfies('%clang')\
|
||||||
if self.spec.satisfies('%fj') and 'fjhpctag.o' in line:
|
or self.spec.satisfies('%fj'):
|
||||||
line = re.sub(r'/\S*/fjhpctag.o', '', line)
|
fs.filter_file('wl=""\n', 'wl="-Wl,"\n', libtool_path)
|
||||||
sys.stdout.write(line)
|
fs.filter_file('pic_flag=""\n',
|
||||||
|
'pic_flag="{0}"\n'
|
||||||
|
.format(self.compiler.cc_pic_flag),
|
||||||
|
libtool_path)
|
||||||
|
if self.spec.satisfies('%fj'):
|
||||||
|
fs.filter_file(r'/\S*/fjhpctag.o', '', libtool_path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_directory(self):
|
def configure_directory(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user