Skip to content

build: support building with GTK compiled without x11-backend #3477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ldv opened this issue Dec 27, 2024 · 8 comments
Closed

build: support building with GTK compiled without x11-backend #3477

ldv opened this issue Dec 27, 2024 · 8 comments

Comments

@ldv
Copy link

ldv commented Dec 27, 2024

Build environment: Fedora 41, gtk4 package compiled with x11-backend option disabled.

I tried to build the package with:
zig build -fsys=simdutf -Dtarget=native -Doptimize=ReleaseFast -Dpie

but it fails with the following errors:

install
└─ install ghostty
   └─ zig build-exe ghostty ReleaseFast native 2 errors
src/apprt/gtk/c.zig:2:15: error: C import failed
pub const c = @cImport({
              ^~~~~~~~
referenced by:
    gtk: src/cli/version.zig:8:80
    run: src/cli/version.zig:42:13
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
/home/ldv/Downloads/ghostty-1.0.0/.zig-cache/o/cfe3a1b5077a346ccf90ce9c54a404e4/cimport.h:3:10: error: 'gdk/x11/gdkx.h' file not found
#include <gdk/x11/gdkx.h>

Is there a plan to support "pure" Wayland GTK backend? Or am I missing something?

@mitchellh
Copy link
Contributor

This file is required for compilation but we don't use it at runtime if Wayland is used. We could introduce a build option to not complete the X11 support at all but I'm not sure if it's worth it... still I've tagged this to look into it.

@mitchellh mitchellh changed the title Unable to build with GTK (Wayland only) build: support building with GTK compiled without x11-backend Dec 27, 2024
@sin-ack
Copy link
Contributor

sin-ack commented Dec 27, 2024

We also hit this issue in Gentoo packaging, as GTK 4 can be built without X. https://bugs.gentoo.org/947032

@mitchellh
Copy link
Contributor

Thanks for the additional data point. I'd like to fix this.

@tristan957
Copy link
Member

I tried fixing this one time, but I don't understand Zig's C support enough to fix it. If this was a C project, I would have it done, but I'm still new to Zig. Very interested to see what solutions can be come up with!

@mitchellh
Copy link
Contributor

I tried fixing this one time, but I don't understand Zig's C support enough to fix it.

We need to introduce a build option that we then use to avoid ever referencing the cImport decl. Since Zig tree shakes, this will avoid trying to load and compile it.

mitchellh added a commit that referenced this issue Dec 28, 2024
@mitchellh
Copy link
Contributor

This should be fixed on main with #3748. I'd appreciate any confirmation, it should happen automatically now.

@ldv
Copy link
Author

ldv commented Dec 29, 2024

I tried to build from master (c8950d3)::

zig build -fsys=simdutf -Dtarget=native -Doptimize=ReleaseFast -Dpie -Dgtk-x11=false -Dgtk-adwaita=false

and it works, thank you!

@sin-ack
Copy link
Contributor

sin-ack commented Dec 29, 2024

Also confirmed on a pure-Wayland Gentoo chroot.

mitchellh added a commit that referenced this issue Dec 29, 2024
As a follow-up to #3477 and #3748, this eliminates the use of dlopen to
access `libX11` functions by directly linking `libX11` if X11 is
enabled. This should also fix problems with systems like NixOS and Void
Linux that have reported problems using Ghostty on X11 when using the
distribution packages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants