zlib: fix shared libraries when '%nvhpc' (#34039)
This commit is contained in:
parent
a25868594c
commit
7a5e527cab
@ -77,6 +77,43 @@ def edit(self, pkg, spec, prefix):
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user