lestrrat-go / libxml2

Interface to libxml2, with DOM interface
MIT License
230 stars 55 forks source link

Statically link to libxml2 when `static_build` tag is defined #95

Closed chrisnovakovic closed 7 months ago

chrisnovakovic commented 7 months ago

There's an unofficial convention in the Go ecosystem that the static_build tag indicates a desire to link statically to external libraries detected with pkg-config - examples include:

Support this convention by invoking pkg-config with the --static option if the static_build tag is defined, or without if it isn't.

chrisnovakovic commented 7 months ago

This is a proposed solution to the problems faced in #62. Hopefully it'll be resolved officially in the Go toolchain when https://github.com/golang/go/issues/26492 is implemented, but until then, this seems to be the unofficial convention for getting external libraries linked statically.

lestrrat commented 7 months ago

@chrisnovakovic can you please modify the CI tests that they additionally test building with static linking?

chrisnovakovic commented 7 months ago

I've started off with Ubuntu (tested locally in a Docker container similar to ubuntu-latest on GHA). Could you approve the workflow run? If that works, I'll move on to Arch. Actually it looks like Arch doesn't package static libraries, so if the Ubuntu-based workflow works, there's nothing else to be done.

lestrrat commented 7 months ago

I think you had an overzealous copy/paste :D

chrisnovakovic commented 7 months ago

There's a dangling env in there, a remnant of an earlier attempt at defining the Go build flags. Thanks for fixing it 🙂

chrisnovakovic commented 7 months ago

The latest failure is because the libxml2 package version in Arch is 2.12.6 - changing line 61 to

pacman -S --noconfirm 'libxml2>=2.12.0'

ought to do it, given that you just want something with at least libxml2's 2.12 API.

lestrrat commented 7 months ago

Ah, I just made it 2.12.6, but I guess I should have looked closer. Meh, I'll fix that when it breaks again in the future.

Thanks for your PR! will merge now