From 861427cf4bd17a5afcc71f16a1e8ad225ce9fdc2 Mon Sep 17 00:00:00 2001 From: Komo Date: Tue, 3 Dec 2024 04:12:01 +0800 Subject: [PATCH] fix(main/zig): fix warning missing ABI and dynamic linker Closes #20294 Zig uses FHS-type path to guess the ABI and dynamic linker of `env` binary. That leads to a warning like in #20294 --- packages/zig/build.sh | 1 + .../zig/lib-std-zig-LibCInstallation.zig.patch | 15 +++++++++++++++ packages/zig/lib-std-zig-system.zig.patch | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 packages/zig/lib-std-zig-LibCInstallation.zig.patch create mode 100644 packages/zig/lib-std-zig-system.zig.patch diff --git a/packages/zig/build.sh b/packages/zig/build.sh index 488d86ad1453105..a922cb1ea060d49 100644 --- a/packages/zig/build.sh +++ b/packages/zig/build.sh @@ -4,6 +4,7 @@ TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_LICENSE_FILE="zig/LICENSE" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="0.13.0" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://github.com/ziglang/zig/releases/download/${TERMUX_PKG_VERSION}/zig-bootstrap-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=cd446c084b5da7bc42e8ad9b4e1c910a957f2bf3f82bcc02888102cd0827c139 TERMUX_PKG_BUILD_IN_SRC=true diff --git a/packages/zig/lib-std-zig-LibCInstallation.zig.patch b/packages/zig/lib-std-zig-LibCInstallation.zig.patch new file mode 100644 index 000000000000000..cd28acb0b837866 --- /dev/null +++ b/packages/zig/lib-std-zig-LibCInstallation.zig.patch @@ -0,0 +1,15 @@ +diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig +index 686471bde..47e1f714c 100644 +--- a/zig/lib/std/zig/LibCInstallation.zig ++++ b/zig/lib/std/zig/LibCInstallation.zig +@@ -203,6 +203,10 @@ pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { + self.include_dir = try args.allocator.dupeZ(u8, "/usr/include"); + self.sys_include_dir = try args.allocator.dupeZ(u8, "/usr/include"); + self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib/64"); ++ } else if (builtin.target.isAndroid()) { ++ self.include_dir = try args.allocator.dupeZ(u8, "@TERMUX_PREFIX@/include"); ++ self.sys_include_dir = try args.allocator.dupeZ(u8, "@TERMUX_PREFIX@/include/sys"); ++ self.crt_dir = try args.allocator.dupeZ(u8, "@TERMUX_PREFIX@/lib/crtbegin_dynamic.o"); + } else if (std.process.can_spawn) { + try self.findNativeIncludeDirPosix(args); + switch (builtin.target.os.tag) { diff --git a/packages/zig/lib-std-zig-system.zig.patch b/packages/zig/lib-std-zig-system.zig.patch new file mode 100644 index 000000000000000..255e87df58d5ad9 --- /dev/null +++ b/packages/zig/lib-std-zig-system.zig.patch @@ -0,0 +1,16 @@ +diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig +index 83c798c34..6668f4bcd 100644 +--- a/zig/lib/std/zig/system.zig ++++ b/zig/lib/std/zig/system.zig +@@ -996,6 +996,11 @@ fn detectAbiAndDynamicLinker( + .haiku => "/bin/env", + }; + ++ if (builtin.target.isAndroid()) { ++ // Consider using /system/bin/env instead ++ file_name = "@TERMUX_PREFIX@/bin/env"; ++ } ++ + // According to `man 2 execve`: + // + // The kernel imposes a maximum length on the text