This general situation (getting a Perl distro to successfully link and run with -lxml2) is addressed by Alien::Libxml2, as used by XML::LibXML, which has plenty of passes on MacOS. In your situation I would move my distro over to using that scheme of things and copy exactly what XML::LibXML does.