• Michał Kępień's avatar
    Make lib/dns/tests/tkey_test.c more portable · 119f3e0c
    Michał Kępień authored
    Weak symbols are handled differently by different dynamic linkers.  With
    glibc, lib/dns/tests/tkey_test works as expected no matter whether
    --with-libtool is used or not: __attribute__((weak)) prevents a static
    build from failing and it just so happens that the desired symbols are
    picked at runtime for dynamic builds.  However, with BSD libc, the
    libdns functions called from lib/dns/tests/tkey_test.c use the "real"
    memory allocation functions from libisc, thus breaking that unit test.
    (Note: similar behavior can be reproduced with glibc by setting the
    LD_DYNAMIC_WEAK environment variable.)
    The simplest way to make lib/dns/tests/tkey_test work reliably is to
    drop all uses of __attribute__((weak)) in it - this way, the memory
    functions inside lib/dns/tests/tkey_test.c will always be used instead
    of the "real" libisc ones for dynamic builds.  However, this would not
    work with static builds as it would result in multiple strong symbols
    with the same name being present in a single binary.
    Work around the problem by only compiling in the overriding definitions
    of memory functions when building using --with-libtool.  For static
    builds, keep relying on the --wrap linker option for replacing calls to
    the functions we are interested in.
configure 713 KB