Subject: Re: --export-dynamic
To: Lubomir Sedlacik <salo@Xtrmntr.org>
From: Johnny C. Lam <jlam@netbsd.org>
List: tech-pkg
Date: 06/21/2002 10:54:14
On Fri, Jun 21, 2002 at 04:23:32PM +0200, Lubomir Sedlacik wrote:
>
> On Sun, Jun 16, 2002 at 08:50:10PM -0500, Eric Schnoebelen wrote:
> > Personal opinion: always test _for_ things. Positive matches are more
> > likely to be correct.
>
> yes, but there is one BUT why i asked this. i don't have any GNU/Linux
> or Mac OS X/Darwin system to check what they want so if they require it
> as well as NetBSD does, i'd like to correct them all at once. i assume
> they all use GNU ld, so it's more effective to exclude SunOS, which uses
> own ld, than name all others. maybe someone with clue can say whether
> is it needed for GNU/Linux and/or Mac OS X/Darwin at all? from manpage
> it seems that it is not required on all systems:
>
> -export-dynamic
> When creating an ELF file, add all symbols to the
> dynamic symbol table. Normally, the dynamic symbol
> table contains only symbols which are used by a dy-
> namic object. This option is needed for some uses
> of dlopen.
As you've pointed out, this flag is only available on systems using GNU ld,
which not even all NetBSD systems use. Darwin and Solaris systems also use
their own linker, so we should definitely do something to conditionalize
the addition of this flag correctly with either something like:
LDFLAGS+= ${EXPORT_SYMBOLS_LDFLAGS}
or:
.if defined(USE_GNU_LD)
LDFLAGS+= -Wl,-export-dynamic
.endif
with appropriate settings in mk/defs.*.mk. Admittedly, not many packages
need this, and it might actually be better to push this directly into the
package with patches. I favor adding:
.if ${OBJECT_FMT} == "ELF"
EXPORT_SYMBOLS_LDFLAGS?= -Wl,-E
.elif ${OBJECT_FMT} == "a.out"
EXPORT_SYMBOLS_LDFLAGS?= -Wl,--export-dynamic
.endif
to defs.NetBSD.mk and putting
EXPORT_SYMBOLS_LDFLAGS?= # empty
in the remaining defs.*.mk files.
Cheers,
-- Johnny Lam <jlam@netbsd.org>