-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(main/zig): fix missing dynamic linker and libc runtime
Closes #20294 Zig uses FHS-type path to guess the dynamic linker of `env` binary. That leads to a warning like in #20294 Zig also tries to find the include dir via `clang`, but it failed. I have no idea why.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/zig/zig-lib-std-zig-LibCInstallation.zig.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |