[Libreoffice] right way to control libs and flags on the link line
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Thu Jul 7 09:21:29 PDT 2011
Hi Caolán, Hi all,
On Thu, 07 Jul 2011 16:33:10 +0100
Caolán McNamara <caolanm at redhat.com> wrote:
> You can see that we *do* have -lfontconfig -lfreetype at the start of
> the linker line, and -lcairo at the end of it, but we get undefined
> references to freetype functions.
>
> Easiest fix would be to, for the internal cairo case, to have -lcairo
> -lfreetype -lfontconfig there. So for a quick fix I added fontconfig
> to the plain libs for unxgcc.mk and shoved in freetype + fontconfig
> into Library_vcl.mk for Linux.
>
> That's not really what I want to do, because that drops the exact
> linker options for fontconfig and freetype that we have in
> FONTCONFIG_LIBS and FREETYPE_LIBS.
>
> So, I suppose the main question is: How should I get FONTCONFIG_LIBS
> and FONTCONFIG_LIBS, currently placed into gb_Library_set_ldflags, to
> appear after cairo in the link line.
>
> The other question is, even outside of this specific issue, if the
> current adding of FOO_LIBS into gb_Library_set_ldflags is the right
> way to add those anyway ?
This happens when the linker defaults to --as-needed, making the
link order important. Hacks around this are:
- default to --no-as-needed by having that as first link flag, but that
would be an ugly hack.
- try to use --start-group/--end-group, but that would hurt link
performance.
The real solution would be to use gb_LinkTarget_add_libs, because
linked libs get added in the link command _after_ the objects and only
use ldflags for 'real' linker flags (those changing general behaviour),
so there is no problem anymore. Indecently this is what is being done
very well with the rework of external linking in gnumake4, centralizing
it so that the external-linking-foo is done in one file, and not all
over place. see:
http://cgit.freedesktop.org/libreoffice/bootstrap/tree/RepositoryExternal.mk?h=feature/gnumake4
With which you link for example against zlib from tl as in:
http://cgit.freedesktop.org/libreoffice/libs-gui/tree/tools/Library_tl.mk?h=feature/gnumake4#n126
This should also be easier to migrate to the gold linker one day.
Best,
Bjoern
--
https://launchpad.net/~bjoern-michaelsen
More information about the LibreOffice
mailing list