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

autotools: Enable building static liblxc #2265

Closed
brauner opened this Issue Apr 9, 2018 · 5 comments

Comments

4 participants
@brauner
Copy link
Member

brauner commented Apr 9, 2018

This was something that @tych0 once requested. @tych0 did you ever manage to make this work and have a patch ready?

@tych0

This comment has been minimized.

Copy link
Member

tych0 commented Apr 9, 2018

@t3hmrman

This comment has been minimized.

Copy link

t3hmrman commented May 24, 2018

Just wanted to note that I tried to start figuring out how to set this up (on Alpine), thinking I could just use --enable-static and --disable-shared with configure.

That ended relatively quickly with an error due to not being able to find liblxc.la -- is this one of the things that don't have static versions?

/bin/bash ../../libtool  --tag=CC   --mode=link gcc -fPIC -DPIC -DLXCROOTFSMOUNT=\"/usr/lib/lxc/rootfs\" -DLXCPATH=\"/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/usr/libexec\" -DLIBEXECDIR=\"/usr/libexec\" -DLXCTEMPLATEDIR=\"/usr/share/lxc/template
s\" -DLXCTEMPLATECONFIG=\"/usr/share/lxc/config\" -DLOGPATH=\"/var/log/lxc\" -DLXC_DEFAULT_CONFIG=\"/etc/lxc/default.conf\" -DLXC_USERNIC_DB=\"/run/lxc/nics\" -DLXC_USERNIC_CONF=\"/etc/lxc/lxc-usernet\" -DDEFAULT_CGROUP_PATTERN=\"lxc/%n\" -DRUNTIME_PATH=\"/run\" -DSBINDIR=\
"/usr/sbin\" -I ../../src -I ../../src/lxc -I ../../src/lxc/storage -I ../../src/lxc/cgroups     -DHAVE_SECCOMP  -pthread  -Os -fomit-frame-pointer -Wall -pthread -shared -Wl,-soname,liblxc.so.1 -version-info 1 -Wl,--as-needed -o liblxc.la -rpath /usr/lib liblxc_la-argument
s.lo storage/liblxc_la-storage.lo storage/liblxc_la-aufs.lo storage/liblxc_la-btrfs.lo storage/liblxc_la-dir.lo storage/liblxc_la-loop.lo storage/liblxc_la-lvm.lo storage/liblxc_la-nbd.lo storage/liblxc_la-overlay.lo storage/liblxc_la-rbd.lo storage/liblxc_la-rsync.lo stora
ge/liblxc_la-zfs.lo storage/liblxc_la-storage_utils.lo cgroups/liblxc_la-cgfs.lo cgroups/liblxc_la-cgfsng.lo cgroups/liblxc_la-cgroup_utils.lo cgroups/liblxc_la-cgroup.lo liblxc_la-commands.lo liblxc_la-commands_utils.lo liblxc_la-start.lo liblxc_la-execute.lo liblxc_la-mon
itor.lo liblxc_la-console.lo liblxc_la-freezer.lo liblxc_la-error.lo liblxc_la-parse.lo liblxc_la-initutils.lo liblxc_la-utils.lo liblxc_la-sync.lo liblxc_la-namespace.lo liblxc_la-conf.lo liblxc_la-confile.lo liblxc_la-confile_legacy.lo liblxc_la-confile_utils.lo liblxc_la
-state.lo liblxc_la-log.lo liblxc_la-attach.lo liblxc_la-criu.lo liblxc_la-network.lo liblxc_la-nl.lo liblxc_la-rtnl.lo liblxc_la-genl.lo liblxc_la-caps.lo liblxc_la-mainloop.lo liblxc_la-af_unix.lo liblxc_la-lxclock.lo liblxc_la-lxccontainer.lo lsm/liblxc_la-nop.lo lsm/lib
lxc_la-lsm.lo       liblxc_la-seccomp.lo -lcap   -lseccomp   -lutil -lpthread -lcap
libtool: link: gcc -DLXCROOTFSMOUNT=\"/usr/lib/lxc/rootfs\" -DLXCPATH=\"/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/usr/libexec\" -DLIBEXECDIR=\"/usr/libexec\" -DLXCTEMPLATEDIR=\"/usr/share/lxc/templates\" -DLXCTEMPLATECONFIG=\"/usr/share/lxc/conf
ig\" -DLOGPATH=\"/var/log/lxc\" -DLXC_DEFAULT_CONFIG=\"/etc/lxc/default.conf\" -DLXC_USERNIC_DB=\"/run/lxc/nics\" -DLXC_USERNIC_CONF=\"/etc/lxc/lxc-usernet\" -DDEFAULT_CGROUP_PATTERN=\"lxc/%n\" -DRUNTIME_PATH=\"/run\" -DSBINDIR=\"/usr/sbin\" -I ../../src -I ../../src/lxc -I
 ../../src/lxc/storage -I ../../src/lxc/cgroups -DHAVE_SECCOMP -DNO_LXC_CONF -Os -fomit-frame-pointer -Wall -static -Wl,--as-needed -o init.lxc.static tools/init_lxc_static-lxc_init.o init_lxc_static-error.o init_lxc_static-log.o init_lxc_static-initutils.o init_lxc_static-
caps.o  -lutil -lpthread -lcap     
../../libtool: line 2625: func__fatal_error: command not found
libtool: link: ( cd ".libs" && rm -f "liblxc.la" && ln -s "../liblxc.la" "liblxc.la" )
/bin/bash ../../libtool  --tag=CC   --mode=link gcc -DLXCROOTFSMOUNT=\"/usr/lib/lxc/rootfs\" -DLXCPATH=\"/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/usr/libexec\" -DLIBEXECDIR=\"/usr/libexec\" -DLXCTEMPLATEDIR=\"/usr/share/lxc/templates\" -DLXCTEM
PLATECONFIG=\"/usr/share/lxc/config\" -DLOGPATH=\"/var/log/lxc\" -DLXC_DEFAULT_CONFIG=\"/etc/lxc/default.conf\" -DLXC_USERNIC_DB=\"/run/lxc/nics\" -DLXC_USERNIC_CONF=\"/etc/lxc/lxc-usernet\" -DDEFAULT_CGROUP_PATTERN=\"lxc/%n\" -DRUNTIME_PATH=\"/run\" -DSBINDIR=\"/usr/sbin\"
 -I ../../src -I ../../src/lxc -I ../../src/lxc/storage -I ../../src/lxc/cgroups     -DHAVE_SECCOMP  -Os -fomit-frame-pointer -Wall -Wl,-E  -Wl,--as-needed -o lxc-attach tools/lxc_attach.o liblxc.la -lcap   -lseccomp  -lutil -lpthread -lcap
/bin/bash ../../libtool  --tag=CC   --mode=link gcc -DLXCROOTFSMOUNT=\"/usr/lib/lxc/rootfs\" -DLXCPATH=\"/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/usr/libexec\" -DLIBEXECDIR=\"/usr/libexec\" -DLXCTEMPLATEDIR=\"/usr/share/lxc/templates\" -DLXCTEM
PLATECONFIG=\"/usr/share/lxc/config\" -DLOGPATH=\"/var/log/lxc\" -DLXC_DEFAULT_CONFIG=\"/etc/lxc/default.conf\" -DLXC_USERNIC_DB=\"/run/lxc/nics\" -DLXC_USERNIC_CONF=\"/etc/lxc/lxc-usernet\" -DDEFAULT_CGROUP_PATTERN=\"lxc/%n\" -DRUNTIME_PATH=\"/run\" -DSBINDIR=\"/usr/sbin\"
 -I ../../src -I ../../src/lxc -I ../../src/lxc/storage -I ../../src/lxc/cgroups     -DHAVE_SECCOMP  -Os -fomit-frame-pointer -Wall -Wl,-E  -Wl,--as-needed -o lxc-autostart tools/lxc_autostart.o liblxc.la -lcap   -lseccomp  -lutil -lpthread -lcap
libtool:   error: cannot find name of link library for 'liblxc.la'
make[3]: *** [Makefile:1196: lxc-autostart] Error 1

Also, a ldd on one of the lxc-<subcommand> binaries generated on Alpine reveals the following:

      qemu-test:~/packages/main/x86_64$ file ./usr/bin/lxc-usernsexec
      ./usr/bin/lxc-usernsexec: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped
      qemu-test:~/packages/main/x86_64$ ldd ./usr/bin/lxc-usernsexec
              /lib/ld-musl-x86_64.so.1 (0x7f33716c2000)
              liblxc.so.1 => /usr/lib/liblxc.so.1 (0x7f3371206000)
              libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f33716c2000)
              libseccomp.so.2 => /usr/lib/libseccomp.so.2 (0x7f3370fc6000)
              libcap.so.2 => /usr/lib/libcap.so.2 (0x7f3370dc1000)

musl libc can be statically included so I'm not worried about that, and I'm trying to work with CoreOS, so libseccomp & libcap are installed there, and I'm not worried about them:

core@localhost ~ $ ldconfig -p | grep "seccomp"
        libseccomp.so.2 (libc6,x86-64) => /lib64/libseccomp.so.2
        libseccomp.so (libc6,x86-64) => /lib64/libseccomp.so
core@localhost ~ $ ldconfig -p | grep "libcap"
        libcap.so.2 (libc6,x86-64) => /lib64/libcap.so.2
        libcap-ng.so.0 (libc6,x86-64) => /lib64/libcap-ng.so.0
        libcap-ng.so (libc6,x86-64) => /lib64/libcap-ng.so

So it looks like the only problem is this liblxc, but I'm not sure where it comes from -- where can I find the sources for liblxc?

@tcharding

This comment has been minimized.

Copy link
Contributor

tcharding commented Aug 20, 2018

What is src/lxc/.libs/liblxc.a if its not static liblxc?

@t3hmrman

This comment has been minimized.

Copy link

t3hmrman commented Aug 20, 2018

Hey @tcharding sorry but where did you see/on what distribution was that? If I somehow failed to see an obvious statically compiled liblxc that's in a distribution somewhere then I apologize.

@brauner

This comment has been minimized.

Copy link
Member

brauner commented Aug 20, 2018

I've just recently enabled this

@brauner brauner closed this Aug 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment