summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjperkin <jperkin@pkgsrc.org>2022-08-09 11:31:14 +0000
committerjperkin <jperkin@pkgsrc.org>2022-08-09 11:31:14 +0000
commitde2c929e25f15120e317bd40fdb81f8e0839d938 (patch)
tree22e7f9244386c1988d9142db8f5d69f5220f13c6
parentecc3fa2c92a5bb2a288c0d579ce803fcbb35b53a (diff)
downloadpkgsrc-de2c929e25f15120e317bd40fdb81f8e0839d938.tar.gz
mk: Add OPSYS_EXPLICIT_LIBDEPS and enable on SunOS.
Most systems use GNU ld, which will happily pull in symbols required by a program even if they are only available via implicit library dependencies. The SunOS linker is stricter, and if a program uses a symbol then the library that defines that symbol must be an explicit dependency. This mostly causes problems with libiconv and libintl, both of which Linux bundles in its C library, so a lot of third-party software does not correctly check for them. Until now we've had to add many, many overrides, along with variables such as BROKEN_GETTEXT_DETECTION which nowadays only has limited effectiveness. The situation appears to be getting worse, especially with software built with meson, and so both libiconv and gettext-lib will now automatically add the correct LDFLAGS if the OPSYS sets OPSYS_EXPLICIT_LIBDEPS=yes. This isn't perfect. For one it isn't really an OPSYS setting as you can try to use GNU ld on SunOS, it just doesn't work very well. It should also really be done via the wrappers rather than exposing LDFLAGS, but we do not yet have an approved patch for doing this. However it does improve the current situation.
-rw-r--r--converters/libiconv/buildlink3.mk20
-rw-r--r--devel/gettext-lib/buildlink3.mk17
-rw-r--r--mk/platform/SunOS.mk5
3 files changed, 39 insertions, 3 deletions
diff --git a/converters/libiconv/buildlink3.mk b/converters/libiconv/buildlink3.mk
index bd61139690a..98e732f49ed 100644
--- a/converters/libiconv/buildlink3.mk
+++ b/converters/libiconv/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.26 2009/03/20 19:24:03 joerg Exp $
+# $NetBSD: buildlink3.mk,v 1.27 2022/08/09 11:31:14 jperkin Exp $
BUILDLINK_TREE+= iconv
@@ -10,6 +10,24 @@ BUILDLINK_ABI_DEPENDS.iconv+= libiconv>=1.9.1nb4
BUILDLINK_PKGSRCDIR.iconv?= ../../converters/libiconv
BUILDLINK_LIBNAME.iconv= iconv
BUILDLINK_LDADD.iconv= ${BUILDLINK_LIBNAME.iconv:S/^/-l/:S/^-l$//}
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+#
+# Due to Linux shipping libiconv in libc, third-party software often forgets to
+# explicitly look for and add -liconv when required. On systems that use GNU
+# ld this isn't always an issue as it will often be pulled in via an explicit
+# library, but some systems have a stricter linker that will not pull in
+# symbols via implicit dependencies, and so we need to explicitly link here.
+#
+# Ideally this would be done via CWRAPPERS_LDADD to avoid leaking into LDFLAGS
+# but there is no concensus on that yet.
+#
+.if ${OPSYS_EXPLICIT_LIBDEPS:Uno:tl} == "yes"
+BUILDLINK_LDFLAGS.iconv+= ${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.iconv}/lib
+BUILDLINK_LDFLAGS.iconv+= ${BUILDLINK_LDADD.iconv}
+.endif
+
.endif # ICONV_BUILDLINK3_MK
BUILDLINK_TREE+= -iconv
diff --git a/devel/gettext-lib/buildlink3.mk b/devel/gettext-lib/buildlink3.mk
index 79f625ff658..79ddc36fc36 100644
--- a/devel/gettext-lib/buildlink3.mk
+++ b/devel/gettext-lib/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.40 2019/11/03 10:39:12 rillig Exp $
+# $NetBSD: buildlink3.mk,v 1.41 2022/08/09 11:31:14 jperkin Exp $
BUILDLINK_TREE+= gettext
@@ -27,6 +27,21 @@ BUILDLINK_LIBS.gettext+= ${BUILDLINK_LDADD.gettext}
CONFIGURE_ENV+= INTLLIBS="${BUILDLINK_LDADD.gettext}"
.endif
+#
+# Due to Linux shipping libintl in libc, third-party software often forgets to
+# explicitly look for and add -lintl when required. On systems that use GNU
+# ld this isn't always an issue as it will often be pulled in via an explicit
+# library, but some systems have a stricter linker that will not pull in
+# symbols via implicit dependencies, and so we need to explicitly link here.
+#
+# Ideally this would be done via CWRAPPERS_LDADD to avoid leaking into LDFLAGS
+# but there is no concensus on that yet.
+#
+.if ${OPSYS_EXPLICIT_LIBDEPS:Uno:tl} == "yes"
+BUILDLINK_LDFLAGS.gettext+= ${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.gettext}/lib
+BUILDLINK_LDFLAGS.gettext+= ${BUILDLINK_LDADD.gettext}
+.endif
+
CHECK_BUILTIN.gettext:= yes
.include "../../devel/gettext-lib/builtin.mk"
CHECK_BUILTIN.gettext:= no
diff --git a/mk/platform/SunOS.mk b/mk/platform/SunOS.mk
index c3ec403cd6b..56e0c6f48f2 100644
--- a/mk/platform/SunOS.mk
+++ b/mk/platform/SunOS.mk
@@ -1,4 +1,4 @@
-# $NetBSD: SunOS.mk,v 1.82 2021/11/29 16:14:23 jperkin Exp $
+# $NetBSD: SunOS.mk,v 1.83 2022/08/09 11:31:14 jperkin Exp $
#
# Variable definitions for the SunOS/Solaris operating system.
@@ -139,6 +139,9 @@ _OPSYS_SUPPORTS_FORTIFY= yes # Requires GCC
_OPSYS_SUPPORTS_SSP?= yes # Requires GCC
_OPSYS_CAN_CHECK_SHLIBS= yes # Requires readelf
+# The Solaris/illumos linker requires explicit library dependencies.
+OPSYS_EXPLICIT_LIBDEPS= yes
+
# check for maximum command line length and set it in configure's environment,
# to avoid a test required by the libtool script that takes forever.
# FIXME: Adjust to work on this system and enable the lines below.