summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorSergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>2022-11-24 20:10:18 +0100
committerGitHub <noreply@github.com>2022-11-24 20:10:18 +0100
commit7a5e527cab5980cb4732bb3504fab77d75286a19 (patch)
tree1da92ea42b8d433fd7d95f2ad2c45d98d527c269 /var
parenta25868594ce2d297deabf415b5d53ac7f2c1cfcb (diff)
downloadspack-7a5e527cab5980cb4732bb3504fab77d75286a19.tar.gz
spack-7a5e527cab5980cb4732bb3504fab77d75286a19.tar.bz2
spack-7a5e527cab5980cb4732bb3504fab77d75286a19.tar.xz
spack-7a5e527cab5980cb4732bb3504fab77d75286a19.zip
zlib: fix shared libraries when '%nvhpc' (#34039)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/zlib/package.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/zlib/package.py b/var/spack/repos/builtin/packages/zlib/package.py
index f8af00163b..846675e32f 100644
--- a/var/spack/repos/builtin/packages/zlib/package.py
+++ b/var/spack/repos/builtin/packages/zlib/package.py
@@ -77,6 +77,43 @@ class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder, SetupEnviron
config_args.append("--static")
configure("--prefix={0}".format(prefix), *config_args)
+ if "+shared" in self.spec:
+ # We need to fix the building of the shared libraries with compilers that are not
+ # recognized as gcc. Note that a compiler is recognized as gcc if it has "gcc" or
+ # "clang" substring either in its executable name (including the path) or in the output
+ # generated with the `-v` flag (i.e '$CC -v 2>&1'). The latter is the reason why, for
+ # example, %intel and %oneapi are often recognized as gcc: they almost always contain
+ # "gcc" in the verbose output. Another example is %pgi, which has "gcc" in the name of
+ # the C compiler (pgcc) and in the verbose output (e.g. "pgcc-Warning-No files to
+ # process"). Although we should not rely on the false positive results of the configure
+ # script but patch the makefile for all the aforementioned compilers, given the
+ # importance of the package, we try to be conservative for now and do the patching only
+ # for compilers that will not produce a correct shared library otherwise.
+ if self.spec.compiler.name in ["nvhpc"]:
+ if "~pic" in self.spec:
+ # In this case, we should build the static library without PIC, therefore we
+ # don't append the respective compiler flag to CFLAGS in the build environment.
+ # However, we need the flag for the objects of the shared library:
+ filter_file(
+ r"^(SFLAGS *=.*)$",
+ r"\1 {0}".format(self.pkg.compiler.cc_pic_flag),
+ "Makefile",
+ )
+ if any(self.spec.satisfies("platform={0}".format(p)) for p in ["linux", "cray"]):
+ # Without the following, the shared library will not have a soname entry.
+ # Currently, we support linux and cray platforms only.
+ filter_file(
+ r"^(LDSHARED *= *).*$",
+ # Note that we should use '-Wl,` and not self.pkg.compiler.linker_arg
+ # because the former is understood by virtually every C compiler and the
+ # latter might be meant for the Fortran compiler only (e.g. NAG):
+ r"\1 {0} -shared "
+ r"-Wl,-soname,libz.{1}.{2},--version-script,zlib.map".format(
+ spack_cc, dso_suffix, self.spec.version.up_to(1)
+ ),
+ "Makefile",
+ )
+
class GenericBuilder(spack.build_systems.generic.GenericBuilder, SetupEnvironment):
def install(self, spec, prefix):