summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTomoki, Karatsu <49965247+t-karatsu@users.noreply.github.com>2020-09-28 17:53:56 +0900
committerGitHub <noreply@github.com>2020-09-28 10:53:56 +0200
commitb76189a2e54ff9c811f680341e94316ef1be5350 (patch)
treefc90c84b919851f07329af192b05e31dca4825e1 /lib
parentc8ac61979be5ae9ed02c25345c0567a518353803 (diff)
downloadspack-b76189a2e54ff9c811f680341e94316ef1be5350.tar.gz
spack-b76189a2e54ff9c811f680341e94316ef1be5350.tar.bz2
spack-b76189a2e54ff9c811f680341e94316ef1be5350.tar.xz
spack-b76189a2e54ff9c811f680341e94316ef1be5350.zip
autotools: patch 'libtool' recursively in subdirectories (#18620)
Previous version was doing it only in the root build directory.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_systems/autotools.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py
index 1ea238e2d1..1f490058de 100644
--- a/lib/spack/spack/build_systems/autotools.py
+++ b/lib/spack/spack/build_systems/autotools.py
@@ -5,17 +5,15 @@
import inspect
-import fileinput
import os
import os.path
import shutil
import stat
-import sys
-import re
from subprocess import PIPE
from subprocess import check_call
import llnl.util.tty as tty
+import llnl.util.filesystem as fs
from llnl.util.filesystem import working_dir, force_remove
from spack.package import PackageBase, run_after, run_before
from spack.util.executable import Executable
@@ -196,20 +194,25 @@ class AutotoolsPackage(PackageBase):
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.cc_pic_flag)
- if self.spec.satisfies('%fj') and 'fjhpctag.o' in line:
- line = re.sub(r'/\S*/fjhpctag.o', '', line)
- sys.stdout.write(line)
+ # Exit early if we are required not to patch libtool
+ if not self.patch_libtool:
+ return
+
+ for libtool_path in fs.find(
+ self.build_directory, 'libtool', recursive=True):
+ self._patch_libtool(libtool_path)
+
+ def _patch_libtool(self, libtool_path):
+ if self.spec.satisfies('%arm')\
+ or self.spec.satisfies('%clang')\
+ or self.spec.satisfies('%fj'):
+ fs.filter_file('wl=""\n', 'wl="-Wl,"\n', libtool_path)
+ 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
def configure_directory(self):