On 2/15/20 10:22 PM, Eric Blake wrote:
At least the VDDK plugin needs a way to load .so files with a custom directory prepended. Asking the user to set LD_LIBRARY_PATH is too strong (that would leak into the child process created by --run, and makes the user think about issues that we'd rather cover automatically). But overriding dlopen() to make it easier to prepend a directory name under our control requires either a separate namespace via dlmopen() (which itself is annoying - it messes up gdb debugging), or that the override occur prior to any other library that also depends on -ldl. Which means that if we are going to provide this functionality, we have to do so from nbdkit proper.
Note that properly injecting a dlopen shim for all subsequent shared library loads requires that the override itself be in a shared library. Thus, nbdkit has to pull it in via a shared library link, rather than merely a .o file, and we now have to install something in pkglibdir. What's more, now that we link against a shared library instead of just libtool convenience libraries, libtool now creates a wrapper app named lt-nbdkit so that it can run an in-tree build that still locates the uninstalled shared library; this affects some expected output in tests.
The wrapper script also needs a tweak thanks to libtool's behavior; I'll have to squash this in: diff --git i/wrapper.c w/wrapper.c index 6aef81a1..b0b9c158 100644 --- i/wrapper.c +++ w/wrapper.c @@ -1,5 +1,5 @@ /* nbdkit - * Copyright (C) 2017-2019 Red Hat Inc. + * Copyright (C) 2017-2020 Red Hat Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -148,6 +148,8 @@ main (int argc, char *argv[]) */ s = getenv ("NBDKIT_VALGRIND"); if (s && strcmp (s, "1") == 0) { + passthru ("libtool"); + passthru ("execute"); passthru (VALGRIND); passthru ("--vgdb=no"); passthru ("--leak-check=full"); @@ -163,6 +165,8 @@ main (int argc, char *argv[]) else { s = getenv ("NBDKIT_GDB"); if (s && strcmp (s, "1") == 0) { + passthru ("libtool"); + passthru ("execute"); passthru ("gdb"); passthru ("--args"); } -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org