From 49d43f89a1c548f04e4d6ce42f27bf57eecd7692 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 17 Nov 2024 11:51:27 +0100 Subject: [PATCH] Fix build on 32bit systems + static build adjustments I was trying to remove the need for that strip command with some -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables, but passing even one of those to the ncurses build would result in an ncdu binary that's twice as large and fails to run. I don't get it. --- Makefile | 11 ++++++----- src/bin_export.zig | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a311438..b248131 100644 --- a/Makefile +++ b/Makefile @@ -68,24 +68,25 @@ static-%.tar.gz: LD="${ZIG} cc --target=$*"\ AR="${ZIG} ar" RANLIB="${ZIG} ranlib" cd static-$*/nc && ../../ncurses/configure --prefix="`pwd`/../inst"\ - --with-pkg-config-libdir="`pwd`/../inst/pkg"\ --without-cxx --without-cxx-binding --without-ada --without-manpages --without-progs\ - --without-tests --enable-pc-files --without-pkg-config --without-shared --without-debug\ + --without-tests --disable-pc-files --without-pkg-config --without-shared --without-debug\ --without-gpm --without-sysmouse --enable-widec --with-default-terminfo-dir=/usr/share/terminfo\ --with-terminfo-dirs=/usr/share/terminfo:/lib/terminfo:/usr/local/share/terminfo\ --with-fallbacks="screen linux vt100 xterm xterm-256color" --host=$*\ CC="${ZIG} cc --target=$*"\ LD="${ZIG} cc --target=$*"\ AR="${ZIG} ar" RANLIB="${ZIG} ranlib"\ - CPPFLAGS=-D_GNU_SOURCE && make -j8 && make install.libs + CPPFLAGS=-D_GNU_SOURCE && make -j8 @# zig-build - cleaner approach but doesn't work, results in a dynamically linked binary. @#cd static-$* && PKG_CONFIG_LIBDIR="`pwd`/inst/pkg" zig build -Dtarget=$* @# --build-file ../build.zig --search-prefix inst/ --cache-dir zig -Drelease-fast=true @# Alternative approach, bypassing zig-build cd static-$* && ${ZIG} build-exe -target $*\ - -Iinst/include -Iinst/include/ncursesw -Izstd -lc inst/lib/libncursesw.a zstd/libzstd.a\ + -Inc/include -Izstd -lc nc/lib/libncursesw.a zstd/libzstd.a\ --cache-dir zig-cache -static -fstrip -O ReleaseFast ../src/main.zig - strip -R .eh_frame -R .eh_frame_hdr static-$*/main + @# My system's strip can't deal with arm binaries and zig doesn't wrap a strip alternative. + @# Whatever, just let it error for those. + strip -R .eh_frame -R .eh_frame_hdr static-$*/main || true cd static-$* && mv main ncdu && tar -czf ../static-$*.tar.gz ncdu rm -rf static-$* diff --git a/src/bin_export.zig b/src/bin_export.zig index 43a8cf0..e197344 100644 --- a/src/bin_export.zig +++ b/src/bin_export.zig @@ -106,7 +106,7 @@ pub const Thread = struct { var out = std.ArrayList(u8).init(main.allocator); if (t.block_num == std.math.maxInt(u32) or t.off == 0) return out; - out.ensureTotalCapacityPrecise(12 + c.ZSTD_COMPRESSBOUND(t.off)) catch unreachable; + out.ensureTotalCapacityPrecise(12 + @as(usize, @intCast(c.ZSTD_COMPRESSBOUND(@as(c_int, @intCast(t.off)))))) catch unreachable; out.items.len = out.capacity; const bodylen = compressZstd(t.buf[0..t.off], out.items[8..]); out.items.len = 12 + bodylen;