Skip to content

Draft: Patch gobject & glib for static linking

fasterthanlime requested to merge amos/win-msvc-static-linking into main

These changes enable producing a static build of glib on Windows with MSVC.

See GNOME/glib!1655 for prior art.

(This MR is intentionally opened against fasterthanlime/glib rather than GNOME/glib, because it is not meant to be merged, I just want a convenient view of what my current changeset is.)

General approach

From @lb90 in their MR:

  1. Use CreateProcess directly instead of CRT _wspanw* functions where applicable.
  2. Switch to using FLS in the GPrivate implementation on Windows.
  3. Move the code that now resides in DllMain and handles DLL_PROCESS_ATTACH into a PE constructor.
  4. Modify the build definitions to allow static builds on Windows.

Dependencies

This MR needs these to land first:

CI pipelines

This adds two CI pipelines. Both msys2-mingw32 and vs2017-x64 got -static and -shared variants.

Tests

Not all tests are expected to run on MSVC builds anyway (even dynamic ones), here's a list of expected failures (taken from a recent main run):

https://gist.github.com/fasterthanlime/89b740e9eef045c8d33759c0693174b5

Edited by fasterthanlime

Merge request reports