From 88aab88d8bc0c89960ea3b1c65dceb8f2f57c1c5 Mon Sep 17 00:00:00 2001 From: Richard Pospesel Date: Wed, 27 Mar 2024 04:19:01 +0000 Subject: [PATCH] pages: updated news entry with build-system and packaging updates --- source/pages/content/news.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/pages/content/news.md b/source/pages/content/news.md index 076ec53b..9f6e442d 100644 --- a/source/pages/content/news.md +++ b/source/pages/content/news.md @@ -2,6 +2,18 @@ --- +## 2024-03-27 - Some Cargo Annoyances + +So in the previous post I mentioned using patchelf to set the [SONAME](https://en.wikipedia.org/wiki/Soname) attribute on the libcgosling.so shared library to facilitate proper debian packaging. I further mentioned this was due to an upstream cargo issue. Well, it turns out a similar issue exists for macOS binaries. Rather than playing whack-a-mole and manually fixing every single eventual build target, I took a step back and re-thought my approach and what could be done that would be most maintainable long term. + +The end-result is [this](https://github.com/blueprint-freespeech/gosling/commit/9ae019efd3c5e5565287b963d09868c4ffaf5891). + +To summarise, rather than manually patching and generally futzing with build outputs, I am instead only building cgosling as a static lib, and then building a shared lib using each platforms C tooling. This way, we can lean on CMake to do the heavy lifting when it comes to platform-specific metadata, symbolic-links, naming, etc. Unfortunately there is no standard way using cmake to just build a shared library which exports all of a static libraries public symbols. + +As a result, I've had to do some *interesting* engineering in the cgosling crate using proc macros. Without going into too much detail, we are now building two copies of the cgosling static library, one for direct consumption by downstream projects, and another `_impl` suffixed copy whose functions have also been renamed to include an `_impl` suffix. Then, using our existing code-generation pipeline, a cgosling shared library is written which defines public functions with the names found in the generated header, which simply pass-through all arguments to the `_impl` versions. *Hopefully* the compilers will optimise away this little overhead but if not I would be surprised if it is actually a big deal. + +This work has allowed me to pretty rapidly and confidently implement both an [Homebrew Formula](https://github.com/blueprint-freespeech/gosling/commit/1435386ba6f826dd73096fa4dbaa4cc8f460af6e) for macOS (and Linux) and a [PKGBUILD](https://github.com/blueprint-freespeech/gosling/commit/b3e59159da503da2d37efd948843681667979ce3) script for msys2 Windows environments. + ## 2024-02-28 - Debian Source Packages This past week I've been diving into the wonderful world of debian packaging. Specifically, constructing a debian source package via CMake which can be used to build the cgosling library from source, and generate both binary and dev packages.