Skip to content

Incorrect MIPS termios constants #13198

@ghost

Description

Zig Version

0.10.0-dev.4418+99c3578f6

Steps to Reproduce

#12079 apparently exposed an interesting C ABI issue for MIPS Linux that @topolarity found where when trying to run tests like this the output looks malformed like this:

$ cat test0.zig                                                                               
test { }

test "test a" {
    return error.SkipZigTest;
}

test "test b" {
    return error.SkipZigTest;
}
$ ./build/stage3/bin/zig test test0.zig -target mips-linux --test-cmd qemu-mips --test-cmd-bin
Test [2/3] test.test a... SKIP
                              Test [3/3] test.test b... SKIP
                                                            1 passed; 2 skipped; 0 failed.
                                                                                          %    

The issue boils down to this tcsetattr

defer os.tcsetattr(file.handle, .NOW, original_termios) catch {
in getTerminalCursorColumn in std.Progress.

This however is purely a C ABI issue. It should actually work.

Here's reproducible code: it gets termios (the terminal's config) and then sets it. It shouldn't change the terminal at all:

Zig:

const std = @import("std");

pub fn main() !void {
    const current_termios = try std.os.tcgetattr(std.os.STDERR_FILENO);
    try std.os.tcsetattr(std.os.STDERR_FILENO, .NOW, current_termios);
}
zig build-exe x.zig -target mips-linux; qemu-mips x

Outcome: broken terminal with echo etc. not working.

C:

#include <termios.h>
#include <unistd.h>

int main() {
    struct termios current_termios;
    tcgetattr(STDERR_FILENO, &current_termios);
    tcsetattr(STDERR_FILENO, TCSANOW, &current_termios);
}
mips-linux-gnu-gcc -static x.c; qemu-mips a.out

Outcome: terminal is the same as before.

You might need the packages gcc-mips-linux-gnu, qemu-user, and qemu-system-mips for your system in order to reproduce this issue.

Expected Behavior

The terminal doesn't break.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-mips32-bit MIPSarch-mips6464-bit MIPSbugObserved behavior contradicts documented or intended behavioros-linuxLinuxstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions