netcdf packages: filter compiler wrappers in the *-config files (#33025)

* netcdf packages: filter compiler wrappers in the *-config files

* netcdf-c: provide dependent packages with unfiltered nc-config
This commit is contained in:
Sergey Kosukhin 2022-10-12 11:29:47 +02:00 committed by GitHub
parent dc39edb790
commit c85faaa216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -131,6 +131,8 @@ class NetcdfC(AutotoolsPackage):
conflicts("+parallel-netcdf", when="@:4.0")
conflicts("+hdf4", when="@:4.0")
filter_compiler_wrappers("nc-config", relative_root="bin")
@property
def force_autoreconf(self):
# The patch for 4.7.0 touches configure.ac.
@ -245,6 +247,22 @@ def configure_args(self):
return config_args
def setup_dependent_build_environment(self, env, dependent_spec):
# Some packages, e.g. ncview, refuse to build if the compiler path returned by nc-config
# differs from the path to the compiler that the package should be built with. Therefore,
# we have to shadow nc-config from self.prefix.bin, which references the real compiler,
# with a backed up version, which references Spack compiler wrapper.
if os.path.exists(self._nc_config_backup_dir):
env.prepend_path("PATH", self._nc_config_backup_dir)
@run_after("install")
def backup_nc_config(self):
# We expect this to be run before filter_compiler_wrappers:
nc_config_file = self.prefix.bin.join("nc-config")
if os.path.exists(nc_config_file):
mkdirp(self._nc_config_backup_dir)
install(nc_config_file, self._nc_config_backup_dir)
def check(self):
# h5_test fails when run in parallel
make("check", parallel=False)
@ -253,3 +271,7 @@ def check(self):
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libnetcdf", root=self.prefix, shared=shared, recursive=True)
@property
def _nc_config_backup_dir(self):
return join_path(self.metadata_dir, "spack-nc-config")

View File

@ -29,6 +29,8 @@ class NetcdfCxx4(AutotoolsPackage):
depends_on("doxygen", when="+doc", type="build")
filter_compiler_wrappers("ncxx4-config", relative_root="bin")
def flag_handler(self, name, flags):
if name == "cflags" and "+pic" in self.spec:
flags.append(self.compiler.cc_pic_flag)

View File

@ -62,6 +62,8 @@ class NetcdfFortran(AutotoolsPackage):
# derived from https://github.com/Unidata/netcdf-fortran/pull/211
patch("no_parallel_build.patch", when="@4.5.2")
filter_compiler_wrappers("nf-config", relative_root="bin")
def flag_handler(self, name, flags):
if name == "cflags":
if "+pic" in self.spec: