kata-containers / packaging

Kata Containers version 1.x packaging (for version 2.x see https://github.com/kata-containers/kata-containers).
https://katacontainers.io/
Apache License 2.0
119 stars 92 forks source link

Add support for statically building cloud-hypervisor #1089

Closed amshinde closed 3 years ago

amshinde commented 4 years ago

Cloud-hypervisor binary built with packaging scripts is not a static binary:

 ldd /opt/kata/bin/cloud-hypervisor
    linux-vdso.so.1 =>  (0x00007ffc44b97000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fee787c9000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fee785c1000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fee783a4000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fee7818e000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fee77dc4000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fee790c6000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fee77abb000)

We need to install cloud-hypervisor as a static binary to make sure we do not run into dependency issues on the system.

amshinde commented 4 years ago

cc @jcvenegas @likebreath @sboeuf

sboeuf commented 4 years ago

If using glibc, it is not statically built:

cargo build
ldd target/debug/cloud-hypervisor
        linux-vdso.so.1 (0x00007ffcf49b6000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7d13314000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7d132f1000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7d132d6000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7d130e4000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f7d141bc000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7d12f95000)

but if you use musl as the target (which is meant for producing static binaries), you get what you need:

cargo build --target x86_64-unknown-linux-musl
ldd target/x86_64-unknown-linux-musl/debug/cloud-hypervisor
        not a dynamic executable
likebreath commented 4 years ago

Overlapped with issue #1033, and is now fixed by PR #1099.

fidencio commented 3 years ago

This issue is being automatically closed as Kata Containers 1.x has now reached EOL (End of Life). This means it is no longer being maintained.

Important:

All users should switch to the latest Kata Containers 2.x release to ensure they are using a maintained release that contains the latest security fixes, performance improvements and new features.

This decision was discussed by the @kata-containers/architecture-committee and has been announced via the Kata Containers mailing list:

If you believe this issue still applies to Kata Containers 2.x, please open an issue against the Kata Containers 2.x repository, pointing to this one, providing details to allow us to migrate it.