dirmngr/ks-engine-ldap.c which contains ks_ldap_free_state's implementation is only compile if USE_LDAP is defined:
x86_64-pc-linux-gnu-cc -DWITHOUT_NPTH=1 -std=gnu99 -I/usr/x86_64-pc-linux-gnu/include -I/usr/x86_64-pc-linux-gnu/include -I/usr/x86_64-pc-linux-gnu/include -I/usr/x86_64 -pc-linux-gnu/include -Wall -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -flto -fuse-linker-plugin -march=native -O2 -pipe -D_FORTIFY_SOURCE=2 -Wl,-O1 -Wl,--a s-needed -flto -o t-http-basic t_http_basic-t-support.o t_http_basic-dns.o t_http_basic-t-http-basic.o t_http_basic-http.o t_http_basic-dns-stuff.o t_http_basic-http-common .o ../common/libcommon.a -lassuan -L/usr/x86_64-pc-linux-gnu/lib -lgpg-error -L/usr/x86_64-pc-linux-gnu/lib -lgcrypt -lgpg-error -L/usr/x86_64-pc-linux-gnu/lib -lgpg-error -lgnutls -L/usr/x86_64-pc-linux-gnu/lib -lksba -lgpg-error -L/usr/x86_64-pc-linux-gnu/lib -lgcrypt -lgpg-error -L/usr/x86_64-pc-linux-gnu/lib -lgpg-error -lgnutls /usr/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ld: /var/tmp/paludis/build/app-crypt-gnupg-2.3.8/temp//ccZ3C4tQ.ltrans0.ltrans.o: in function `start_command_handler': <artificial>:(.text+0xbb71): undefined reference to `ks_ldap_free_state'