[Mesa-dev] Statically linking libstdc++ and libgcc

Vivek Dasmohapatra vivek at collabora.co.uk
Tue Mar 10 13:07:11 PDT 2015


Hi - As you probably already know, there can only be one version of
libstdc++.so in your runtime link chain - This is usually not a problem,
but when things are linked against the Steam runtime (for example), they
can end up with two - one from the steam runtime, and one pulled in via
the mesa dri libs from the OS/distribution.

In order to address this, Valve asked Collabora to look at enabling
mesa linking with libstdcc+.a/libgcc.a/libgcc_eh.a instead of
listdcc++so and libgcc_s.so.

I think I've figured out a minimally intrusive way to do this, working
around the fact that libtool really, really wants to link those in
if C++ is involved.

I've broken this up into a couple of pieces:

The first patch attached gets libtool to not link in the .so
files in question: It's pretty small - it doesn't introduce a
configure flag to control this behaviour, but I would be happy
to adapt it to do so if that's considered a better approach.

The second and third extend this a little further: Patch #3
is actually to llvm, and builds a parallel libLLVM-X.Y-nostdlib.so
which is likewise linked with libstdc++.a et al instead of .so,
and patch #2 makes the mesa build system use said library if it
is available.

So: Would mesa be interested in patches #1 and/or #2?
If not, is there something I could do to make the patches
more palatable, or some other approach that you'd prefer?

( I'm aware of the configure flags to statically link against
   libLLVM, but when I tried it with llvm-3.5 and a git checkout
   of mesa 10.6-dev I got link errors, hence the LLVM patchset. )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Link-libstdc-and-libgcc-.a-instead-of-.so.patch
Type: text/x-diff
Size: 2514 bytes
Desc: 
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150310/7d6a1d1a/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Use-nostdlib-libLLVM-X.Y-.so-variant-when-present.patch
Type: text/x-diff
Size: 1464 bytes
Desc: 
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150310/7d6a1d1a/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm3.5--really-embed-libstdcxx-and-libgcc.patch
Type: text/x-diff
Size: 4628 bytes
Desc: 
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150310/7d6a1d1a/attachment-0002.patch>


More information about the mesa-dev mailing list