From 04de78b59ce96a944bac8ace9e4f58388801807e Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Tue, 17 Oct 2023 18:11:22 -0700 Subject: [PATCH 01/10] Add pic option to zstd --- var/spack/repos/builtin/packages/zstd/package.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/var/spack/repos/builtin/packages/zstd/package.py b/var/spack/repos/builtin/packages/zstd/package.py index 8c0cbd8bfe1c51..622244d88bb1ff 100644 --- a/var/spack/repos/builtin/packages/zstd/package.py +++ b/var/spack/repos/builtin/packages/zstd/package.py @@ -52,6 +52,11 @@ class Zstd(CMakePackage, MakefilePackage): values=any_combination_of("zlib", "lz4", "lzma"), description="Enable support for additional compression methods in programs", ) + variant( + "pic", + default=True, + description="Enable position-independent code (PIC)", + ) depends_on("zlib", when="compression=zlib") depends_on("lz4", when="compression=lz4") @@ -61,6 +66,8 @@ class Zstd(CMakePackage, MakefilePackage): # (last tested: nvhpc@22.3) conflicts("+programs %nvhpc") + conflicts("+pic libs=shared") + build_system("cmake", "makefile", default="makefile") @@ -77,6 +84,7 @@ def cmake_args(self): [ self.define("ZSTD_BUILD_STATIC", self.spec.satisfies("libs=static")), self.define("ZSTD_BUILD_SHARED", self.spec.satisfies("libs=shared")), + self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), ] ) if "compression=zlib" in spec: From 3103832f2e95a02a6d51652b075bf4addddee83d Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Wed, 18 Oct 2023 13:11:07 -0700 Subject: [PATCH 02/10] Update udunits --- .../repos/builtin/packages/udunits/package.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/udunits/package.py b/var/spack/repos/builtin/packages/udunits/package.py index 2b92c71d472c78..f63c00a9973dfd 100644 --- a/var/spack/repos/builtin/packages/udunits/package.py +++ b/var/spack/repos/builtin/packages/udunits/package.py @@ -35,10 +35,24 @@ class Udunits(AutotoolsPackage): depends_on("expat") variant("shared", default=True, description="Build shared library") + variant( + "pic", + default=True, + description="Enable position-independent code (PIC)", + when="~shared", + ) @property def libs(self): - return find_libraries(["libudunits2"], root=self.prefix, recursive=True, shared=True) + return find_libraries( + "libudunits2", + root=self.prefix, + recursive=True, + shared=self.spec.satisfies("+shared") + ) def configure_args(self): - return self.enable_or_disable("shared") + config_args = [] + config_args.extend(self.enable_or_disable("shared")) + config_args.extend(self.with_or_without("pic")) + return config_args From a7f0334f166ba7f6813344201e9a2bd6c81c698e Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Wed, 18 Oct 2023 13:11:23 -0700 Subject: [PATCH 03/10] Add static netcdf-c support to nco --- var/spack/repos/builtin/packages/nco/package.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/var/spack/repos/builtin/packages/nco/package.py b/var/spack/repos/builtin/packages/nco/package.py index 4b53a1b296ac0a..d20a4255f6b137 100644 --- a/var/spack/repos/builtin/packages/nco/package.py +++ b/var/spack/repos/builtin/packages/nco/package.py @@ -66,6 +66,10 @@ def configure_args(self): config_args.append("CFLAGS=-O1") config_args.append("CXXFLAGS=-O1") + ncconfig = which("nc-config") + nc_libs = ncconfig("--static", "--libs", output=str).strip() + config_args.append(f"LIBS={nc_libs}") + return config_args def setup_build_environment(self, env): From db2d8db7421f5d8bc4a6b1dcf4a904288a3d4205 Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Wed, 18 Oct 2023 13:20:19 -0700 Subject: [PATCH 04/10] style fix --- var/spack/repos/builtin/packages/udunits/package.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/var/spack/repos/builtin/packages/udunits/package.py b/var/spack/repos/builtin/packages/udunits/package.py index f63c00a9973dfd..db42ac8c1288aa 100644 --- a/var/spack/repos/builtin/packages/udunits/package.py +++ b/var/spack/repos/builtin/packages/udunits/package.py @@ -36,19 +36,13 @@ class Udunits(AutotoolsPackage): variant("shared", default=True, description="Build shared library") variant( - "pic", - default=True, - description="Enable position-independent code (PIC)", - when="~shared", + "pic", default=True, description="Enable position-independent code (PIC)", when="~shared" ) @property def libs(self): return find_libraries( - "libudunits2", - root=self.prefix, - recursive=True, - shared=self.spec.satisfies("+shared") + "libudunits2", root=self.prefix, recursive=True, shared=self.spec.satisfies("+shared") ) def configure_args(self): From 5c43207e0db7b9f416549b8d6729266fe0066d36 Mon Sep 17 00:00:00 2001 From: Alex Richert <82525672+AlexanderRichert-NOAA@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:49:45 -0700 Subject: [PATCH 05/10] style fix --- var/spack/repos/builtin/packages/zstd/package.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/var/spack/repos/builtin/packages/zstd/package.py b/var/spack/repos/builtin/packages/zstd/package.py index 622244d88bb1ff..52049082072f8d 100644 --- a/var/spack/repos/builtin/packages/zstd/package.py +++ b/var/spack/repos/builtin/packages/zstd/package.py @@ -52,11 +52,7 @@ class Zstd(CMakePackage, MakefilePackage): values=any_combination_of("zlib", "lz4", "lzma"), description="Enable support for additional compression methods in programs", ) - variant( - "pic", - default=True, - description="Enable position-independent code (PIC)", - ) + variant("pic", default=True, description="Enable position-independent code (PIC)") depends_on("zlib", when="compression=zlib") depends_on("lz4", when="compression=lz4") From 4a72da858e62d725dfbb3aaa7e7422d3ebed8a88 Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Wed, 18 Oct 2023 16:09:10 -0700 Subject: [PATCH 06/10] Add static gettext support to glib meson build --- var/spack/repos/builtin/packages/glib/package.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/var/spack/repos/builtin/packages/glib/package.py b/var/spack/repos/builtin/packages/glib/package.py index 2452550f30e7c7..d6ccd5a0bbbc2d 100644 --- a/var/spack/repos/builtin/packages/glib/package.py +++ b/var/spack/repos/builtin/packages/glib/package.py @@ -310,6 +310,12 @@ def meson_args(self): args.append("-Diconv=external") else: args.append("-Diconv=gnu") + + if self.spec.satisfies("^gettext ~shared"): + libs = self.spec["iconv"].libs.search_flags + " " + self.spec["iconv"].libs.link_flags + args.append(f"-Dc_link_args={libs}") + args.append(f"-Dcpp_link_args={libs}") + return args From 9273a3a00504a57c709704795e15837eceb2ebf0 Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Wed, 18 Oct 2023 16:10:43 -0700 Subject: [PATCH 07/10] libxpm --- var/spack/repos/builtin/packages/libxpm/package.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/var/spack/repos/builtin/packages/libxpm/package.py b/var/spack/repos/builtin/packages/libxpm/package.py index bbdad61aa2791d..74e495bd4d7f9f 100644 --- a/var/spack/repos/builtin/packages/libxpm/package.py +++ b/var/spack/repos/builtin/packages/libxpm/package.py @@ -30,3 +30,10 @@ def flag_handler(self, name, flags): if name == "ldflags" and "intl" in self.spec["gettext"].libs.names: flags.append("-lintl") return env_flags(name, flags) + + def configure_args(self): + args = [] + if self.spec.satisfies("^gettext ~shared"): + libs = self.spec["iconv"].libs.search_flags + " " + self.spec["iconv"].libs.link_flags + args.append(f"LIBS={libs}") + return args From 32b9507b602880d0c6472d60ed8667462ed2fcbb Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Thu, 19 Oct 2023 01:50:32 -0700 Subject: [PATCH 08/10] update gobject-introspection --- .../packages/gobject-introspection/package.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/var/spack/repos/builtin/packages/gobject-introspection/package.py b/var/spack/repos/builtin/packages/gobject-introspection/package.py index 580918fd96647f..dee1dc841c8a59 100644 --- a/var/spack/repos/builtin/packages/gobject-introspection/package.py +++ b/var/spack/repos/builtin/packages/gobject-introspection/package.py @@ -88,19 +88,10 @@ def setup_build_environment(self, env): if self.spec.satisfies("@:1.60"): env.set("SPACK_SBANG", sbang.sbang_install_path()) - cairo = self.spec["cairo"] - if cairo.satisfies("~shared"): - ldflags = [] - libs = [] - if cairo.satisfies("+fc"): - ldflags.append("-L%s" % cairo["fontconfig"].prefix.lib) - libs.append("-lfontconfig") - if cairo.satisfies("+ft"): - ldflags.append("-L%s" % cairo["freetype"].prefix.lib) - libs.append("-lfreetype") - ldflags.append("-L%s" % cairo["pixman"].prefix.lib) - libs.append("-lpixman-1") - env.set("CFLAGS", " ".join(ldflags) + " " + " ".join(libs)) + if self.spec.satisfies("^cairo ~shared"): + pkgconfig = which("pkg-config") + cairo_libs = pkgconfig("cairo", "--static", "--libs", output=str).strip() + env.set("CFLAGS", cairo_libs) def setup_run_environment(self, env): env.prepend_path("GI_TYPELIB_PATH", join_path(self.prefix.lib, "girepository-1.0")) From 228d2545c09a880caa09e72aab2c363e895c64d2 Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Thu, 19 Oct 2023 01:50:45 -0700 Subject: [PATCH 09/10] update harfbuzz (static cairo) --- .../builtin/packages/harfbuzz/package.py | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/var/spack/repos/builtin/packages/harfbuzz/package.py b/var/spack/repos/builtin/packages/harfbuzz/package.py index fd68b37fb74586..63e3a805b3a2b3 100644 --- a/var/spack/repos/builtin/packages/harfbuzz/package.py +++ b/var/spack/repos/builtin/packages/harfbuzz/package.py @@ -126,12 +126,23 @@ class MesonBuilder(spack.build_systems.meson.MesonBuilder, SetupEnvironment): def meson_args(self): graphite2 = "enabled" if self.pkg.spec.satisfies("+graphite2") else "disabled" coretext = "enabled" if self.pkg.spec.satisfies("+coretext") else "disabled" - return [ + meson_args = [ # disable building of gtk-doc files following #9885 and #9771 "-Ddocs=disabled", "-Dgraphite2={0}".format(graphite2), "-Dcoretext={0}".format(coretext), ] + libs = [] + pc = which("pkg-config") + deps = {"zlib": "~shared", "bzip": "~shared", "libpng": "libs=static", "cairo": "~shared"} + for dep in deps.keys(): + if self.spec.satisfies(f"^{dep} {deps[dep]}"): + libs.append(pc(dep, "--static", "--libs", output=str).strip()) + if libs: + meson_args.append("-Dc_link_args=%s" % " ".join(libs)) + meson_args.append("-Dcpp_link_args=%s" % " ".join(libs)) + + return meson_args class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder, SetupEnvironment): @@ -148,29 +159,13 @@ def configure_args(self): args.extend(self.with_or_without("graphite2")) args.extend(self.with_or_without("coretext")) - ldflags = [] libs = [] - for lib in ["bzip2", "zlib", "libpng"]: - spec = self.spec[lib] - if spec.satisfies("+shared") or spec.satisfies("libs=shared"): - continue - ldflags.append(spec.libs.ld_flags) - libs.append(spec.libs.link_flags) - cairo = self.spec["cairo"] - if cairo.satisfies("~shared"): - if cairo.satisfies("+fc"): - ldflags.append("-L%s" % cairo["fontconfig"].prefix.lib) - libs.append("-lfontconfig") - if cairo.satisfies("+ft"): - ldflags.append("-L%s" % cairo["freetype"].prefix.lib) - libs.append("-lfreetype") - if cairo.satisfies("+png"): - ldflags.append("-L%s" % cairo["libpng"].prefix.lib) - libs.append("-lpng") - ldflags.append("-L%s" % cairo["pixman"].prefix.lib) - libs.append("-lpixman-1") - if ldflags: - args.append("LDFLAGS=%s" % " ".join(ldflags)) + pc = which("pkg-config") + deps = {"zlib": "~shared", "bzip": "~shared", "libpng": "libs=static", "cairo": "~shared"} + for dep in deps.keys(): + if self.spec.satisfies(f"^{dep} {deps[dep]}"): + libs.append(pc(dep, "--static", "--libs", output=str).strip()) + if libs: args.append("LIBS=%s" % " ".join(libs)) return args From 20fcdd1514b3b753188f503b7e549e58acc84354 Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Thu, 19 Oct 2023 01:50:55 -0700 Subject: [PATCH 10/10] update pango (static cairo) --- var/spack/repos/builtin/packages/pango/package.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/var/spack/repos/builtin/packages/pango/package.py b/var/spack/repos/builtin/packages/pango/package.py index 8e423a762d34dd..06c68357b4149e 100644 --- a/var/spack/repos/builtin/packages/pango/package.py +++ b/var/spack/repos/builtin/packages/pango/package.py @@ -127,14 +127,10 @@ def configure_args(self): args.append("GTKDOC_MKPDF={0}".format(true)) args.append("GTKDOC_REBASE={0}".format(true)) - if self.spec["cairo"].satisfies("~shared"): - ldflags = [self.spec["pixman"].libs.search_flags] - libs = [self.spec["pixman"].libs.link_flags] - if self.spec["cairo"].satisfies("+png"): - ldflags.append(self.spec["libpng"].libs.search_flags) - libs.append(self.spec["libpng"].libs.link_flags) - args.append("LDFLAGS=%s" % " ".join(ldflags)) - args.append("LIBS=%s" % " ".join(libs)) + if self.spec.satisfies("^cairo ~shared"): + pkgconfig = which("pkg-config") + cairo_libs = pkgconfig("cairo", "--static", "--libs", output=str).strip() + args.append(f"LIBS={cairo_libs}") return args