Tue Aug 9 11:31:14 2022 UTC ()
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.


(jperkin)
diff -r1.26 -r1.27 pkgsrc/converters/libiconv/buildlink3.mk
diff -r1.40 -r1.41 pkgsrc/devel/gettext-lib/buildlink3.mk
diff -r1.82 -r1.83 pkgsrc/mk/platform/SunOS.mk

cvs diff -r1.26 -r1.27 pkgsrc/converters/libiconv/buildlink3.mk (expand / switch to unified diff)

--- pkgsrc/converters/libiconv/buildlink3.mk 2009/03/20 19:24:03 1.26
+++ pkgsrc/converters/libiconv/buildlink3.mk 2022/08/09 11:31:14 1.27
@@ -1,15 +1,33 @@ @@ -1,15 +1,33 @@
1# $NetBSD: buildlink3.mk,v 1.26 2009/03/20 19:24:03 joerg Exp $ 1# $NetBSD: buildlink3.mk,v 1.27 2022/08/09 11:31:14 jperkin Exp $
2 2
3BUILDLINK_TREE+= iconv 3BUILDLINK_TREE+= iconv
4 4
5.if !defined(ICONV_BUILDLINK3_MK) 5.if !defined(ICONV_BUILDLINK3_MK)
6ICONV_BUILDLINK3_MK:= 6ICONV_BUILDLINK3_MK:=
7 7
8BUILDLINK_API_DEPENDS.iconv+= libiconv>=1.9.1 8BUILDLINK_API_DEPENDS.iconv+= libiconv>=1.9.1
9BUILDLINK_ABI_DEPENDS.iconv+= libiconv>=1.9.1nb4 9BUILDLINK_ABI_DEPENDS.iconv+= libiconv>=1.9.1nb4
10BUILDLINK_PKGSRCDIR.iconv?= ../../converters/libiconv 10BUILDLINK_PKGSRCDIR.iconv?= ../../converters/libiconv
11BUILDLINK_LIBNAME.iconv= iconv 11BUILDLINK_LIBNAME.iconv= iconv
12BUILDLINK_LDADD.iconv= ${BUILDLINK_LIBNAME.iconv:S/^/-l/:S/^-l$//} 12BUILDLINK_LDADD.iconv= ${BUILDLINK_LIBNAME.iconv:S/^/-l/:S/^-l$//}
 13
 14.include "../../mk/bsd.fast.prefs.mk"
 15
 16#
 17# Due to Linux shipping libiconv in libc, third-party software often forgets to
 18# explicitly look for and add -liconv when required. On systems that use GNU
 19# ld this isn't always an issue as it will often be pulled in via an explicit
 20# library, but some systems have a stricter linker that will not pull in
 21# symbols via implicit dependencies, and so we need to explicitly link here.
 22#
 23# Ideally this would be done via CWRAPPERS_LDADD to avoid leaking into LDFLAGS
 24# but there is no concensus on that yet.
 25#
 26.if ${OPSYS_EXPLICIT_LIBDEPS:Uno:tl} == "yes"
 27BUILDLINK_LDFLAGS.iconv+= ${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.iconv}/lib
 28BUILDLINK_LDFLAGS.iconv+= ${BUILDLINK_LDADD.iconv}
 29.endif
 30
13.endif # ICONV_BUILDLINK3_MK 31.endif # ICONV_BUILDLINK3_MK
14 32
15BUILDLINK_TREE+= -iconv 33BUILDLINK_TREE+= -iconv

cvs diff -r1.40 -r1.41 pkgsrc/devel/gettext-lib/buildlink3.mk (expand / switch to unified diff)

--- pkgsrc/devel/gettext-lib/buildlink3.mk 2019/11/03 10:39:12 1.40
+++ pkgsrc/devel/gettext-lib/buildlink3.mk 2022/08/09 11:31:14 1.41
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: buildlink3.mk,v 1.40 2019/11/03 10:39:12 rillig Exp $ 1# $NetBSD: buildlink3.mk,v 1.41 2022/08/09 11:31:14 jperkin Exp $
2 2
3BUILDLINK_TREE+= gettext 3BUILDLINK_TREE+= gettext
4 4
5.if !defined(GETTEXT_BUILDLINK3_MK) 5.if !defined(GETTEXT_BUILDLINK3_MK)
6GETTEXT_BUILDLINK3_MK:= 6GETTEXT_BUILDLINK3_MK:=
7 7
8BUILDLINK_API_DEPENDS.gettext+= gettext-lib>=0.18 8BUILDLINK_API_DEPENDS.gettext+= gettext-lib>=0.18
9BUILDLINK_ABI_DEPENDS.gettext+= gettext-lib>=0.18 9BUILDLINK_ABI_DEPENDS.gettext+= gettext-lib>=0.18
10BUILDLINK_PKGSRCDIR.gettext?= ../../devel/gettext-lib 10BUILDLINK_PKGSRCDIR.gettext?= ../../devel/gettext-lib
11BUILDLINK_LIBNAME.gettext= intl 11BUILDLINK_LIBNAME.gettext= intl
12BUILDLINK_LDADD.gettext= ${BUILDLINK_LIBNAME.gettext:S/^/-l/:S/^-l$//} 12BUILDLINK_LDADD.gettext= ${BUILDLINK_LIBNAME.gettext:S/^/-l/:S/^-l$//}
13BUILDLINK_LDADD.gettext+= ${BUILDLINK_LDADD.iconv} 13BUILDLINK_LDADD.gettext+= ${BUILDLINK_LDADD.iconv}
14 14
@@ -17,26 +17,41 @@ BUILDLINK_LDADD.gettext+= ${BUILDLINK_LD @@ -17,26 +17,41 @@ BUILDLINK_LDADD.gettext+= ${BUILDLINK_LD
17# Some GNU configure scripts generated with an older and broken gettext.m4 17# Some GNU configure scripts generated with an older and broken gettext.m4
18# fail to detect if gettext is present or not because it fails to add 18# fail to detect if gettext is present or not because it fails to add
19# "-lintl" to the linker command line. 19# "-lintl" to the linker command line.
20# 20#
21# If BROKEN_GETTEXT_DETECTION is "yes", then automatically add "-lintl" 21# If BROKEN_GETTEXT_DETECTION is "yes", then automatically add "-lintl"
22# to LIBS to workaround this brokenness. 22# to LIBS to workaround this brokenness.
23# 23#
24BROKEN_GETTEXT_DETECTION?= no 24BROKEN_GETTEXT_DETECTION?= no
25.if !empty(BROKEN_GETTEXT_DETECTION:M[yY][eE][sS]) 25.if !empty(BROKEN_GETTEXT_DETECTION:M[yY][eE][sS])
26BUILDLINK_LIBS.gettext+= ${BUILDLINK_LDADD.gettext} 26BUILDLINK_LIBS.gettext+= ${BUILDLINK_LDADD.gettext}
27CONFIGURE_ENV+= INTLLIBS="${BUILDLINK_LDADD.gettext}" 27CONFIGURE_ENV+= INTLLIBS="${BUILDLINK_LDADD.gettext}"
28.endif 28.endif
29 29
 30#
 31# Due to Linux shipping libintl in libc, third-party software often forgets to
 32# explicitly look for and add -lintl when required. On systems that use GNU
 33# ld this isn't always an issue as it will often be pulled in via an explicit
 34# library, but some systems have a stricter linker that will not pull in
 35# symbols via implicit dependencies, and so we need to explicitly link here.
 36#
 37# Ideally this would be done via CWRAPPERS_LDADD to avoid leaking into LDFLAGS
 38# but there is no concensus on that yet.
 39#
 40.if ${OPSYS_EXPLICIT_LIBDEPS:Uno:tl} == "yes"
 41BUILDLINK_LDFLAGS.gettext+= ${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.gettext}/lib
 42BUILDLINK_LDFLAGS.gettext+= ${BUILDLINK_LDADD.gettext}
 43.endif
 44
30CHECK_BUILTIN.gettext:= yes 45CHECK_BUILTIN.gettext:= yes
31.include "../../devel/gettext-lib/builtin.mk" 46.include "../../devel/gettext-lib/builtin.mk"
32CHECK_BUILTIN.gettext:= no 47CHECK_BUILTIN.gettext:= no
33 48
34# A built-in gettext is always going to use a built-in iconv. 49# A built-in gettext is always going to use a built-in iconv.
35.if !empty(USE_BUILTIN.gettext:M[yY][eE][sS]) 50.if !empty(USE_BUILTIN.gettext:M[yY][eE][sS])
36USE_BUILTIN.iconv= yes 51USE_BUILTIN.iconv= yes
37.else 52.else
38#BUILDLINK_INCDIRS.gettext+= include/gettext 53#BUILDLINK_INCDIRS.gettext+= include/gettext
39BUILDLINK_FNAME_TRANSFORM.gettext+= -e 's|include/gettext/|include/|' 54BUILDLINK_FNAME_TRANSFORM.gettext+= -e 's|include/gettext/|include/|'
40.endif 55.endif
41 56
42.include "../../converters/libiconv/buildlink3.mk" 57.include "../../converters/libiconv/buildlink3.mk"

cvs diff -r1.82 -r1.83 pkgsrc/mk/platform/SunOS.mk (expand / switch to unified diff)

--- pkgsrc/mk/platform/SunOS.mk 2021/11/29 16:14:23 1.82
+++ pkgsrc/mk/platform/SunOS.mk 2022/08/09 11:31:14 1.83
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: SunOS.mk,v 1.82 2021/11/29 16:14:23 jperkin Exp $ 1# $NetBSD: SunOS.mk,v 1.83 2022/08/09 11:31:14 jperkin Exp $
2# 2#
3# Variable definitions for the SunOS/Solaris operating system. 3# Variable definitions for the SunOS/Solaris operating system.
4 4
5ECHO_N?= ${ECHO} -n 5ECHO_N?= ${ECHO} -n
6IMAKE_MAKE?= ${MAKE} # program which gets invoked by imake 6IMAKE_MAKE?= ${MAKE} # program which gets invoked by imake
7PKGLOCALEDIR?= lib 7PKGLOCALEDIR?= lib
8PS?= /bin/ps 8PS?= /bin/ps
9# XXX: default from defaults/mk.conf. Verify/correct for this platform 9# XXX: default from defaults/mk.conf. Verify/correct for this platform
10# and remove this comment. 10# and remove this comment.
11SU?= /usr/bin/su 11SU?= /usr/bin/su
12TYPE?= /usr/bin/type 12TYPE?= /usr/bin/type
13 13
14CATMAN_SECTION_SUFFIX?= yes 14CATMAN_SECTION_SUFFIX?= yes
@@ -129,17 +129,20 @@ _OPSYS_SYSTEM_RPATH?= /lib${LIBABISUFFIX @@ -129,17 +129,20 @@ _OPSYS_SYSTEM_RPATH?= /lib${LIBABISUFFIX
129_OPSYS_LIB_DIRS?= /lib${LIBABISUFFIX} /usr/lib${LIBABISUFFIX} 129_OPSYS_LIB_DIRS?= /lib${LIBABISUFFIX} /usr/lib${LIBABISUFFIX}
130_OPSYS_INCLUDE_DIRS?= /usr/include 130_OPSYS_INCLUDE_DIRS?= /usr/include
131 131
132# Sun Studio support is untested at this time, but would be strongly desired. 132# Sun Studio support is untested at this time, but would be strongly desired.
133.if ${PKGSRC_COMPILER} != "sunpro" 133.if ${PKGSRC_COMPILER} != "sunpro"
134_OPSYS_SUPPORTS_CWRAPPERS= yes 134_OPSYS_SUPPORTS_CWRAPPERS= yes
135.endif 135.endif
136 136
137_OPSYS_SUPPORTS_CTF= yes # Compact Type Format conversion. 137_OPSYS_SUPPORTS_CTF= yes # Compact Type Format conversion.
138_OPSYS_SUPPORTS_FORTIFY= yes # Requires GCC 138_OPSYS_SUPPORTS_FORTIFY= yes # Requires GCC
139_OPSYS_SUPPORTS_SSP?= yes # Requires GCC 139_OPSYS_SUPPORTS_SSP?= yes # Requires GCC
140_OPSYS_CAN_CHECK_SHLIBS= yes # Requires readelf 140_OPSYS_CAN_CHECK_SHLIBS= yes # Requires readelf
141 141
 142# The Solaris/illumos linker requires explicit library dependencies.
 143OPSYS_EXPLICIT_LIBDEPS= yes
 144
142# check for maximum command line length and set it in configure's environment, 145# check for maximum command line length and set it in configure's environment,
143# to avoid a test required by the libtool script that takes forever. 146# to avoid a test required by the libtool script that takes forever.
144# FIXME: Adjust to work on this system and enable the lines below. 147# FIXME: Adjust to work on this system and enable the lines below.
145#_OPSYS_MAX_CMDLEN_CMD= /sbin/sysctl -n kern.argmax 148#_OPSYS_MAX_CMDLEN_CMD= /sbin/sysctl -n kern.argmax