netcdf-fortran: fix building with AOCC (#25186)
This commit is contained in:
parent
25a4c5ad18
commit
053fa2a47b
1 changed files with 39 additions and 0 deletions
|
@ -141,11 +141,50 @@ def configure_args(self):
|
||||||
def patch_libtool(self):
|
def patch_libtool(self):
|
||||||
"""AOCC support for NETCDF-F"""
|
"""AOCC support for NETCDF-F"""
|
||||||
if '%aocc' in self.spec:
|
if '%aocc' in self.spec:
|
||||||
|
# Libtool does not fully support the compiler toolchain, therefore
|
||||||
|
# we have to patch the script. The C compiler normally gets
|
||||||
|
# configured correctly, the variables of interest in the
|
||||||
|
# 'BEGIN LIBTOOL CONFIG' section are set to non-empty values and,
|
||||||
|
# therefore, are not affected by the replacements below. A more
|
||||||
|
# robust solution would be to extend the filter_file function with
|
||||||
|
# an additional argument start_at and perform the replacements
|
||||||
|
# between the '# ### BEGIN LIBTOOL TAG CONFIG: FC' and
|
||||||
|
# '# ### END LIBTOOL TAG CONFIG: FC' markers for the Fortran
|
||||||
|
# compiler, and between the '# ### BEGIN LIBTOOL TAG CONFIG: F77'
|
||||||
|
# and '# ### END LIBTOOL TAG CONFIG: F77' markers for the Fortran 77
|
||||||
|
# compiler.
|
||||||
|
|
||||||
|
# How to pass a linker flag through the compiler:
|
||||||
|
filter_file(r'^wl=""$',
|
||||||
|
'wl="{0}"'.format(self.compiler.linker_arg),
|
||||||
|
'libtool')
|
||||||
|
|
||||||
|
# Additional compiler flags for building library objects (we need
|
||||||
|
# this to enable shared libraries when building with ~pic). Note
|
||||||
|
# that the following will set fc_pic_flag for both FC and F77, which
|
||||||
|
# in the case of AOCC, should not be a problem. If it is, the
|
||||||
|
# aforementioned modification of the filter_file function could be
|
||||||
|
# a solution.
|
||||||
|
filter_file(r'^pic_flag=""$',
|
||||||
|
'pic_flag=" {0}"'.format(self.compiler.fc_pic_flag),
|
||||||
|
'libtool')
|
||||||
|
|
||||||
|
# The following is supposed to tell the compiler to use the GNU
|
||||||
|
# linker. However, the replacement does not happen (at least for
|
||||||
|
# NetCDF-Fortran 4.5.3) because the replaced substring (i.e. the
|
||||||
|
# first argument passed to the filter_file function) is not present
|
||||||
|
# in the file. The flag should probably be added to 'ldflags' in the
|
||||||
|
# flag_handler method above (another option is to add the flag to
|
||||||
|
# 'ldflags' in compilers.yaml automatically as it was done for other
|
||||||
|
# flags in https://github.com/spack/spack/pull/22219).
|
||||||
filter_file(
|
filter_file(
|
||||||
r'\${wl}-soname \$wl\$soname',
|
r'\${wl}-soname \$wl\$soname',
|
||||||
r'-fuse-ld=ld -Wl,-soname,\$soname',
|
r'-fuse-ld=ld -Wl,-soname,\$soname',
|
||||||
'libtool', string=True)
|
'libtool', string=True)
|
||||||
|
|
||||||
|
# TODO: resolve the NAG-related issues in a similar way: remove the
|
||||||
|
# respective patch files and tune the generated libtool script instead.
|
||||||
|
|
||||||
@when('@:4.4.5')
|
@when('@:4.4.5')
|
||||||
def check(self):
|
def check(self):
|
||||||
with working_dir(self.build_directory):
|
with working_dir(self.build_directory):
|
||||||
|
|
Loading…
Reference in a new issue