Could g_get_user_database_entry() and friends be moved to their own file for the benefit of statically linked applications?
If a statically linked application pulls in functions like getpwuid(), then the linker will warn about this:
(.text+0x267): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Unfortunately, glib's gutils.c file includes both functions which use getpwuid() (eg g_get_user_database_entry()) and also ones which do not (for instance g_get_prgname(), g_get_tmp_name()). Since even a trivial glib-using program is likely to call functions which pull in g_get_prgname(), this means that the linker will warn spuriously, because static linking works on a "pull in the whole .o file from the library" basis, and so g_get_user_database_entry() is in the final executable even though it is never called.
For example:
$ cat /tmp/glib-hello.c
#include <glib.h>
int main(void)
{
GString *my_string = g_string_new("This Hello world is %d chars long\n");
g_print(my_string->str, my_string->len);
g_string_free(my_string, TRUE);
return 0;
}
$ gcc -g -Wall /tmp/glib-hello.c `pkg-config --cflags --libs gthread-2.0` -o /tmp/glib-hello -static
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libglib-2.0.a(libglib_2_0_la-gutils.o): In function `g_get_user_database_entry':
(.text+0x267): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
(.text+0xdd): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
(.text+0x11b): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
If g_get_user_database_entry() and its callers (and any other functions that use getwpuid and similar libc functions) could be moved out of gutils.c and into their own .c file, then the static linker would only pull them in if the user's application genuinely required them, and thus the linker warnings would be produced only if they were actually relevant.
(This is a specific issue for QEMU, which links against glib, and uses static linking for its 'linux-user' emulator binaries. The warning is harmless but it would be nice to avoid confusing our users with it.)