Skip to content
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
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,59 @@ jobs:
- name: Run tests
run: cd coreutils && make test

# There is no Vinix runner on GitHub, so this job does not run the suite. It
# cross-compiles every tool for the target instead, which is the check that
# catches what the platform-gated files in src/*/ get wrong: a tool whose
# shared .v and its _nix/_default variants disagree will not build for Vinix
# even though it builds for Windows, and that is exactly how `timeout` was
# broken on all three Unix targets before this existed.
vinix-cross-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Latest V
uses: actions/checkout@v6
with:
repository: vlang/v
path: v
- name: Build V
run: cd v && make && sudo ./v symlink && cd -
- name: Checkout Coreutils
uses: actions/checkout@v6
with:
path: coreutils
- name: V doctor
run: v doctor
- name: Cross-compile every tool for Vinix
shell: bash
run: |
cd coreutils
# Read the ignore list straight out of build.vsh so the two cannot
# drift. `grep -n` and `sed -n` are both 1-based, so the key's own
# line is the one to read and there is no offset to get wrong.
# The key word itself is dropped, since it is not a tool name.
ignored=$(grep -E "^\s*'vinix':" build.vsh | grep -oE "'[a-z0-9_]+'" | tr -d "'"
| grep -vx 'vinix')
echo "vinix ignores: ${ignored:-<none>}"
ok=0 skipped=0 failed=0
for d in src/*/; do
name=$(basename "$d")
# A tool directory is one holding at least one .v file.
compgen -G "$d*.v" >/dev/null || continue
if printf '%s\n' "$ignored" | grep -qx "$name"; then
skipped=$((skipped + 1))
continue
fi
if v -os vinix -o "/tmp/vinix_${name}.c" "$d" >/dev/null 2>&1; then
ok=$((ok + 1))
else
echo "::error file=$d::cross-compile for vinix failed: $name"
v -os vinix -o "/tmp/vinix_${name}.c" "$d" 2>&1 | head -20 || true
failed=$((failed + 1))
fi
done
echo "vinix cross-compile: ok=$ok skipped=$skipped failed=$failed"
[ "$failed" -eq 0 ]

ubuntu-gnu-coreutils:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions build.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ const ignore_dirs = {
// TODO: nohup is included in Win32 version
'nohup',
]
// Vinix is a Unix-like, so it shares the macOS list. The two categories
// differ for a reason worth spelling out: `stat` and `sync` are excluded on
// macOS because the BSD syscall surface differs from Linux, and Vinix
// follows POSIX closely enough that they do build there; `uptime` is
// excluded everywhere because it reads the utmp database, which Vinix
// does not implement yet.
'macos': ['stat', 'sync', 'uptime']
'vinix': ['uptime']
}[user_os()] or { [] }

unbuffer_stdout()
Expand Down
2 changes: 1 addition & 1 deletion src/timeout/timeout_default.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn setup_process_group(p os.Process, foreground bool) {
// Fallback
}

fn terminate_process(p os.Process, sig_num int, process_group bool) {
fn terminate_process(mut p &os.Process, sig_num int, process_group bool) {
// Fallback: try to kill the process
p.signal_kill()
}
5 changes: 4 additions & 1 deletion src/timeout/timeout_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ fn setup_process_group(p os.Process, foreground bool) {
}
}

fn terminate_process(p &os.Process, sig_num int, process_group bool) {
// All three platform variants take `mut p`, so the caller in timeout.v can pass
// `mut &p` unconditionally. Passing this one by value made the compiler insert an
// automatic reference and then reject that as deprecated.
fn terminate_process(mut p &os.Process, sig_num int, process_group bool) {
pid := if process_group { -p.pid } else { p.pid }
C.kill(pid, sig_num)
}
Loading