Corrected compiler filtering for TAU makefiles (#15342)

* Implemented working file filtering to replace spack compiler wrapper with real compiler.

* Using string=True instead of re.escape. Using self.prefix.lib instead of appending /lib.

Co-authored-by: Wyatt Spear <wspear@cs.uoregon.edu>
This commit is contained in:
wspear 2020-03-17 08:38:53 -07:00 committed by GitHub
parent c2e0ee6383
commit 304f0e9ef1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,8 +104,6 @@ class Tau(Package):
conflicts('+adios2', when='@:2.29.1') conflicts('+adios2', when='@:2.29.1')
conflicts('+sqlite', when='@:2.29.1') conflicts('+sqlite', when='@:2.29.1')
filter_compiler_wrappers('tau_cc.sh', 'Makefile.tau', relative_root='bin')
def set_compiler_options(self, spec): def set_compiler_options(self, spec):
useropt = ["-O2 -g", self.rpath_args] useropt = ["-O2 -g", self.rpath_args]
@ -271,11 +269,15 @@ def install(self, spec, prefix):
compiler_specific_options = self.set_compiler_options(spec) compiler_specific_options = self.set_compiler_options(spec)
options.extend(compiler_specific_options) options.extend(compiler_specific_options)
configure(*options) configure(*options)
make("install") make("install")
# Link arch-specific directories into prefix since there is # Link arch-specific directories into prefix since there is
# only one arch per prefix the way spack installs. # only one arch per prefix the way spack installs.
self.link_tau_arch_dirs() self.link_tau_arch_dirs()
# TAU may capture Spack's internal compiler wrapper. Replace
# it with the correct compiler.
self.fix_tau_compilers()
def link_tau_arch_dirs(self): def link_tau_arch_dirs(self):
for subdir in os.listdir(self.prefix): for subdir in os.listdir(self.prefix):
@ -285,6 +287,22 @@ def link_tau_arch_dirs(self):
if os.path.isdir(src) and not os.path.exists(dest): if os.path.isdir(src) and not os.path.exists(dest):
os.symlink(join_path(subdir, d), dest) os.symlink(join_path(subdir, d), dest)
def fix_tau_compilers(self):
filter_file('FULL_CC=' + spack_cc, 'FULL_CC=' + self.compiler.cc,
self.prefix + '/include/Makefile', backup=False,
string=True)
filter_file('FULL_CXX=' + spack_cxx, 'FULL_CXX=' +
self.compiler.cxx, self.prefix + '/include/Makefile',
backup=False, string=True)
for makefile in os.listdir(self.prefix.lib):
if makefile.startswith('Makefile.tau'):
filter_file('FULL_CC=' + spack_cc, 'FULL_CC=' +
self.compiler.cc, self.prefix.lib + "/" +
makefile, backup=False, string=True)
filter_file('FULL_CXX=' + spack_cxx, 'FULL_CXX=' +
self.compiler.cxx, self.prefix.lib +
"/" + makefile, backup=False, string=True)
def setup_run_environment(self, env): def setup_run_environment(self, env):
pattern = join_path(self.prefix.lib, 'Makefile.*') pattern = join_path(self.prefix.lib, 'Makefile.*')
files = glob.glob(pattern) files = glob.glob(pattern)