Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Statically link to libxml2 when static_build tag is defined #95

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

chrisnovakovic
Copy link
Contributor

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.

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:

* [LXC](https://github.com/lxc/go-lxc/blob/ccae595aa49e779f7ecc9250329967aa546acd31/linking_static.go)
* [containers-storage](https://github.com/containers/storage/blob/6c835719e98e403dae4a437e3809e247c9561b29/pkg/devicemapper/devmapper_wrapper_static.go)

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
Copy link
Contributor Author

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

@lestrrat
Copy link
Collaborator

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

@chrisnovakovic
Copy link
Contributor Author

chrisnovakovic commented Mar 27, 2024

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
Copy link
Collaborator

I think you had an overzealous copy/paste :D

See if removing this key works
@chrisnovakovic
Copy link
Contributor Author

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

@chrisnovakovic
Copy link
Contributor Author

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
Copy link
Collaborator

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

@lestrrat lestrrat merged commit c5fabe2 into lestrrat-go:master Mar 28, 2024
5 checks passed
@chrisnovakovic chrisnovakovic deleted the static_build branch March 28, 2024 00:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants