From d464185bba7fc6fb4f81f0687da4889451346cef Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl <43588962+bernhardkaindl@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:39:02 +0100 Subject: bcache: support external gettext when `libintl` is in glibc (#34114) * bcache: support external gettext when `libintl` is in glibc Many glibc-based Linux systems don't have gettext's libintl because libintl is included in the standard system's glibc (libc) itself. When using `spack external find gettext` on those, packages like `bcache` which unconditionally to link using `-lintl` fail to link with -lintl. Description of the fix: The libs property of spack's gettext recipe returns the list of libs, so when gettext provides libintl, use it. When not, there is no separate liblint library and the libintl API is provided by glibc. Tested with `spack external find gettext` on glibc-based Linux and in musl-based Alpine Linux to make sure that when -lintl is really needed, it is really used and nothing breaks. --- var/spack/repos/builtin/packages/bcache/package.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/bcache/package.py b/var/spack/repos/builtin/packages/bcache/package.py index 61ee6ff5ea..6cf3678c85 100644 --- a/var/spack/repos/builtin/packages/bcache/package.py +++ b/var/spack/repos/builtin/packages/bcache/package.py @@ -25,7 +25,9 @@ class Bcache(MakefilePackage): depends_on("pkgconfig", type="build") def setup_build_environment(self, env): - env.append_flags("LDFLAGS", "-lintl") + # Add -lintl if provided by gettext, otherwise libintl is provided by the system's glibc: + if any("libintl" in filename for filename in self.libs): + env.append_flags("LDFLAGS", "-lintl") patch( "func_crc64.patch", -- cgit v1.2.3-60-g2f50