From c110bcc5af64a0d93200b58861a9cb65c751ffbd Mon Sep 17 00:00:00 2001 From: Chris Green Date: Tue, 2 May 2023 20:18:30 -0500 Subject: libintl, iconv, gettext: account for libc provider and externals (#35450) * libiconv can be provided by libc, so update packages which depend on libiconv to require the iconv virtual instead * Many packages need special consideration when locating iconv depending on whether it is provided by libc (no prefix provided) or the libiconv package (in that case we want to provide a prefix) * It was also noticed that when an iconv external was provided, that there was interference with linking (this should generally be handled by Spack's compiler wrappers and bears further investigation) * Like iconv, libintl can be provided by libc or another package, namely gettext. It is not converted to a provider like libiconv because it provides additional routines. The logic is similar to that of iconv but instead of checking the provider, we check whether the gettext installation includes libintl. --- var/spack/repos/builtin/packages/acl/package.py | 6 ++-- var/spack/repos/builtin/packages/apex/package.py | 3 +- var/spack/repos/builtin/packages/bash/package.py | 10 ++++-- var/spack/repos/builtin/packages/bcache/package.py | 10 +++--- var/spack/repos/builtin/packages/bind9/package.py | 2 +- .../repos/builtin/packages/binutils/package.py | 15 +++++---- .../repos/builtin/packages/elfutils/package.py | 22 +++++++++++-- var/spack/repos/builtin/packages/extrae/package.py | 12 +++++-- var/spack/repos/builtin/packages/ffmpeg/package.py | 2 +- var/spack/repos/builtin/packages/fsl/package.py | 4 +-- var/spack/repos/builtin/packages/gdal/package.py | 8 +++-- .../repos/builtin/packages/gettext/package.py | 7 +++- var/spack/repos/builtin/packages/git/package.py | 27 ++++++++++++---- var/spack/repos/builtin/packages/glib/package.py | 13 +++++--- var/spack/repos/builtin/packages/gnupg/package.py | 7 ++-- var/spack/repos/builtin/packages/groff/package.py | 6 +++- var/spack/repos/builtin/packages/krb5/package.py | 7 ++-- var/spack/repos/builtin/packages/lftp/package.py | 15 +++++++-- .../repos/builtin/packages/libarchive/package.py | 13 ++++++-- var/spack/repos/builtin/packages/libxpm/package.py | 10 +++--- var/spack/repos/builtin/packages/mono/package.py | 7 ++-- var/spack/repos/builtin/packages/neovim/package.py | 4 +-- .../repos/builtin/packages/nfs-utils/package.py | 5 ++- .../builtin/packages/oci-systemd-hook/package.py | 8 +++-- var/spack/repos/builtin/packages/opencv/package.py | 2 +- var/spack/repos/builtin/packages/procps/package.py | 37 +++++++++++++++++----- .../repos/builtin/packages/pulseaudio/package.py | 2 +- .../builtin/packages/py-onnxruntime/package.py | 2 +- var/spack/repos/builtin/packages/qt/package.py | 9 +++--- .../repos/builtin/packages/r-rjava/package.py | 2 +- .../repos/builtin/packages/rpcsvc-proto/package.py | 5 ++- .../repos/builtin/packages/rrdtool/package.py | 11 ++++--- .../repos/builtin/packages/subversion/package.py | 19 ++++++----- .../repos/builtin/packages/systemtap/package.py | 7 ++-- var/spack/repos/builtin/packages/tar/package.py | 24 ++++++++------ .../builtin/packages/universal-ctags/package.py | 2 +- var/spack/repos/builtin/packages/xfd/package.py | 5 ++- .../repos/builtin/packages/xfsdump/package.py | 6 ++-- .../repos/builtin/packages/xfsprogs/package.py | 14 ++++---- 39 files changed, 243 insertions(+), 127 deletions(-) diff --git a/var/spack/repos/builtin/packages/acl/package.py b/var/spack/repos/builtin/packages/acl/package.py index 020400762e..1dbb16dfba 100644 --- a/var/spack/repos/builtin/packages/acl/package.py +++ b/var/spack/repos/builtin/packages/acl/package.py @@ -26,8 +26,10 @@ class Acl(AutotoolsPackage): depends_on("attr") depends_on("gettext") - def setup_build_environment(self, env): - env.append_flags("LDFLAGS", "-lintl") + def flag_handler(self, name, flags): + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return self.build_system_flags(name, flags) def autoreconf(self, spec, prefix): bash = which("bash") diff --git a/var/spack/repos/builtin/packages/apex/package.py b/var/spack/repos/builtin/packages/apex/package.py index a6f9c05563..f1590023bf 100644 --- a/var/spack/repos/builtin/packages/apex/package.py +++ b/var/spack/repos/builtin/packages/apex/package.py @@ -154,7 +154,8 @@ class Apex(CMakePackage): args.append("-DBFD_ROOT={0}".format(spec["binutils"].prefix)) if "+binutils ^binutils+nls" in spec: - args.append("-DCMAKE_SHARED_LINKER_FLAGS=-lintl") + if "intl" in self.spec["gettext"].libs.names: + args.append("-DCMAKE_SHARED_LINKER_FLAGS=-lintl") if "+otf2" in spec: args.append("-DOTF2_ROOT={0}".format(spec["otf2"].prefix)) diff --git a/var/spack/repos/builtin/packages/bash/package.py b/var/spack/repos/builtin/packages/bash/package.py index 69a8bc72e8..c772e16697 100644 --- a/var/spack/repos/builtin/packages/bash/package.py +++ b/var/spack/repos/builtin/packages/bash/package.py @@ -6,6 +6,7 @@ import re from spack.package import * +from spack.util.environment import is_system_path class Bash(AutotoolsPackage, GNUMirrorPackage): @@ -177,8 +178,7 @@ class Bash(AutotoolsPackage, GNUMirrorPackage): def configure_args(self): spec = self.spec - - return [ + args = [ # https://github.com/Homebrew/legacy-homebrew/pull/23234 # https://trac.macports.org/ticket/40603 "CFLAGS=-DSSH_SOURCE_BASHRC", @@ -186,8 +186,12 @@ class Bash(AutotoolsPackage, GNUMirrorPackage): "--with-curses", "--enable-readline", "--with-installed-readline", - "--with-libiconv-prefix={0}".format(spec["iconv"].prefix), ] + if spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(spec["iconv"].prefix): + args.append("--with-libiconv-prefix={0}".format(spec["iconv"].prefix)) + return args def check(self): make("tests") diff --git a/var/spack/repos/builtin/packages/bcache/package.py b/var/spack/repos/builtin/packages/bcache/package.py index 4f24bd9cd7..724e4dff19 100644 --- a/var/spack/repos/builtin/packages/bcache/package.py +++ b/var/spack/repos/builtin/packages/bcache/package.py @@ -24,16 +24,16 @@ class Bcache(MakefilePackage): depends_on("gettext") depends_on("pkgconfig", type="build") - def setup_build_environment(self, env): - # Add -lintl if provided by gettext, otherwise libintl is provided by the system's glibc: - if "gettext" in self.spec and "intl" in self.spec["gettext"].libs.names: - env.append_flags("LDFLAGS", "-lintl") - patch( "func_crc64.patch", sha256="558b35cadab4f410ce8f87f0766424a429ca0611aa2fd247326ad10da115737d", ) + def flag_handler(self, name, flags): + if name == "ldflags" and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return self.env_flags(name, flags) + def install(self, spec, prefix): mkdirp(prefix.bin) install("bcache-register", prefix.bin) diff --git a/var/spack/repos/builtin/packages/bind9/package.py b/var/spack/repos/builtin/packages/bind9/package.py index 8320fa3e59..68b1e9da44 100644 --- a/var/spack/repos/builtin/packages/bind9/package.py +++ b/var/spack/repos/builtin/packages/bind9/package.py @@ -19,7 +19,7 @@ class Bind9(AutotoolsPackage): depends_on("libuv", type="link") depends_on("pkgconfig", type="build") depends_on("openssl", type="link") - depends_on("libiconv", type="link") + depends_on("iconv", type="link") def configure_args(self): args = [ diff --git a/var/spack/repos/builtin/packages/binutils/package.py b/var/spack/repos/builtin/packages/binutils/package.py index b3e3416701..cd11f0f8e5 100644 --- a/var/spack/repos/builtin/packages/binutils/package.py +++ b/var/spack/repos/builtin/packages/binutils/package.py @@ -269,9 +269,12 @@ class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder): # also grab the headers from the bfd directory install(join_path(self.build_directory, "bfd", "*.h"), extradir) - def setup_build_environment(self, env): - if self.spec.satisfies("%cce"): - env.append_flags("LDFLAGS", "-Wl,-z,muldefs") - - if "+nls" in self.spec: - env.append_flags("LDFLAGS", "-lintl") + def flag_handler(self, name, flags): + spec = self.spec + if name == "ldflags": + if spec.satisfies("%cce"): + flags.append("-Wl,-z,muldefs") + elif name == "ldlibs": + if "+nls" in self.spec and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return self.build_system_flags(name, flags) diff --git a/var/spack/repos/builtin/packages/elfutils/package.py b/var/spack/repos/builtin/packages/elfutils/package.py index 53eab7b06e..4cec61c36e 100644 --- a/var/spack/repos/builtin/packages/elfutils/package.py +++ b/var/spack/repos/builtin/packages/elfutils/package.py @@ -7,6 +7,7 @@ import glob import os.path from spack.package import * +from spack.util.environment import is_system_path class Elfutils(AutotoolsPackage, SourcewarePackage): @@ -105,7 +106,12 @@ class Elfutils(AutotoolsPackage, SourcewarePackage): files = glob.glob(os.path.join("*", "Makefile.in")) filter_file("-Werror", "", *files) - flag_handler = AutotoolsPackage.build_system_flags + def flag_handler(self, name, flags): + if name == "ldlibs": + spec = self.spec + if "+nls" in spec and "intl" in spec["gettext"].libs.names: + flags.append("-lintl") + return self.inject_flags(name, flags) def configure_args(self): spec = self.spec @@ -126,9 +132,19 @@ class Elfutils(AutotoolsPackage, SourcewarePackage): # zlib is required args.append("--with-zlib=%s" % spec["zlib"].prefix) + if spec.satisfies("@0.183:"): + if spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(spec["iconv"].prefix): + args.append("--with-libiconv-prefix=" + format(spec["iconv"].prefix)) + if "+nls" in spec: - # configure doesn't use LIBS correctly - args.append("LDFLAGS=-Wl,--no-as-needed -L%s -lintl" % spec["gettext"].prefix.lib) + # Prior to 0.183, only msgfmt is used from gettext. + if spec.satisfies("@0.183:"): + if "intl" not in spec["gettext"].libs.names: + args.append("--without-libintl-prefix") + elif not is_system_path(spec["gettext"].prefix): + args.append("--with-libintl-prefix=" + spec["gettext"].prefix) else: args.append("--disable-nls") diff --git a/var/spack/repos/builtin/packages/extrae/package.py b/var/spack/repos/builtin/packages/extrae/package.py index b645375605..eb646cc54f 100644 --- a/var/spack/repos/builtin/packages/extrae/package.py +++ b/var/spack/repos/builtin/packages/extrae/package.py @@ -127,14 +127,20 @@ class Extrae(AutotoolsPackage): make.add_default_arg("CXXFLAGS=%s" % self.compiler.cxx11_flag) args.append("CXXFLAGS=%s" % self.compiler.cxx11_flag) + return args + + def flag_handler(self, name, flags): # This was added due to: # - configure failure # https://www.gnu.org/software/gettext/FAQ.html#integrating_undefined # - linking error # https://github.com/bsc-performance-tools/extrae/issues/57 - args.append("LDFLAGS=-lintl -pthread") - - return args + if name == "ldlibs": + if "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + elif name == "ldflags": + flags.append("-pthread") + return self.build_system_flags(name, flags) def install(self, spec, prefix): with working_dir(self.build_directory): diff --git a/var/spack/repos/builtin/packages/ffmpeg/package.py b/var/spack/repos/builtin/packages/ffmpeg/package.py index 18f9a4558a..1c080fd088 100644 --- a/var/spack/repos/builtin/packages/ffmpeg/package.py +++ b/var/spack/repos/builtin/packages/ffmpeg/package.py @@ -75,7 +75,7 @@ class Ffmpeg(AutotoolsPackage): variant("libx264", default=False, description="H.264 encoding") depends_on("alsa-lib", when="platform=linux") - depends_on("libiconv") + depends_on("iconv") depends_on("yasm@1.2.0:") depends_on("zlib") diff --git a/var/spack/repos/builtin/packages/fsl/package.py b/var/spack/repos/builtin/packages/fsl/package.py index 2b7c92b430..add8cce02c 100644 --- a/var/spack/repos/builtin/packages/fsl/package.py +++ b/var/spack/repos/builtin/packages/fsl/package.py @@ -31,7 +31,7 @@ class Fsl(Package, CudaPackage): depends_on("expat") depends_on("libx11") depends_on("glu") - depends_on("libiconv") + depends_on("iconv") depends_on("openblas", when="@6:") depends_on("vtk@:8") @@ -40,7 +40,7 @@ class Fsl(Package, CudaPackage): patch("build_log.patch") patch("eddy_Makefile.patch", when="@6.0.4") - patch("iconv.patch") + patch("iconv.patch", when="^libiconv") patch("fslpython_install_v5.patch", when="@:5") patch("fslpython_install_v604.patch", when="@6.0.4") patch("fslpython_install_v605.patch", when="@6.0.5") diff --git a/var/spack/repos/builtin/packages/gdal/package.py b/var/spack/repos/builtin/packages/gdal/package.py index 7e84f04181..b116dd8b62 100644 --- a/var/spack/repos/builtin/packages/gdal/package.py +++ b/var/spack/repos/builtin/packages/gdal/package.py @@ -9,7 +9,7 @@ import sys from spack.build_systems.autotools import AutotoolsBuilder from spack.build_systems.cmake import CMakeBuilder from spack.package import * -from spack.util.environment import filter_system_paths +from spack.util.environment import filter_system_paths, is_system_path class Gdal(CMakePackage, AutotoolsPackage, PythonExtension): @@ -627,7 +627,6 @@ class AutotoolsBuilder(AutotoolsBuilder): self.with_or_without("hdf4", package="hdf"), self.with_or_without("hdf5", package="hdf5"), self.with_or_without("hdfs", package="hadoop"), - self.with_or_without("libiconv-prefix", variant="iconv", package="iconv"), self.with_or_without("idb", package="idb"), self.with_or_without("ingres", package="ingres"), self.with_or_without("jasper", package="jasper"), @@ -681,6 +680,11 @@ class AutotoolsBuilder(AutotoolsBuilder): self.with_or_without("perl"), self.with_or_without("php"), ] + if "+iconv" in self.spec: + if self.spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(self.spec["iconv"].prefix): + args.append("--with-libiconv-prefix=" + self.spec["iconv"].prefix) # Renamed or modified flags if self.spec.satisfies("@3:"): diff --git a/var/spack/repos/builtin/packages/gettext/package.py b/var/spack/repos/builtin/packages/gettext/package.py index b7da6f97b8..4ae7eb59d9 100644 --- a/var/spack/repos/builtin/packages/gettext/package.py +++ b/var/spack/repos/builtin/packages/gettext/package.py @@ -6,6 +6,7 @@ import re from spack.package import * +from spack.util.environment import is_system_path class Gettext(AutotoolsPackage, GNUMirrorPackage): @@ -78,7 +79,6 @@ class Gettext(AutotoolsPackage, GNUMirrorPackage): config_args = [ "--disable-java", "--disable-csharp", - "--with-libiconv-prefix={0}".format(spec["iconv"].prefix), "--with-included-glib", "--with-included-gettext", "--with-included-libcroco", @@ -87,6 +87,11 @@ class Gettext(AutotoolsPackage, GNUMirrorPackage): "--without-cvs", ] + if self.spec["iconv"].name == "libc": + config_args.append("--without-libiconv-prefix") + elif not is_system_path(self.spec["iconv"].prefix): + config_args.append("--with-libiconv-prefix=" + self.spec["iconv"].prefix) + if "+curses" in spec: config_args.append("--with-ncurses-prefix={0}".format(spec["ncurses"].prefix)) else: diff --git a/var/spack/repos/builtin/packages/git/package.py b/var/spack/repos/builtin/packages/git/package.py index 401af82d8f..dfca4fe6a2 100644 --- a/var/spack/repos/builtin/packages/git/package.py +++ b/var/spack/repos/builtin/packages/git/package.py @@ -7,6 +7,7 @@ import os import re from spack.package import * +from spack.util.environment import is_system_path class Git(AutotoolsPackage): @@ -466,12 +467,18 @@ class Git(AutotoolsPackage): # The test avoids failures when git is an external package. # In that case the node in the DAG gets truncated and git DOES NOT # have a gettext dependency. - if "+nls" in self.spec: - if "intl" in self.spec["gettext"].libs.names: - env.append_flags("EXTLIBS", "-L{0} -lintl".format(self.spec["gettext"].prefix.lib)) - env.append_flags("CFLAGS", "-I{0}".format(self.spec["gettext"].prefix.include)) - - if "~perl" in self.spec: + spec = self.spec + if "+nls" in spec: + if "intl" in spec["gettext"].libs.names: + extlib_bits = [] + if not is_system_path(spec["gettext"].prefix): + extlib_bits.append(spec["gettext"].libs.search_flags) + extlib_bits.append("-lintl") + env.append_flags("EXTLIBS", " ".join(extlib_bits)) + if not is_system_path(spec["gettext"].prefix): + env.append_flags("CFLAGS", spec["gettext"].headers.include_flags) + + if "~perl" in spec: env.append_flags("NO_PERL", "1") def configure_args(self): @@ -480,11 +487,17 @@ class Git(AutotoolsPackage): configure_args = [ "--with-curl={0}".format(spec["curl"].prefix), "--with-expat={0}".format(spec["expat"].prefix), - "--with-iconv={0}".format(spec["iconv"].prefix), "--with-openssl={0}".format(spec["openssl"].prefix), "--with-zlib={0}".format(spec["zlib"].prefix), ] + if not self.spec["iconv"].name == "libc": + configure_args.append( + "--with-iconv={0}".format( + "yes" if is_system_path(spec["iconv"].prefix) else spec["iconv"].prefix + ) + ) + if "+perl" in self.spec: configure_args.append("--with-perl={0}".format(spec["perl"].command.path)) diff --git a/var/spack/repos/builtin/packages/glib/package.py b/var/spack/repos/builtin/packages/glib/package.py index 730fb5e14e..5d53b74c25 100644 --- a/var/spack/repos/builtin/packages/glib/package.py +++ b/var/spack/repos/builtin/packages/glib/package.py @@ -6,6 +6,7 @@ import os.path from spack.package import * +from spack.util.environment import is_system_path class Glib(Package): @@ -210,7 +211,7 @@ class Glib(Package): if self.spec.satisfies("@:2.72"): args.append("-Dgettext=external") if self.spec.satisfies("@:2.74"): - if "libc" in self.spec: + if self.spec["iconv"].name == "libc": args.append("-Diconv=libc") else: if self.spec.satisfies("@2.61.0:"): @@ -244,7 +245,7 @@ class Glib(Package): args.append( "--with-python={0}".format(os.path.basename(self.spec["python"].command.path)) ) - if "libc" in self.spec: + if self.spec["iconv"].name == "libc": args.append("--with-libiconv=maybe") else: args.append("--with-libiconv=gnu") @@ -350,10 +351,14 @@ class Glib(Package): # Packages that link to glib were also picking up -lintl from glib's # glib-2.0.pc file. However, packages such as py-pygobject were # bypassing spack's compiler wrapper for linking and thus not finding - # the gettext library directory. The patch below explitly adds the + # the gettext library directory. The patch below explicitly adds the # appropriate -L path. spec = self.spec - if spec.satisfies("@2.0:2"): + if ( + spec.satisfies("@2.0:2") + and "intl" in self.spec["gettext"].libs.names + and not is_system_path(spec["gettext"].prefix) + ): pattern = "Libs:" repl = "Libs: -L{0} -Wl,-rpath={0} ".format(spec["gettext"].libs.directories[0]) myfile = join_path(self.spec["glib"].libs.directories[0], "pkgconfig", "glib-2.0.pc") diff --git a/var/spack/repos/builtin/packages/gnupg/package.py b/var/spack/repos/builtin/packages/gnupg/package.py index e206fb3dc1..ef989c7371 100644 --- a/var/spack/repos/builtin/packages/gnupg/package.py +++ b/var/spack/repos/builtin/packages/gnupg/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * +from spack.util.environment import is_system_path class Gnupg(AutotoolsPackage): @@ -143,7 +144,6 @@ class Gnupg(AutotoolsPackage): "--disable-regex", "--with-zlib=" + self.spec["zlib"].prefix, "--without-tar", - "--without-libiconv-prefix", "--without-readline", ] @@ -159,9 +159,12 @@ class Gnupg(AutotoolsPackage): "--with-libassuan-prefix=" + self.spec["libassuan"].prefix, "--with-ksba-prefix=" + self.spec["libksba"].prefix, "--with-npth-prefix=" + self.spec["npth"].prefix, - "--with-libiconv-prefix=" + self.spec["iconv"].prefix, ] ) + if self.spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(self.spec["iconv"].prefix): + args.append("--with-libiconv-prefix=" + self.spec["iconv"].prefix) if self.spec.satisfies("@:1"): args.extend( diff --git a/var/spack/repos/builtin/packages/groff/package.py b/var/spack/repos/builtin/packages/groff/package.py index 7fb2ffa999..132348295a 100644 --- a/var/spack/repos/builtin/packages/groff/package.py +++ b/var/spack/repos/builtin/packages/groff/package.py @@ -6,6 +6,7 @@ import re from spack.package import * +from spack.util.environment import is_system_path class Groff(AutotoolsPackage, GNUMirrorPackage): @@ -77,7 +78,10 @@ class Groff(AutotoolsPackage, GNUMirrorPackage): args.extend(self.with_or_without("x")) if "@1.22.4:" in self.spec: args.extend(self.with_or_without("uchardet")) - args.append("--with-libiconv-prefix={0}".format(self.spec["iconv"].prefix)) + if self.spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(self.spec["iconv"].prefix): + args.append("--with-libiconv-prefix={0}".format(self.spec["iconv"].prefix)) return args def setup_run_environment(self, env): diff --git a/var/spack/repos/builtin/packages/krb5/package.py b/var/spack/repos/builtin/packages/krb5/package.py index 08e70deeb9..493b191490 100644 --- a/var/spack/repos/builtin/packages/krb5/package.py +++ b/var/spack/repos/builtin/packages/krb5/package.py @@ -81,10 +81,7 @@ class Krb5(AutotoolsPackage): return args - def setup_build_environment(self, env): - env.prepend_path("LD_LIBRARY_PATH", self.spec["gettext"].prefix.lib) - def flag_handler(self, name, flags): - if name == "ldlibs": + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: flags.append("-lintl") - return (flags, None, None) + return inject_flags(name, flags) diff --git a/var/spack/repos/builtin/packages/lftp/package.py b/var/spack/repos/builtin/packages/lftp/package.py index d6ee43a95e..6c8df1ad09 100644 --- a/var/spack/repos/builtin/packages/lftp/package.py +++ b/var/spack/repos/builtin/packages/lftp/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * +from spack.util.environment import is_system_path class Lftp(AutotoolsPackage): @@ -19,6 +20,7 @@ class Lftp(AutotoolsPackage): version("4.6.4", sha256="791e783779d3d6b519d0c23155430b9785f2854023eb834c716f5ba78873b15a") depends_on("expat") + depends_on("gettext") depends_on("iconv") depends_on("ncurses") depends_on("openssl") @@ -26,11 +28,20 @@ class Lftp(AutotoolsPackage): depends_on("zlib") def configure_args(self): - return [ + args = [ "--with-expat={0}".format(self.spec["expat"].prefix), - "--with-libiconv={0}".format(self.spec["iconv"].prefix), "--with-openssl={0}".format(self.spec["openssl"].prefix), "--with-readline={0}".format(self.spec["readline"].prefix), "--with-zlib={0}".format(self.spec["zlib"].prefix), "--disable-dependency-tracking", ] + if self.spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(self.spec["iconv"].prefix): + args.append("--with-libiconv-prefix={0}".format(self.spec["iconv"].prefix)) + if "intl" not in self.spec["gettext"].libs.names: + args.append("--without-libintl-prefix") + elif not is_system_path(self.spec["gettext"].prefix): + args.append("--with-libintl-prefix={0}".format(self.spec["gettext"].prefix)) + + return args diff --git a/var/spack/repos/builtin/packages/libarchive/package.py b/var/spack/repos/builtin/packages/libarchive/package.py index 56b9d90f95..c86bf2f4d2 100644 --- a/var/spack/repos/builtin/packages/libarchive/package.py +++ b/var/spack/repos/builtin/packages/libarchive/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * +from spack.util.environment import is_system_path class Libarchive(AutotoolsPackage): @@ -109,7 +110,7 @@ class Libarchive(AutotoolsPackage): depends_on("libxml2", when="xar=libxml2") depends_on("expat", when="xar=expat") - depends_on("libiconv", when="+iconv") + depends_on("iconv", when="+iconv") conflicts( "crypto=mbedtls", when="@:3.4.1", msg="mbed TLS is only supported from libarchive 3.4.2" @@ -119,11 +120,19 @@ class Libarchive(AutotoolsPackage): # The build test suite cannot be built with Intel def configure_args(self): + spec = self.spec args = ["--without-libb2"] args += self.with_or_without("compression") args += self.with_or_without("crypto") - args += self.with_or_without("iconv") args += self.with_or_without("xar") args += self.enable_or_disable("programs") + if "+iconv" in spec: + if spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(spec["iconv"].prefix): + args.append("--with-libiconv-prefix={p}".format(p=spec["iconv"].prefix)) + else: + args.append("--without-iconv") + return args diff --git a/var/spack/repos/builtin/packages/libxpm/package.py b/var/spack/repos/builtin/packages/libxpm/package.py index 26e169e74f..e3f4f2ee35 100644 --- a/var/spack/repos/builtin/packages/libxpm/package.py +++ b/var/spack/repos/builtin/packages/libxpm/package.py @@ -26,9 +26,7 @@ class Libxpm(AutotoolsPackage, XorgPackage): depends_on("pkgconfig", type="build") depends_on("util-macros", type="build") - def setup_build_environment(self, env): - # If libxpm is installed as an external package, gettext won't - # be available in the spec. See - # https://github.com/spack/spack/issues/9149 for details. - if "gettext" in self.spec and "intl" in self.spec["gettext"].libs.names: - env.append_flags("LDFLAGS", "-lintl") + def flag_handler(self, name, flags): + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return env_flags(name, flags) diff --git a/var/spack/repos/builtin/packages/mono/package.py b/var/spack/repos/builtin/packages/mono/package.py index 606e023a55..7525b563a0 100644 --- a/var/spack/repos/builtin/packages/mono/package.py +++ b/var/spack/repos/builtin/packages/mono/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * +from spack.util.environment import is_system_path class Mono(AutotoolsPackage): @@ -74,6 +75,8 @@ class Mono(AutotoolsPackage): def configure_args(self): args = [] - li = self.spec["iconv"].prefix - args.append("--with-libiconv-prefix={p}".format(p=li)) + if self.spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(self.spec["iconv"].prefix): + args.append("--with-libiconv-prefix={p}".format(p=self.spec["iconv"].prefix)) return args diff --git a/var/spack/repos/builtin/packages/neovim/package.py b/var/spack/repos/builtin/packages/neovim/package.py index df14643c0d..c9276ce1f5 100644 --- a/var/spack/repos/builtin/packages/neovim/package.py +++ b/var/spack/repos/builtin/packages/neovim/package.py @@ -94,7 +94,7 @@ class Neovim(CMakePackage): depends_on("jemalloc", type="link", when="platform=linux") depends_on("lua-lpeg") depends_on("lua-mpack") - depends_on("libiconv", type="link") + depends_on("iconv", type="link") depends_on("libtermkey", type="link") depends_on("libuv", type="link") depends_on("libluv", type="link") @@ -117,7 +117,7 @@ class Neovim(CMakePackage): with when("@0.6:"): depends_on("cmake@3.10:", type="build") depends_on("gperf@3.1:", type="link") - depends_on("libiconv@1.15:", type="link") + conflicts("libiconv@:1.14") depends_on("libtermkey@0.22:", type="link") depends_on("libvterm@0.1.4:", type="link") depends_on("msgpack-c@3.0.0:", type="link") diff --git a/var/spack/repos/builtin/packages/nfs-utils/package.py b/var/spack/repos/builtin/packages/nfs-utils/package.py index 1605dfe969..7a1744f147 100644 --- a/var/spack/repos/builtin/packages/nfs-utils/package.py +++ b/var/spack/repos/builtin/packages/nfs-utils/package.py @@ -29,9 +29,8 @@ class NfsUtils(AutotoolsPackage): depends_on("util-linux") depends_on("gettext") - def setup_build_environment(self, env): - env.append_flags("LIBS", "-lintl") - def configure_args(self): args = ["--disable-gss", "--with-rpcgen=internal"] + if "intl" in self.spec["gettext"].libs.names: + args.append("LIBS=-lintl") return args diff --git a/var/spack/repos/builtin/packages/oci-systemd-hook/package.py b/var/spack/repos/builtin/packages/oci-systemd-hook/package.py index 1947e01cca..72d08ad7e3 100644 --- a/var/spack/repos/builtin/packages/oci-systemd-hook/package.py +++ b/var/spack/repos/builtin/packages/oci-systemd-hook/package.py @@ -27,9 +27,11 @@ class OciSystemdHook(AutotoolsPackage): depends_on("util-linux") depends_on("go-md2man") - def configure_args(self): - args = ["LDFLAGS=-lintl"] - return args + def flag_handler(self, name, flags): + if name == "ldlibs": + if "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return self.build_system_flags(name, flags) def install(self, spec, prefix): oci_systemd_hook_jsondir = "oci_systemd_hook_jsondir=" diff --git a/var/spack/repos/builtin/packages/opencv/package.py b/var/spack/repos/builtin/packages/opencv/package.py index 03ac773771..c786183cd5 100644 --- a/var/spack/repos/builtin/packages/opencv/package.py +++ b/var/spack/repos/builtin/packages/opencv/package.py @@ -595,7 +595,7 @@ class Opencv(CMakePackage, CudaPackage): with when("+wechat_qrcode"): conflicts("~dnn") conflicts("~imgproc") - depends_on("libiconv") + depends_on("iconv") with when("+xfeatures2d"): with when("+cuda"): diff --git a/var/spack/repos/builtin/packages/procps/package.py b/var/spack/repos/builtin/packages/procps/package.py index fa06d5558c..5c135e2505 100644 --- a/var/spack/repos/builtin/packages/procps/package.py +++ b/var/spack/repos/builtin/packages/procps/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * +from spack.util.environment import is_system_path class Procps(AutotoolsPackage): @@ -17,6 +18,8 @@ class Procps(AutotoolsPackage): version("master", branch="master") version("3.3.15", tag="v3.3.15") + variant("nls", default=True, description="Enable Native Language Support.") + depends_on("autoconf", type="build") depends_on("automake", type="build") depends_on("libtool", type="build") @@ -24,7 +27,7 @@ class Procps(AutotoolsPackage): depends_on("pkgconfig@0.9.0:", type="build") depends_on("dejagnu", type="test") depends_on("iconv") - depends_on("gettext") + depends_on("gettext", when="+nls") depends_on("ncurses") conflicts("platform=darwin", msg="procps is linux-only") @@ -33,11 +36,29 @@ class Procps(AutotoolsPackage): sh = which("sh") sh("autogen.sh") + def flag_handler(self, name, flags): + if name == "ldlibs": + spec = self.spec + if "+nls" in spec and "intl" in spec["gettext"].libs.names: + flags.append("-lintl") + return self.build_system_flags(name, flags) + def configure_args(self): - return [ - "--with-libiconv-prefix={0}".format(self.spec["iconv"].prefix), - "--with-libintl-prefix={0}".format(self.spec["gettext"].prefix), - "--with-ncurses", - # Required to avoid libintl linking errors - "--disable-nls", - ] + spec = self.spec + args = ["--with-ncurses"] + + if "+nls" in spec: + args.append("--enable-nls") + if "intl" not in spec["gettext"].libs.names: + args.append("--without-libintl-prefix") + elif not is_system_path(spec["gettext"].prefix): + args.append("--with-libintl-prefix=" + spec["gettext"].prefix) + else: + args.append("--disable-nls") + + if spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(spec["iconv"].prefix): + args.append("--with-libiconv-prefix={0}".format(spec["iconv"].prefix)) + + return args diff --git a/var/spack/repos/builtin/packages/pulseaudio/package.py b/var/spack/repos/builtin/packages/pulseaudio/package.py index e975f2a30c..f96d2af990 100644 --- a/var/spack/repos/builtin/packages/pulseaudio/package.py +++ b/var/spack/repos/builtin/packages/pulseaudio/package.py @@ -37,7 +37,7 @@ class Pulseaudio(AutotoolsPackage): depends_on("gconf", when="+gconf") depends_on("json-c@0.11:") depends_on("libcap") - depends_on("libiconv") + depends_on("iconv") depends_on("libsndfile@1.0.18:") depends_on("libtool@2.4:") # links to libltdl.so depends_on("libsm", when="+x11") diff --git a/var/spack/repos/builtin/packages/py-onnxruntime/package.py b/var/spack/repos/builtin/packages/py-onnxruntime/package.py index 7efd37f8ec..68929f6d3c 100644 --- a/var/spack/repos/builtin/packages/py-onnxruntime/package.py +++ b/var/spack/repos/builtin/packages/py-onnxruntime/package.py @@ -52,7 +52,7 @@ class PyOnnxruntime(CMakePackage, PythonExtension): # https://github.com/cms-externals/onnxruntime/compare/5bc92df...d594f80 patch("cms.patch", level=1, when="@1.7.2") # https://github.com/cms-externals/onnxruntime/compare/0d9030e...7a6355a - patch("cms_1_10.patch", whe="@1.10") + patch("cms_1_10.patch", when="@1.10") # https://github.com/microsoft/onnxruntime/issues/4234#issuecomment-698077636 # only needed when iconv is provided by libiconv patch("libiconv.patch", level=0, when="@1.7.2 ^libiconv") diff --git a/var/spack/repos/builtin/packages/qt/package.py b/var/spack/repos/builtin/packages/qt/package.py index 94e7734bef..c388adaca1 100644 --- a/var/spack/repos/builtin/packages/qt/package.py +++ b/var/spack/repos/builtin/packages/qt/package.py @@ -368,10 +368,11 @@ class Qt(Package): # webkit requires libintl (gettext), but does not test for it # correctly, so add it here. def flag_handler(self, name, flags): - if "+webkit" in self.spec and name == "ldlibs": - flags.append("-lintl") - - return (flags, None, None) + if self.name == "ldlibs": + spec = self.spec + if "+webkit" in spec and "intl" in spec["gettext"].libs.names: + flags.append("-lintl") + return self.inject_flags(name, flags) @when("@4 platform=darwin") def patch(self): diff --git a/var/spack/repos/builtin/packages/r-rjava/package.py b/var/spack/repos/builtin/packages/r-rjava/package.py index 034dc19048..812d4daacb 100644 --- a/var/spack/repos/builtin/packages/r-rjava/package.py +++ b/var/spack/repos/builtin/packages/r-rjava/package.py @@ -27,7 +27,7 @@ class RRjava(RPackage): # these are not listed as dependencies but are needed depends_on("bzip2") depends_on("icu4c") - depends_on("libiconv") + depends_on("iconv") depends_on("pcre2") depends_on("xz") depends_on("zlib") diff --git a/var/spack/repos/builtin/packages/rpcsvc-proto/package.py b/var/spack/repos/builtin/packages/rpcsvc-proto/package.py index 98e498409f..85b7c208d3 100644 --- a/var/spack/repos/builtin/packages/rpcsvc-proto/package.py +++ b/var/spack/repos/builtin/packages/rpcsvc-proto/package.py @@ -20,7 +20,10 @@ class RpcsvcProto(AutotoolsPackage): depends_on("gettext") def configure_args(self): - return ["LIBS=-lintl"] + if "intl" in self.spec["gettext"].libs.names: + return ["LIBS=-lintl"] + else: + return [] @run_before("build") def change_makefile(self): diff --git a/var/spack/repos/builtin/packages/rrdtool/package.py b/var/spack/repos/builtin/packages/rrdtool/package.py index f2d1cd7081..413024b47e 100644 --- a/var/spack/repos/builtin/packages/rrdtool/package.py +++ b/var/spack/repos/builtin/packages/rrdtool/package.py @@ -22,8 +22,9 @@ class Rrdtool(AutotoolsPackage): depends_on("perl-extutils-makemaker") def configure_args(self): - args = [ - "LDFLAGS=-lintl", - "--with-systemdsystemunitdir=" + self.spec["rrdtool"].prefix.lib.systemd.system, - ] - return args + return ["--with-systemdsystemunitdir=" + self.spec["rrdtool"].prefix.lib.systemd.system] + + def flag_handler(self, name, flags): + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return self.build_system_flags(name, flags) diff --git a/var/spack/repos/builtin/packages/subversion/package.py b/var/spack/repos/builtin/packages/subversion/package.py index 423d4c4e86..97be031546 100644 --- a/var/spack/repos/builtin/packages/subversion/package.py +++ b/var/spack/repos/builtin/packages/subversion/package.py @@ -6,6 +6,7 @@ import re from spack.package import * +from spack.util.environment import is_system_path class Subversion(AutotoolsPackage): @@ -102,16 +103,14 @@ class Subversion(AutotoolsPackage): args.append("APXS=no") if "+nls" in spec: - args.extend( - [ - "LDFLAGS={0}".format(spec["gettext"].libs.search_flags), - # Using .libs.link_flags is the canonical way to add these arguments, - # but since libintl is much smaller than the rest and also the only - # necessary one, we specify it by hand here. - "LIBS=-lintl", - "--enable-nls", - ] - ) + args.append("--enable-nls") + if "intl" in spec["gettext"].libs.names: + # Using .libs.link_flags is the canonical way to add these arguments, + # but since libintl is much smaller than the rest and also the only + # necessary one, we would specify it by hand here + args.append("LIBS=-lintl") + if not is_system_path(spec["gettext"].prefix): + args.append("LDFLAGS={0}".format(spec["gettext"].libs.search_flags)) else: args.append("--disable-nls") diff --git a/var/spack/repos/builtin/packages/systemtap/package.py b/var/spack/repos/builtin/packages/systemtap/package.py index 99b44fb7e8..939f6cba0f 100644 --- a/var/spack/repos/builtin/packages/systemtap/package.py +++ b/var/spack/repos/builtin/packages/systemtap/package.py @@ -28,6 +28,7 @@ class Systemtap(AutotoolsPackage): depends_on("py-setuptools", type="build") depends_on("python", type=("build", "run")) - def configure_args(self): - args = ["LDFLAGS=-lintl"] - return args + def flag_handler(self, name, flags): + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return self.build_system_flags(name, flags) diff --git a/var/spack/repos/builtin/packages/tar/package.py b/var/spack/repos/builtin/packages/tar/package.py index ff7b9ef4a5..9e0c9b2e50 100644 --- a/var/spack/repos/builtin/packages/tar/package.py +++ b/var/spack/repos/builtin/packages/tar/package.py @@ -6,6 +6,7 @@ import re from spack.package import * +from spack.util.environment import is_system_path class Tar(AutotoolsPackage, GNUMirrorPackage): @@ -62,23 +63,28 @@ class Tar(AutotoolsPackage, GNUMirrorPackage): return match.group(1) if match else None def configure_args(self): + spec = self.spec # Note: compression programs are passed by abs path, # so that tar can locate them when invoked without spack load. args = [ - "--with-libiconv-prefix={0}".format(self.spec["iconv"].prefix), - "--with-xz={0}".format(self.spec["xz"].prefix.bin.xz), - "--with-lzma={0}".format(self.spec["xz"].prefix.bin.lzma), - "--with-bzip2={0}".format(self.spec["bzip2"].prefix.bin.bzip2), + "--with-xz={0}".format(spec["xz"].prefix.bin.xz), + "--with-lzma={0}".format(spec["xz"].prefix.bin.lzma), + "--with-bzip2={0}".format(spec["bzip2"].prefix.bin.bzip2), ] - if "^zstd" in self.spec: - args.append("--with-zstd={0}".format(self.spec["zstd"].prefix.bin.zstd)) + if spec["iconv"].name == "libc": + args.append("--without-libiconv-prefix") + elif not is_system_path(spec["iconv"].prefix): + args.append("--with-libiconv-prefix={0}".format(spec["iconv"].prefix)) + + if "^zstd" in spec: + args.append("--with-zstd={0}".format(spec["zstd"].prefix.bin.zstd)) # Choose gzip/pigz - zip = self.spec.variants["zip"].value + zip = spec.variants["zip"].value if zip == "gzip": - gzip_path = self.spec["gzip"].prefix.bin.gzip + gzip_path = spec["gzip"].prefix.bin.gzip elif zip == "pigz": - gzip_path = self.spec["pigz"].prefix.bin.pigz + gzip_path = spec["pigz"].prefix.bin.pigz args.append("--with-gzip={}".format(gzip_path)) return args diff --git a/var/spack/repos/builtin/packages/universal-ctags/package.py b/var/spack/repos/builtin/packages/universal-ctags/package.py index a336b3c88b..6f7ca076b3 100644 --- a/var/spack/repos/builtin/packages/universal-ctags/package.py +++ b/var/spack/repos/builtin/packages/universal-ctags/package.py @@ -28,7 +28,7 @@ class UniversalCtags(AutotoolsPackage): depends_on("automake", type="build") depends_on("libtool", type="build") depends_on("m4", type="build") - depends_on("libiconv", type="link") + depends_on("iconv", type="link") depends_on("pkgconfig", type="build") def autoreconf(self, spec, prefix): diff --git a/var/spack/repos/builtin/packages/xfd/package.py b/var/spack/repos/builtin/packages/xfd/package.py index 8cd8288197..86bbc0ea2e 100644 --- a/var/spack/repos/builtin/packages/xfd/package.py +++ b/var/spack/repos/builtin/packages/xfd/package.py @@ -32,10 +32,9 @@ class Xfd(AutotoolsPackage, XorgPackage): # Xfd requires libintl (gettext), but does not test for it # correctly, so add it here. def flag_handler(self, name, flags): - if name == "ldlibs": + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: flags.append("-lintl") - - return (flags, None, None) + return self.inject_flags(name, flags) def configure_args(self): args = [] diff --git a/var/spack/repos/builtin/packages/xfsdump/package.py b/var/spack/repos/builtin/packages/xfsdump/package.py index c078ef42db..0a9145bd02 100644 --- a/var/spack/repos/builtin/packages/xfsdump/package.py +++ b/var/spack/repos/builtin/packages/xfsdump/package.py @@ -25,8 +25,10 @@ class Xfsdump(MakefilePackage): depends_on("attr") depends_on("xfsprogs@:4.20.0") - def setup_build_environment(self, env): - env.append_flags("LDFLAGS", "-lintl") + def flag_handler(self, name, flags): + if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return env_flags(name, flags) def build(self, spec, prefix): make( diff --git a/var/spack/repos/builtin/packages/xfsprogs/package.py b/var/spack/repos/builtin/packages/xfsprogs/package.py index 4813635df8..7fa6961591 100644 --- a/var/spack/repos/builtin/packages/xfsprogs/package.py +++ b/var/spack/repos/builtin/packages/xfsprogs/package.py @@ -25,21 +25,19 @@ class Xfsprogs(AutotoolsPackage): depends_on("util-linux") def flag_handler(self, name, flags): - iflags = [] if name == "cflags": if self.spec.satisfies("@:5.4.0 %gcc@10:"): - iflags.append("-fcommon") - return (iflags, None, flags) + flags.append("-fcommon") + elif name == "ldlibs": + if "intl" in self.spec["gettext"].libs.names: + flags.append("-lintl") + return build_system_flags(name, flags) def setup_build_environment(self, env): env.append_path("C_INCLUDE_PATH", self.spec["util-linux"].prefix.include.blkid) def configure_args(self): - args = [ - "LDFLAGS=-lintl", - "--with-systemd-unit-dir=" + self.spec["xfsprogs"].prefix.lib.systemd.system, - ] - return args + return ["--with-systemd-unit-dir=" + self.spec["xfsprogs"].prefix.lib.systemd.system] def install(self, spec, prefix): make("install") -- cgit v1.2.3-60-g2f50