Skip to content

Commit

Permalink
ghostty: fix cross build, use more system libraries
Browse files Browse the repository at this point in the history
Co-authored-by: tranzystorekk <[email protected]>
  • Loading branch information
Duncaen and tranzystorekk committed Dec 27, 2024
1 parent 3f232d1 commit 6234908
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
1 change: 1 addition & 0 deletions srcpkgs/ghostty-terminfo
26 changes: 26 additions & 0 deletions srcpkgs/ghostty/patches/unigen-nolibc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/build.zig b/build.zig
index c3f7302..9fa73e9 100644
--- a/build.zig
+++ b/build.zig
@@ -1494,7 +1494,7 @@ fn addUnicodeTables(
.root_source_file = b.path("src/unicode/props.zig"),
.target = b.host,
});
- exe.linkLibC();
+ // exe.linkLibC();
if (step_ == null) b.installArtifact(exe);

const ziglyph_dep = b.dependency("ziglyph", .{
diff --git a/src/unicode/props.zig b/src/unicode/props.zig
index d77bf4c..994cf36 100644
--- a/src/unicode/props.zig
+++ b/src/unicode/props.zig
@@ -131,7 +131,7 @@ pub fn get(cp: u21) Properties {

/// Runnable binary to generate the lookup tables and output to stdout.
pub fn main() !void {
- const alloc = std.heap.c_allocator;
+ const alloc = std.heap.page_allocator;

const gen: lut.Generator(
Properties,
26 changes: 20 additions & 6 deletions srcpkgs/ghostty/template
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Template file for 'ghostty'
pkgname=ghostty
version=1.0.0
revision=1
revision=2
build_style=zig-build
configure_args="-Doptimize=ReleaseFast -Dpie"
hostmakedepends="pkg-config"
makedepends="gtk4-devel libadwaita-devel"
configure_args="
-Doptimize=ReleaseFast
-Dpie
-Dversion-string=${version}
-fsys=freetype
-fsys=fontconfig
-fsys=harfbuzz"
hostmakedepends="pkg-config glib-devel pandoc"
makedepends="fontconfig-devel freetype-devel harfbuzz-devel gtk4-devel libadwaita-devel"
depends="ghostty-terminfo-${version}_${revision}"
short_desc="Fast and feature-rich terminal emulator that uses GPU acceleration"
maintainer="Duncaen <[email protected]>"
license="MIT"
Expand All @@ -15,6 +22,13 @@ checksum=bd12953c8bbe7149e2f94e7e578a88e981932a69aa483f5ce9a2cfba726e0015

post_install() {
vlicense LICENSE
rm -f "${DESTDIR}/usr/share/man/.placeholder"
tic -o "${DESTDIR}/usr/share/terminfo" -x "${DESTDIR}/usr/share/terminfo/ghostty.terminfo"
tic -sx -o ${DESTDIR}/usr/share/terminfo ${DESTDIR}/usr/share/terminfo/ghostty.terminfo
rm -f ${DESTDIR}/usr/share/man/.placeholder ${DESTDIR}/usr/share/terminfo/ghostty.{terminfo,termcap}
}

ghostty-terminfo_package() {
short_desc+=" - terminfo data"
pkg_install() {
vmove usr/share/terminfo
}
}

6 comments on commit 6234908

@kartikynwa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ghostty built with this template does not work with me and the output does not give a clear reason for the crash:

Terminal output
in ~
 ❯ ghostty help
info: ghostty version=1.0.0
info: ghostty build optimize=ReleaseFast
info: runtime=apprt.Runtime.gtk
info: font_backend=font.main.Backend.fontconfig_freetype
info: dependency harfbuzz=10.1.0
info: dependency fontconfig=21402
info: renderer=renderer.OpenGL
info: libxev backend=main.Backend.io_uring
info(os): setlocale from env result=LC_CTYPE=en_US.UTF-8;LC_NUMERIC=en_US.UTF-8;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=en_US.UTF-8;LC_ADDRESS=en_US.UTF-8;LC_TELEPHONE=en_US.UTF-8;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=en_US.UTF-8
info(gtk): GTK version build=4.16.7 runtime=4.16.7
info: optional config file not found, not loading path=/home/kartik/.config/ghostty/config
info(config): default shell source=env value=/bin/zsh
warning(gtk): configuration error: cli:1:help: invalid field
warning(gtk): CLI errors detected, exiting

in ~
 ❯ ghostty
info: ghostty version=1.0.0
info: ghostty build optimize=ReleaseFast
info: runtime=apprt.Runtime.gtk
info: font_backend=font.main.Backend.fontconfig_freetype
info: dependency harfbuzz=10.1.0
info: dependency fontconfig=21402
info: renderer=renderer.OpenGL
info: libxev backend=main.Backend.io_uring
info(os): setlocale from env result=LC_CTYPE=en_US.UTF-8;LC_NUMERIC=en_US.UTF-8;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=en_US.UTF-8;LC_ADDRESS=en_US.UTF-8;LC_TELEPHONE=en_US.UTF-8;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=en_US.UTF-8
info(gtk): GTK version build=4.16.7 runtime=4.16.7
info: optional config file not found, not loading path=/home/kartik/.config/ghostty/config
info(config): default shell source=env value=/bin/zsh
info(sentry): sentry envelope does not contain crash, discarding
EGL API version 1.5 found
 - Vendor: Mesa Project
 - Version: 1.5
 - Device: /dev/dri/renderD128, 226 128
 - Client APIs: OpenGL OpenGL_ES
 - Extensions:
	EGL_ANDROID_blob_cache
	EGL_ANDROID_native_fence_sync
	EGL_ANGLE_sync_control_rate
	EGL_CHROMIUM_sync_control
	EGL_EXT_buffer_age
	EGL_EXT_config_select_group
	EGL_EXT_create_context_robustness
	EGL_EXT_image_dma_buf_import
	EGL_EXT_image_dma_buf_import_modifiers
	EGL_EXT_pixel_format_float
	EGL_EXT_query_reset_notification_strategy
	EGL_EXT_surface_compression
	EGL_EXT_swap_buffers_with_damage
	EGL_IMG_context_priority
	EGL_KHR_cl_event2
	EGL_KHR_config_attribs
	EGL_KHR_context_flush_control
	EGL_KHR_create_context
	EGL_KHR_create_context_no_error
	EGL_KHR_fence_sync
	EGL_KHR_get_all_proc_addresses
	EGL_KHR_gl_colorspace
	EGL_KHR_gl_renderbuffer_image
	EGL_KHR_gl_texture_2D_image
	EGL_KHR_gl_texture_3D_image
	EGL_KHR_gl_texture_cubemap_image
	EGL_KHR_image
	EGL_KHR_image_base
	EGL_KHR_image_pixmap
	EGL_KHR_no_config_context
	EGL_KHR_reusable_sync
	EGL_KHR_surfaceless_context
	EGL_KHR_swap_buffers_with_damage
	EGL_KHR_wait_sync
	EGL_MESA_configless_context
	EGL_MESA_drm_image
	EGL_MESA_gl_interop
	EGL_MESA_image_dma_buf_export
	EGL_MESA_query_driver
	EGL_MESA_x11_native_visual_id
	EGL_NOK_texture_from_pixmap
	EGL_WL_bind_wayland_display
 - Selected fbconfig: R8G8B8A8, depth 0, stencil 0
          high depth: none
Creating EGL context version 3.2 (debug:no, forward:no, legacy:no, es:no)
Using OpenGL backend EGL
info(gtk): libadwaita version build=1.6.2 runtime=1.6.2
info(sentry): sentry envelope does not contain crash, discarding
error: FileNotFound

in ~
 ❯ xuname
Void 6.12.6_3 x86_64 GenuineIntel uptodate rrmFFFFFFFFFFFF

@AgarimOSLinux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a similar output. In my case it works in Wayland but not in X11. It shows pictures with fastfetch, but not with neofetch.

@Duncaen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use strace to try to find out where "FileNotFound" comes from.

@kartikynwa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the output of strace ghostty but I don't know how to make sense of it: https://termbin.com/1k01n

I am also using X11 as the other commenter said.

@Duncaen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't see anything that stands out, might be in a different thread, use the -ff strace flag.

@kartikynwa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output of strace -ff ghostty: https://termbin.com/0mxn

Please sign in to comment.