On Thu, 9 Feb 2023 at 14:21, John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> wrote: > > Hi! > > On Thu, 2023-02-09 at 14:14 +0000, Peter Maydell wrote: > > The "Using getpwuid in statically linked applications" etc warnings > > are expected, so we can ignore those; this is the key error: > > OK. > > > > /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libdw.a(debuginfod-client.o): in > > > function `__libdwfl_debuginfod_init': > > > (.text.startup+0x17): undefined reference to `dlopen' > > > /usr/bin/ld: (.text.startup+0x32): undefined reference to `dlsym' > > > /usr/bin/ld: (.text.startup+0x4b): undefined reference to `dlsym' > > > /usr/bin/ld: (.text.startup+0x64): undefined reference to `dlsym' > > > /usr/bin/ld: (.text.startup+0x7d): undefined reference to `dlsym' > > > /usr/bin/ld: (.text.startup+0xdc): undefined reference to `dlclose' > > > collect2: error: ld returned 1 exit status > > > > We use pkg-config to find out what the libdw library needs on > > the compiler/linker command line to link successfully, so > > maybe your distro's pkg-config info isn't right. What does > > "pkg-config --static --libs libdw" say ? > > glaubitz@nofan:~> pkg-config --static --libs libdw > -ldw -lbz2 -llzma -pthread -lpthread -lelf -lz
Right, same as my output. > I'm building on Debian stable (Bullseye). > > > If libdw needs libdl > > then it ought to list it in that output, I think. IME pkg-config > > information is often incorrect for static linking, though. > > I guess this one happened to work previously because glibc didn't > > actually mandate linking with '-ldl', and now on your system it > > apparently does. On my system pkg-config says > > -ldw -lbz2 -llzma -pthread -lpthread -lelf -lz > > which looks like it's missing -ldl, but the link succeeds anyway, > > presumably because the symbols are provided by the main glibc .a. > > > > On the other hand, if libdw wants to use dlopen/dlsym then > > I wonder if we should just suppress it for static linking: > > on my (Ubuntu 22.04) ld warns: > > /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libdw.a(debuginfod-client.o): > > in function `__libdwfl_debuginfod_init': > > (.text.startup+0x1b): warning: Using 'dlopen' in statically linked > > applications requires at runtime the shared libraries from the glibc > > version used for linking > > > > so whatever libdw is trying to do will likely not work in most > > statically-linked situations anyway. > > So, just include "-ldl" in LD_FLAGS? If this is necessary, then pkg-config should tell us to do it :-) But in the usual situation that you put the statically linked QEMU binary into a chroot, the dlopen() that libdw is going to try to do won't work anyway... thanks -- PMM