Skip to content
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

[DO NOT MERGE] fix(main/zig): fix missing dynamic linker and libc runtime #22442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
107 changes: 107 additions & 0 deletions packages/zig/zig-lib-std-zig-LibCInstallation.zig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
diff --git a/zig/lib/std/zig/LibCInstallation.zig b/zig/lib/std/zig/LibCInstallation.zig
index 686471bd..4142c72d 100644
--- a/zig/lib/std/zig/LibCInstallation.zig
+++ b/zig/lib/std/zig/LibCInstallation.zig
@@ -167,52 +167,56 @@ pub const FindNativeOptions = struct {
pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation {
var self: LibCInstallation = .{};

- if (is_darwin and args.target.isDarwin()) {
- if (!std.zig.system.darwin.isSdkInstalled(args.allocator))
- return error.DarwinSdkNotFound;
- const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse
- return error.DarwinSdkNotFound;
- defer args.allocator.free(sdk);
-
- self.include_dir = try fs.path.join(args.allocator, &.{
- sdk, "usr/include",
- });
- self.sys_include_dir = try fs.path.join(args.allocator, &.{
- sdk, "usr/include",
- });
- return self;
- } else if (is_windows) {
- const sdk = std.zig.WindowsSdk.find(args.allocator) catch |err| switch (err) {
- error.NotFound => return error.WindowsSdkNotFound,
- error.PathTooLong => return error.WindowsSdkNotFound,
- error.OutOfMemory => return error.OutOfMemory,
- };
- defer sdk.free(args.allocator);
-
- try self.findNativeMsvcIncludeDir(args, sdk);
- try self.findNativeMsvcLibDir(args, sdk);
- try self.findNativeKernel32LibDir(args, sdk);
- try self.findNativeIncludeDirWindows(args, sdk);
- try self.findNativeCrtDirWindows(args, sdk);
- } else if (is_haiku) {
- try self.findNativeIncludeDirPosix(args);
- try self.findNativeGccDirHaiku(args);
- self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib");
- } else if (builtin.target.os.tag.isSolarish()) {
- // There is only one libc, and its headers/libraries are always in the same spot.
- 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 (std.process.can_spawn) {
- try self.findNativeIncludeDirPosix(args);
- switch (builtin.target.os.tag) {
- .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib"),
- .linux => try self.findNativeCrtDirPosix(args),
- else => {},
- }
- } else {
- return error.LibCRuntimeNotFound;
- }
+ // if (is_darwin and args.target.isDarwin()) {
+ // if (!std.zig.system.darwin.isSdkInstalled(args.allocator))
+ // return error.DarwinSdkNotFound;
+ // const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse
+ // return error.DarwinSdkNotFound;
+ // defer args.allocator.free(sdk);
+
+ // self.include_dir = try fs.path.join(args.allocator, &.{
+ // sdk, "usr/include",
+ // });
+ // self.sys_include_dir = try fs.path.join(args.allocator, &.{
+ // sdk, "usr/include",
+ // });
+ // return self;
+ // } else if (is_windows) {
+ // const sdk = std.zig.WindowsSdk.find(args.allocator) catch |err| switch (err) {
+ // error.NotFound => return error.WindowsSdkNotFound,
+ // error.PathTooLong => return error.WindowsSdkNotFound,
+ // error.OutOfMemory => return error.OutOfMemory,
+ // };
+ // defer sdk.free(args.allocator);
+
+ // try self.findNativeMsvcIncludeDir(args, sdk);
+ // try self.findNativeMsvcLibDir(args, sdk);
+ // try self.findNativeKernel32LibDir(args, sdk);
+ // try self.findNativeIncludeDirWindows(args, sdk);
+ // try self.findNativeCrtDirWindows(args, sdk);
+ // } else if (is_haiku) {
+ // try self.findNativeIncludeDirPosix(args);
+ // try self.findNativeGccDirHaiku(args);
+ // self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib");
+ // } else if (builtin.target.os.tag.isSolarish()) {
+ // // There is only one libc, and its headers/libraries are always in the same spot.
+ // 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 (std.process.can_spawn) {
+ // try self.findNativeIncludeDirPosix(args);
+ // switch (builtin.target.os.tag) {
+ // .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib"),
+ // .linux => try self.findNativeCrtDirPosix(args),
+ // else => {},
+ // }
+ // } else {
+ // return error.LibCRuntimeNotFound;
+ // }
+
+ self.include_dir = try args.allocator.dupeZ(u8, "@TERMUX_PREFIX@/include");
+ self.sys_include_dir = try args.allocator.dupeZ(u8, "@TERMUX_PREFIX@/sys_include");
+ self.crt_dir = try args.allocator.dupeZ(u8, "@TERMUX_PREFIX@/lib");
return self;
}

13 changes: 13 additions & 0 deletions packages/zig/zig-lib-std-zig-system.zig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/zig/lib/std/zig/system.zig b/zig/lib/std/zig/system.zig
index 83c798c3..69aef66e 100644
--- a/zig/lib/std/zig/system.zig
+++ b/zig/lib/std/zig/system.zig
@@ -996,6 +996,8 @@ fn detectAbiAndDynamicLinker(
.haiku => "/bin/env",
};

+ file_name = "@TERMUX_PREFIX@/bin/env";
+
// According to `man 2 execve`:
//
// The kernel imposes a maximum length on the text
Loading