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

Making static binaries problem #499

Open
xuegege5290 opened this issue Mar 25, 2024 · 2 comments
Open

Making static binaries problem #499

xuegege5290 opened this issue Mar 25, 2024 · 2 comments

Comments

@xuegege5290
Copy link

Hi~
I've encountered some issues while compiling conmon and I'm seeking a resolution. I wish to compile conmon as a statically linked binary so that it can be used in other environments. However, after completing the static compilation, there's a warning that suggests conmon will still depend on the glibc version of the host machine when run in other environments. Is there a way to resolve this issue? Of course, you might think that using the Nix package manager would be straightforward, but I'm unable to use Nix and would prefer to compile directly, as direct compilation is also faster.

root@syx:~/go/conmon# make static
+ cat VERSION
+ bash -c '[[ `command -v git` && `git rev-parse --git-dir 2>/dev/null` ]] && echo 0'
+ pkg-config --exists libsystemd
+ hack/seccomp-notify.sh
+ pkg-config --cflags glib-2.0
+ pkg-config --libs glib-2.0
cc -static  -std=c99 -Os -Wall -Wextra -Werror -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -DVERSION=\"2.1.10\" -DGIT_COMMIT=\"\"  -o bin/conmon src/conmon.o src/cmsg.
o src/ctr_logging.o src/utils.o src/cli.o src/globals.o src/cgroup.o src/conn_sock.o src/oom.o src/ctrl.o src/ctr_stdio.o src/parent_pipe_fd.o src/ctr_exit.o src/runtime_args.o src/close_fds.o
 src/seccomp_notify.o -Wl,-Bstatic -lglib-2.0 -lpthread -lc
+ cc -static -std=c99 -Os -Wall -Wextra -Werror -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include '-DVERSION="2.1.10"' '-DGIT_COMMIT=""' -o bin/conmon src/conmon.o src/cmsg.
o src/ctr_logging.o src/utils.o src/cli.o src/globals.o src/cgroup.o src/conn_sock.o src/oom.o src/ctrl.o src/ctr_stdio.o src/parent_pipe_fd.o src/ctr_exit.o src/runtime_args.o src/close_fds.o
 src/seccomp_notify.o -Wl,-Bstatic -lglib-2.0 -lpthread -lc
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.c.o): in function `g_get_user_database_entry':
(.text+0x277): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: (.text+0xe0): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: (.text+0x11e): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Note that I have used the same method to compile CRI-O without any issues.

@xuegege5290
Copy link
Author

Do I need to recompile the glibc library and add options like --enable-static-nss to implement static linking of the NSS library?

@xuegege5290
Copy link
Author

Or if I use the Nix package manager for compilation, will I not encounter issues like this that depend on the host's glibc libraries?

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

No branches or pull requests

1 participant