Etapa G (GUI): validación — gtk4-hello, app GTK4 linkeada 100% estática contra libgtk-4.a

- gtk4.toml: el merge ahora fusiona TODOS los convenience-libs bajo output/ (gtk/css, gdk/wayland,
  cursor, gsk…), no solo gtk/gdk/gsk — el .a queda monolítico y autocontenido.
- gtk4-hello.toml: hello.c propio (GtkApplication+ventana), link estático vía pkg-config --static gtk4
  + privadas de gdk/gsk que gtk4.pc no declara (harfbuzz-subset/epoxy/xkbcommon/wayland/tiff/jpeg/
  cairo-script-interpreter). Binario: 134MB, ELF 'not a dynamic executable', corre (exit 0).

Prueba de que el toolkit de GUI del lab es USABLE por apps reales, no solo que compila.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 10:52:48 -04:00
co-authored by Claude Opus 4.8
parent 6ccd1c3846
commit 82dfbcebfe
2 changed files with 61 additions and 3 deletions
+47
View File
@@ -0,0 +1,47 @@
# gtk4-hello — app GTK4 mínima de VALIDACIÓN: prueba que libgtk-4.a (static) es linkeable de verdad.
# Reutiliza el tarball de GTK4 solo como acarreo de [source] (lo ignora); escribe su propio hello.c y
# lo linkea ESTÁTICO contra todo el cierre GTK4 vía `pkg-config --static gtk4`. Si sella, el toolkit
# de GUI del lab es usable por apps, no solo "compila". deps = cierre .pc completo + gtk4.
name = "gtk4-hello"
version = "4.18.6"
[source]
tarball = "https://download.gnome.org/sources/gtk/4.18/gtk-4.18.6.tar.xz"
sha256 = "e1817c650ddc3261f9a8345b3b22a26a5d80af154630dedc03cc7becefffd0fa"
[build]
compiler = "zig-cc"
target = "x86_64-linux-musl"
link = "static"
[build.phases]
# no-op: el tarball trae meson.build y el lab inyectaría `meson setup` por defecto si omito configure.
configure = "true"
compile = '''
cat > hammer_hello.c <<'CEOF'
#include <gtk/gtk.h>
static void activate(GtkApplication *app, gpointer user_data) {
GtkWidget *win = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(win), "Hola desde hammer");
gtk_window_set_default_size(GTK_WINDOW(win), 360, 220);
GtkWidget *label = gtk_label_new("GTK4 static-musl ✓ (zig cc)");
gtk_window_set_child(GTK_WINDOW(win), label);
gtk_window_present(GTK_WINDOW(win));
}
int main(int argc, char **argv) {
GtkApplication *app = gtk_application_new("org.hammer.hola", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
int status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
CEOF
# gtk4.pc NO declara Libs.private (asume link dinámico contra libgtk-4.so); para ESTÁTICO hay que sumar
# las privadas que gdk/gsk linkean directo (harfbuzz-subset, epoxy, wayland, xkbcommon, tiff, jpeg).
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
zig cc -mcpu=baseline -static hammer_hello.c -o gtk4-hello $(pkg-config --cflags --libs --static gtk4 harfbuzz-subset epoxy xkbcommon wayland-client wayland-egl libtiff-4 libjpeg cairo-script-interpreter)
'''
install = "mkdir -p /out/usr/bin && cp gtk4-hello /out/usr/bin/gtk4-hello"
[deps]
build = ["pkgconf", "gtk4", "pango", "gdk-pixbuf", "cairo", "graphene", "glib", "harfbuzz", "fribidi", "fontconfig", "freetype", "pixman", "libpng", "expat", "libjpeg-turbo", "libtiff", "libepoxy", "wayland", "libxkbcommon", "libdrm", "pcre2", "libffi", "zlib", "mesa"]
+14 -3
View File
@@ -20,9 +20,20 @@ link = "static"
# "libgtk_dep" NO es substring de "libgtk_static_dep" ⇒ no toca las que ya usan el estático.
configure = "sed -i 's/libgtk_dep/libgtk_static_dep/g' tools/meson.build && PKG_CONFIG_PATH=/usr/lib/pkgconfig PYTHONPATH=/usr/lib/python3.12/site-packages meson setup output --prefix=/usr --buildtype=release --wrap-mode=nodownload --prefer-static -Ddefault_library=static -Dwayland-backend=true -Dx11-backend=false -Dbroadway-backend=false -Dwin32-backend=false -Dmacos-backend=false -Dvulkan=disabled -Dintrospection=disabled -Dbuild-demos=false -Dbuild-testsuite=false -Dbuild-tests=false -Dbuild-examples=false -Dmedia-gstreamer=disabled -Dprint-cups=disabled -Dprint-cpdb=disabled -Dcloudproviders=disabled -Dsysprof=disabled -Dtracker=disabled -Dcolord=disabled -Df16c=disabled -Ddocumentation=false -Dman-pages=false -Dc_args=-Wno-error=date-time"
compile = "PYTHONPATH=/usr/lib/python3.12/site-packages ninja -C output"
# meson instala solo libgtk-4.so; copio el static_library('gtk') (libgtk.a, GTK completo) como libgtk-4.a
# para que `-lgtk-4` + `-static` resuelva al estático (el lab es static-musl).
install = "PYTHONPATH=/usr/lib/python3.12/site-packages DESTDIR=/out meson install -C output --no-rebuild && cp output/gtk/libgtk.a /out/usr/lib/libgtk-4.a"
# meson instala solo libgtk-4.so y genera convenience-libs THIN (gtk/gdk/gsk por separado, referencian
# los .o por ruta → inútiles fuera del build dir). Fusiono los tres en UN archive GORDO libgtk-4.a (embebe
# todos los .o) para que `-lgtk-4` + `-static` linkee de verdad en el lab static-musl.
install = '''
PYTHONPATH=/usr/lib/python3.12/site-packages DESTDIR=/out meson install -C output --no-rebuild
rm -f /out/usr/lib/libgtk-4.a
cd output
objs=""
for a in $(find . -name '*.a'); do
d=$(dirname "$a"); b=$(basename "$a")
for o in $(cd "$d" && zig ar t "$b"); do objs="$objs $d/$o"; done
done
zig ar rcs /out/usr/lib/libgtk-4.a $objs
'''
[deps]
build = ["meson", "samurai", "python3", "pkgconf", "glib", "cairo", "pango", "gdk-pixbuf", "graphene", "libepoxy", "wayland", "wayland-protocols", "libxkbcommon", "libdrm", "fontconfig", "harfbuzz", "fribidi", "libpng", "pixman", "freetype", "expat", "libffi", "pcre2", "zlib", "libjpeg-turbo", "libtiff", "mesa"]