Skip to content

Commit

Permalink
fix(main/zig): fix warning missing ABI and dynamic linker
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mbekkomo committed Dec 3, 2024
1 parent 36aeea0 commit 861427c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/zig/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions packages/zig/lib-std-zig-LibCInstallation.zig.patch
Original file line number Diff line number Diff line change
@@ -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) {
16 changes: 16 additions & 0 deletions packages/zig/lib-std-zig-system.zig.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 861427c

Please sign in to comment.