Subject: pkg/18115: pkgsrc framework for properly exporting symbols in linked shared objects for various OS/ld
To: None <gnats-bugs@gnats.netbsd.org>
From: Lubomir Sedlacik <salo@Xtrmntr.org>
List: netbsd-bugs
Date: 08/30/2002 10:02:42
>Number: 18115
>Category: pkg
>Synopsis: pkgsrc framework for properly exporting symbols in linked shared objects for various OS/ld
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Aug 30 01:03:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Lubomir Sedlacik
>Release: NetBSD 1.6_BETA5
>Organization:
>Environment:
>Description:
many packages force -Wl,-export-dynamic which is not portable outside GNU ld
and cause problems e.g. on Solaris. some of these packages use if
conditionals either only for NetBSD or except SunOS, but the state is not
coherent and it may complicate later when support for new OS is added to
pkgsrc (e.g. ongoing work on HP-UX support).
jlam proposed the following framework in discussion on tech-pkg:
http://mail-index.netbsd.org/tech-pkg/2002/06/21/0009.html
now, ${EXPORT_SYMBOLS_LDFLAGS} is used instead of directly defining
-Wl,-export-dynamic which is set in appropriate defs.*.mk to reasonable
values. packages should be converted to this framework by:
1) replacing LDFLAGS+= -Wl,-export-dynamic and LIBS+= -export-dynamic with:
LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
2) for use in patchfiles, add this variable to MAKE_ENV if needed:
MAKE_ENV+= EXPORT_SYMBOLS_LDFLAGS=${EXPORT_SYMBOLS_LDFLAGS}
3) replace occurances of -Wl,-export-dynamic and -export-dynamic in patch
files with:
$(EXPORT_SYMBOLS_LDFLAGS)
>How-To-Repeat:
try to build any package using -Wl,-export-dynamic without checking (e.g.
gimp) and see it failing. also check packages like www/php4 or audio/arts,
etc. for the conditional usage examples.
>Fix:
following patches add support for this framework to mk/defs.*.mk and replace
occurances of -Wl,-export-dynamic in various packages (those which use it
directly in Makefile*). since they are quite simple i'll add them here all.
there are different packages in pkgsrc which define -Wl,-export-dynamic in
patch files, i'll send second round soon.
------------------------------------------------------------------------------
patch for mk/* :
Index: defs.Darwin.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.Darwin.mk,v
retrieving revision 1.27
diff -u -r1.27 defs.Darwin.mk
--- defs.Darwin.mk 28 Aug 2002 11:06:18 -0000 1.27
+++ defs.Darwin.mk 29 Aug 2002 18:29:44 -0000
@@ -87,3 +87,6 @@
_STRIPFLAG_CC?= -Wl,-x # cc(1) option to strip
_STRIPFLAG_INSTALL?= -s # install(1) option to strip
.endif
+
+# Add all symbols to the dynamic symbol table when needed
+EXPORT_SYMBOLS_LDFLAGS?= # empty, keep for compatibility
Index: defs.Linux.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.Linux.mk,v
retrieving revision 1.29
diff -u -r1.29 defs.Linux.mk
--- defs.Linux.mk 28 Aug 2002 11:06:18 -0000 1.29
+++ defs.Linux.mk 29 Aug 2002 18:29:44 -0000
@@ -91,3 +91,6 @@
_STRIPFLAG_CC?= -s # cc(1) option to strip
_STRIPFLAG_INSTALL?= -s # install(1) option to strip
.endif
+
+# Add all symbols to the dynamic symbol table when needed
+EXPORT_SYMBOLS_LDFLAGS?= # empty, keep for compatibility
Index: defs.NetBSD.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.NetBSD.mk,v
retrieving revision 1.27
diff -u -r1.27 defs.NetBSD.mk
--- defs.NetBSD.mk 28 Aug 2002 11:06:19 -0000 1.27
+++ defs.NetBSD.mk 29 Aug 2002 18:29:44 -0000
@@ -126,3 +126,10 @@
FFLAGS+= -mieee
. endif # MACHINE_PLATFORM
.endfor # __tmp__
+
+# Add all symbols to the dynamic symbol table when needed
+.if ${OBJECT_FMT} == "ELF"
+EXPORT_SYMBOLS_LDFLAGS?= -Wl,-E
+.elif ${OBJECT_FMT} == "a.out"
+EXPORT_SYMBOLS_LDFLAGS?= -Wl,--export-dynamic
+.endif
Index: defs.SunOS.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.SunOS.mk,v
retrieving revision 1.27
diff -u -r1.27 defs.SunOS.mk
--- defs.SunOS.mk 28 Aug 2002 11:06:19 -0000 1.27
+++ defs.SunOS.mk 29 Aug 2002 18:29:44 -0000
@@ -124,3 +124,5 @@
HAVE_OPENWINDOWS= YES
.endif
+# Add all symbols to the dynamic symbol table when needed
+EXPORT_SYMBOLS_LDFLAGS?= # empty, keep for compatibility
------------------------------------------------------------------------------
patch for audio/arts :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/audio/arts/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- Makefile 28 Aug 2002 07:15:25 -0000 1.7
+++ Makefile 29 Aug 2002 17:42:10 -0000
@@ -14,11 +14,8 @@
USE_PERL5= build
-.include "../../mk/bsd.prefs.mk"
-
-.if ${OPSYS} == "NetBSD"
-LIBS+= -Wl,--export-dynamic
-.endif
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
.include "../../audio/libaudiofile/buildlink.mk"
.include "../../x11/kde3/buildlink.mk"
------------------------------------------------------------------------------
patch for audio/kdemultimedia2 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/audio/kdemultimedia2/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- Makefile 1 Aug 2002 05:48:04 -0000 1.12
+++ Makefile 29 Aug 2002 17:42:37 -0000
@@ -15,11 +15,8 @@
CONFIGURE_ENV+= ac_cv_path_kde_artsplug_compiles="${ARTSCCONFIG}"
-.include "../../mk/bsd.prefs.mk"
-
-.if ${OPSYS} == "NetBSD"
-LIBS= -Wl,--export-dynamic
-.endif
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
.include "../../x11/kde2/buildlink.mk"
.include "../../x11/kdebase2/buildlink.mk"
------------------------------------------------------------------------------
patch for audio/kdemultimedia3 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/audio/kdemultimedia3/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile 28 Aug 2002 07:15:26 -0000 1.4
+++ Makefile 29 Aug 2002 17:43:19 -0000
@@ -10,11 +10,8 @@
USE_BUILDLINK_ONLY= YES
-.include "../../mk/bsd.prefs.mk"
-
-.if ${OPSYS} == "NetBSD"
-LIBS= -Wl,--export-dynamic
-.endif
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
PTHREAD_OPT+= require
------------------------------------------------------------------------------
patch for graphics/dx :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/graphics/dx/Makefile,v
retrieving revision 1.15
diff -u -r1.15 Makefile
--- Makefile 23 Apr 2002 02:08:53 -0000 1.15
+++ Makefile 29 Aug 2002 17:44:36 -0000
@@ -17,7 +17,7 @@
CONFIGURE_ENV+= LEX="flex -l"
# Ensure we export symbols in the linked shared object.
-LDFLAGS+= -Wl,--export-dynamic
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
CPPFLAGS+= -I${BUILDLINK_DIR}/include/freetype # freetype.h
------------------------------------------------------------------------------
patch for graphics/gimp-base :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/graphics/gimp-base/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- Makefile 17 Mar 2002 02:40:57 -0000 1.3
+++ Makefile 29 Aug 2002 17:48:23 -0000
@@ -33,7 +33,9 @@
CONFIGURE_ENV+= LIBMPEG="-lmpeg_lib"
CONFIGURE_ENV+= GAP_DECODE_MPEG="gap_decode_mpeg"
-LDFLAGS+= -Wl,--export-dynamic
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
+
MAKE_ENV+= X11BASE=${X11BASE}
PLIST_SUBST+= LOCALBASE=${LOCALBASE}
------------------------------------------------------------------------------
patch for graphics/kdegraphics2 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/graphics/kdegraphics2/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- Makefile 13 Mar 2002 17:37:11 -0000 1.8
+++ Makefile 29 Aug 2002 17:49:30 -0000
@@ -16,11 +16,8 @@
CONFIGURE_ARGS+= --without-kamera # requires gPhoto2, gpio
-.include "../../mk/bsd.prefs.mk"
-
-.if ${OPSYS} == "NetBSD"
-LIBS= -Wl,--export-dynamic
-.endif
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
.include "../../graphics/tiff/buildlink.mk"
.include "../../x11/kde2/buildlink.mk"
------------------------------------------------------------------------------
patch for graphics/kdegraphics3 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/graphics/kdegraphics3/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile 28 Aug 2002 07:15:28 -0000 1.4
+++ Makefile 29 Aug 2002 17:50:00 -0000
@@ -14,11 +14,8 @@
CONFIGURE_ARGS+= --without-kamera # requires gPhoto2, gpio
-.include "../../mk/bsd.prefs.mk"
-
-.if ${OPSYS} == "NetBSD"
-LIBS= -Wl,--export-dynamic
-.endif
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
#.include "../../graphics/tiff/buildlink.mk"
.include "../../graphics/imlib/buildlink.mk"
------------------------------------------------------------------------------
patch for misc/kdeutils2 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/misc/kdeutils2/Makefile,v
retrieving revision 1.10
diff -u -r1.10 Makefile
--- Makefile 13 Mar 2002 17:37:27 -0000 1.10
+++ Makefile 29 Aug 2002 17:51:16 -0000
@@ -10,11 +10,12 @@
USE_BUILDLINK_ONLY= YES
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
+
.include "../../mk/bsd.prefs.mk"
.if ${OPSYS} == "NetBSD"
-LIBS= -Wl,--export-dynamic
-
. if exists(/usr/include/machine/apmvar.h)
CPPFLAGS+= -D__NetBSD_APM__
. endif
------------------------------------------------------------------------------
patch for misc/kdeutils3 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/misc/kdeutils3/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- Makefile 28 Aug 2002 07:15:37 -0000 1.3
+++ Makefile 29 Aug 2002 17:51:46 -0000
@@ -7,11 +7,12 @@
USE_BUILDLINK_ONLY= YES
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
+
.include "../../mk/bsd.prefs.mk"
.if ${OPSYS} == "NetBSD"
-LIBS= -Wl,--export-dynamic
-
. if exists(/usr/include/machine/apmvar.h)
CPPFLAGS+= -D__NetBSD_APM__
. endif
------------------------------------------------------------------------------
patch for misc/koffice :
Index: Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/misc/koffice/Makefile.common,v
retrieving revision 1.1
diff -u -r1.1 Makefile.common
--- Makefile.common 20 Jun 2002 19:13:50 -0000 1.1
+++ Makefile.common 29 Aug 2002 17:53:25 -0000
@@ -11,9 +11,10 @@
REPLACE_PERL= kpresenter/kprconverter.pl
-.if ${OPSYS} == "NetBSD"
-LIBS+= -Wl,--export-dynamic
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
+.if ${OPSYS} == "NetBSD"
# On egcs-1.1.2, the C++ compiler system isn't quite ISO-compliant. It lacks
# a std::auto_ptr implementation in <memory>, doesn't handle static inline
# functions in headers properly (although that concept, in itself, is quite
------------------------------------------------------------------------------
patch for www/ap-php4 :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/www/ap-php4/Makefile,v
retrieving revision 1.22
diff -u -r1.22 Makefile
--- Makefile 25 Aug 2002 21:51:51 -0000 1.22
+++ Makefile 29 Aug 2002 17:54:34 -0000
@@ -12,9 +12,7 @@
.include "../../www/php4/Makefile.php"
# Ensure we export symbols in the linked shared object.
-.if ${OPSYS} != "SunOS"
-LDFLAGS+= -Wl,--export-dynamic
-.endif
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
do-install:
${INSTALL_DATA} ${WRKSRC}/.libs/libphp4.so \
------------------------------------------------------------------------------
patch for www/php4 (also needs regen of distinfo due to changed patch!) :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/www/php4/Makefile,v
retrieving revision 1.25
diff -u -r1.25 Makefile
--- Makefile 26 Aug 2002 00:16:57 -0000 1.25
+++ Makefile 29 Aug 2002 18:03:29 -0000
@@ -27,9 +27,8 @@
.endif
# Ensure we export symbols in the linked shared object.
-.if ${OPSYS} != "SunOS"
-LDFLAGS+= -Wl,--export-dynamic
-.endif
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
+MAKE_ENV+= EXPORT_SYMBOLS_LDFLAGS="${EXPORT_SYMBOLS_LDFLAGS}"
CONF_FILES= ${EGDIR}/php.ini-recommended ${PKG_SYSCONFDIR}/php.ini
OWN_DIRS= ${PREFIX}/${PHP_EXTENSION_DIR}
Index: Makefile.module
===================================================================
RCS file: /cvsroot/pkgsrc/www/php4/Makefile.module,v
retrieving revision 1.17
diff -u -r1.17 Makefile.module
--- Makefile.module 26 Aug 2002 00:16:57 -0000 1.17
+++ Makefile.module 29 Aug 2002 18:03:29 -0000
@@ -32,10 +32,9 @@
USE_LIBTOOL= YES
LTCONFIG_OVERRIDE= ${WRKSRC}/ltconfig
-# Ensure we export symbols in the linked shared objects.
-.if ${OPSYS} != "SunOS"
-LDFLAGS+= -Wl,--export-dynamic
-.endif
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
+MAKE_ENV+= EXPORT_SYMBOLS_LDFLAGS="${EXPORT_SYMBOLS_LDFLAGS}"
PLIST_SRC= ${.CURDIR}/../../www/php4/PLIST.module
MESSAGE_SRC= ${.CURDIR}/../../www/php4/MESSAGE.module
Index: patches/patch-aa
===================================================================
RCS file: /cvsroot/pkgsrc/www/php4/patches/patch-aa,v
retrieving revision 1.7
diff -u -r1.7 patch-aa
--- patches/patch-aa 16 Oct 2001 04:54:24 -0000 1.7
+++ patches/patch-aa 29 Aug 2002 18:03:29 -0000
@@ -7,7 +7,7 @@
PROGRAM_SOURCES = stub.c
PROGRAM_LDADD = libphp4.la $(EXT_PROGRAM_LDADD)
-PROGRAM_LDFLAGS = -export-dynamic
-+PROGRAM_LDFLAGS = -static -export-dynamic $(LINK_LIBGCC_LDFLAGS)
++PROGRAM_LDFLAGS = -static $(EXPORT_SYMBOLS_LDFLAGS) $(LINK_LIBGCC_LDFLAGS)
PROGRAM_DEPENDENCIES = $(PROGRAM_LDADD)
targets = $(LTLIBRARY_NAME) $(PHP_PROGRAM)
------------------------------------------------------------------------------
patch for www/php3 :
Index: Makefile.module
===================================================================
RCS file: /cvsroot/pkgsrc/www/php3/Makefile.module,v
retrieving revision 1.3
diff -u -r1.3 Makefile.module
--- Makefile.module 24 Jul 2002 19:45:31 -0000 1.3
+++ Makefile.module 29 Aug 2002 18:04:34 -0000
@@ -24,8 +24,8 @@
LD_SHAREABLE_FLAG= -Bshareable
.endif
-# Ensure we export symbols in the linked shared objects.
-LDFLAGS+= -Wl,--export-dynamic
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
MOD_CPPFLAGS+= -I${WRKSRC} -I${MODULESDIR} -fPIC -DPIC -DCOMPILE_DL
MOD_LDFLAGS+= ${LDFLAGS:S/-Wl,//g}
------------------------------------------------------------------------------
patch for www/galeon :
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/www/galeon/Makefile,v
retrieving revision 1.33
diff -u -r1.33 Makefile
--- Makefile 16 Jul 2002 13:16:05 -0000 1.33
+++ Makefile 29 Aug 2002 17:56:37 -0000
@@ -36,11 +36,9 @@
MOZ_LIBDIR= ${PREFIX}/lib/mozilla
LDFLAGS+= -Wl,-R${MOZ_LIBDIR}
-.if(${OBJECT_FMT} == ELF)
-LDFLAGS+= -export-dynamic
-.else
-LIBS+= -lstdc++
-.endif
+
+# Ensure we export symbols in the linked shared object.
+LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
pre-install:
${X11PREFIX}/bin/gconftool --shutdown
>Release-Note:
>Audit-Trail:
>Unformatted: