-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Unexpected error occurs when running a Zig program on CentOS 5.8 #20959
Comments
Zig supports a minimum linux kernel of 4.19, and CentOS 5.8 would be using something like 2.8 or 3.5? |
I checked with uname -r, and the version displayed is 2.6.18-308.el5. Well, it’s a bit frustrating that this version is not supported. |
With the same output, I built one using Rust and didn't encounter any errors. I hope that the Linux kernels supported by Rust can also be supported by Zig. |
@gaogaogoo you need to target ancient kernels explicitly in zig:
note that you may also have to explicitly target an old lib depending on your system. https://distrowatch.com/table.php?distribution=centos tells me centos 5.11 uses glibc 2.5, so you probably want a target of Aside, why on earth are you running/writing new software to work on a system as old as centos 5.8? Centos 5.11 had an EOL in 2017, over 7 years ago! |
Thank you for your reply. Since some of our legacy services can only run on CentOS 5, and these services do not have source code and cannot be updated, we cannot rewrite them. Additionally, we need to develop applications that extend these services on CentOS 5. Unfortunately, when I used zig build-exe -target x86_64-linux.2.6.18-gnu main.zig to build the program, I encountered the same error. The issue persists even when using x86_64-linux.2.6.18-gnu.2.5. |
Note that in your example, the Zig's lib/std/start.zig (which is invoking getrlimit) says:
So maybe that comment needs to be updated (its not silent) --- or I'm wrong about where the failing invocation of Alternatively, looking at start.zig, this getrlimit() call is only happening if the ELF binary contains a In any event, you might try editing start.zig to comment out this call. If that works, we should be able to get Zig to skip the getrlimit call if its not implemented. (Or get it to be more silent like the comment suggests.) |
That log only happens when: pub const unexpected_error_tracing = builtin.zig_backend == .stage2_llvm and builtin.mode == .Debug; so it should be silent in e.g. release-safe builds....
Try adding |
@daurnimator The "hello" was indeed printed correctly, so the program is working. It's just that the error message made me think there might be areas where Zig could be optimized. I just tried your method of linking libc, and the unexpected error disappeared. This has been very helpful to me—thank you very much! |
@daurnimator I have added code to run commands on top of the 'hello' output, and am encountering an unexpected error once again. I linked libc during the build process and hope to get further assistance. The code is as follows: const std = @import("std");
pub fn main() !void {
std.debug.print("hello!\n", .{});
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const result = try std.process.Child.run(.{
.allocator = allocator,
.argv = &[_][]const u8{"ls"},
.max_output_bytes = 1024 * 1024,
});
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);
std.debug.print("{s}\n", .{result.stdout});
} The error message is as follows:
|
As @daurnimator noted, error 38 is In general, the Zig standard library has been written assuming a reasonably modern Linux kernel version, so you're likely to hit more and more of these issues. (For another example, we use FWIW, though, non-invasive patches to support old systems are welcome. |
As @alexrp notes, your kernel is so old it doesn't have In this case, you'll want to add an extra bit around Line 648 in 6d2945f
so that e.g. when the try fails, it falls back to the pipe2 case
|
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
The code only contains a single simple output line:
const std = @import("std");
pub fn main() !void {
std.debug.print("hello!\n", .{});
}
The error message is as follows:
unexpected errno: 38
C:\Users\Cheney.zvm\0.13.0\lib\std/debug.zig:197:31: 0x1037c2f in dumpCurrentStackTrace (abc)
C:\Users\Cheney.zvm\0.13.0\lib\std/posix.zig:7320:40: 0x103874e in unexpectedErrno (abc)
C:\Users\Cheney.zvm\0.13.0\lib\std/posix.zig:6991:45: 0x1036fcc in getrlimit (abc)
C:\Users\Cheney.zvm\0.13.0\lib\std/start.zig:448:51: 0x1035116 in expandStackSize (abc)
C:\Users\Cheney.zvm\0.13.0\lib\std/start.zig:435:24: 0x1034710 in posixCallMainAndExit (abc)
C:\Users\Cheney.zvm\0.13.0\lib\std/start.zig:266:5: 0x10344b1 in _start (abc)
???:?:?: 0x0 in ??? (???)
hello!
Expected Behavior
There is no error.
The text was updated successfully, but these errors were encountered: