Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: Add --enable-static-LIBRARY options for selective static linking #1024

Merged
merged 2 commits into from
Jun 13, 2019

Conversation

andersk
Copy link
Member

@andersk andersk commented Feb 4, 2019

Statically linking mosh-server with glibc isn’t a great idea for various reasons (nsswitch modules, locale format incompatibilities). But we can provide most of the benefits of static linking by allowing specific library dependencies to be linked statically using -Bstatic and -Bdynamic. The full set at this time is

./configure --enable-static-libstdc++ --enable-static-libgcc \
  --enable-static-utempter --enable-static-zlib --enable-static-curses \
  --enable-static-crypto --enable-static-protobuf

which results in binaries whose only runtime library dependencies are
provided with libc:

$ ldd src/frontend/mosh-server
        linux-vdso.so.1 (0x00007ffe0b377000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fa0d9970000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa0d97e3000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa0d97c2000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa0d95d8000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa0d9f6a000)

@cgull
Copy link
Member

cgull commented Feb 5, 2019

This seems like a good idea, but I would consider adding a --enable-static-libraries umbrella option so that packagers and users don't need to manually track all of Mosh's dynamic dependencies.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
…inking

Statically linking mosh-server with glibc isn’t a great idea for
various reasons (nsswitch modules, locale format incompatibilities).
But we can provide most of the benefits of static linking by allowing
specific library dependencies to be linked statically using -Bstatic
and -Bdynamic.  The full set is enabled by

    ./configure --enable-static-libraries

which is equivalent to

    ./configure --enable-static-libstdc++ --enable-static-libgcc \
      --enable-static-utempter --enable-static-zlib --enable-static-curses \
      --enable-static-crypto --enable-static-protobuf

and results in binaries whose only runtime library dependencies are
provided with libc:

    $ ldd src/frontend/mosh-server
            linux-vdso.so.1 (0x00007ffe0b377000)
            libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fa0d9970000)
            libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa0d97e3000)
            libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa0d97c2000)
            libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa0d95d8000)
            /lib64/ld-linux-x86-64.so.2 (0x00007fa0d9f6a000)

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@andersk
Copy link
Member Author

andersk commented Feb 10, 2019

Sure. I’ve added --enable-static-libraries.

@andersk andersk merged commit f7a054c into mobile-shell:master Jun 13, 2019
@eminence eminence added this to the 1.4.0 milestone Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants