OverviewFilesCommitsIssuesDocsReleasesPeers

hyperswarm-peer commits / ec0c817

swarmd/build.sh: the toolchain is a variable, because a plain build is not portable
daemon/build.sh has carried a warning for months — "anything SHIPPED must be built with the Zig wrappers; a plain build links a newer glibc and will not load on ashatron" — and swarmd had no way to honour it. Measured rather than assumed: a g++ build of swarmd-session needs GLIBC_2.38. ashatron has 2.35, so it cannot load. Built through ../tools/zig-cxx (which targets 2.28) the same source needs GLIBC_2.17, and it runs there. CC=../tools/zig-cc CXX=../tools/zig-cxx OBJ=/tmp/swarmd-obj-zig ./build.sh ⚠ The separate OBJ dir is not optional and the comment says why: mixing toolchains in one cache links objects built against different libcs, which is the half-updated-cache failure wearing a new hat. Proven by using it: tabertron's headless Blender session and a bare swarmd-session on ashatron met on the PUBLIC DHT, both reporting peers=1, on a binary that would not have started before this change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ec0c817c9682a02adf0689bd4975cc6e84a43802
by plankatron <fleeky@gmail.com> · 2026-09-10T23:22:51.000Z

Changed files (1) +31 -18

swarmd/build.sh +31 -18
……@@ -7,6 +7,19 @@ cd "$(dirname "$0")"
77
88KB=/storage/projects/code/hypercore-kb/holepunchto/repos
99PEER=..
10
11# ⛔ A PLAIN BUILD DOES NOT LOAD ON EVERY FLEET MACHINE, and there was no way to
12# ask for one that does. Measured: a g++ build here needs GLIBC_2.38; ashatron
13# has 2.35. ../tools/zig-cxx targets glibc 2.28, which is the documented answer
14# in daemon/build.sh and had no equivalent here.
15#
16# CC=../tools/zig-cc CXX=../tools/zig-cxx OBJ=/tmp/swarmd-obj-zig ./build.sh
17#
18# ⚠ USE A SEPARATE OBJ DIR. Mixing toolchains in one cache links objects built
19# against different libcs, which is the half-updated-cache failure wearing a new
20# hat.
21CC=${CC:-gcc}
22CXX=${CXX:-g++}
1023INC="-Isrc -Ischema -Iclient -I$PEER/src -I$PEER/liboverlay/include -I$PEER/thirdparty/libudx/include -I$KB/tier5/libcompact/include -I$KB/tier4/libutf/include -I$KB/tier4/librpc/include"
1124OBJ=${OBJ:-/tmp/swarmd-obj}
1225mkdir -p "$OBJ"
……@@ -18,32 +31,32 @@ echo "Building libcompact / libutf / librpc..."
1831CLIBS=""
1932for c in "$KB"/tier5/libcompact/src/*.c; do
2033 o="$OBJ/compact_$(basename "$c" .c).o"
21 gcc -std=c99 -O2 -I"$KB/tier5/libcompact/include" -I"$KB/tier4/libutf/include" -c -o "$o" "$c" 2>/dev/null
34 "$CC" -std=c99 -O2 -I"$KB/tier5/libcompact/include" -I"$KB/tier4/libutf/include" -c -o "$o" "$c" 2>/dev/null
2235 CLIBS="$CLIBS $o"
2336done
2437for c in "$KB"/tier4/libutf/src/*.c "$KB"/tier4/libutf/src/*/*.c; do
2538 [ -f "$c" ] || continue
2639 o="$OBJ/utf_$(echo "$c" | md5sum | cut -c1-8).o"
27 gcc -std=c99 -O2 -I"$KB/tier4/libutf/include" -c -o "$o" "$c" 2>/dev/null || continue
40 "$CC" -std=c99 -O2 -I"$KB/tier4/libutf/include" -c -o "$o" "$c" 2>/dev/null || continue
2841 CLIBS="$CLIBS $o"
2942done
3043for c in "$KB"/tier4/librpc/src/*.c; do
3144 o="$OBJ/rpc_$(basename "$c" .c).o"
32 gcc -std=c99 -O2 -I"$KB/tier4/librpc/include" -I"$KB/tier5/libcompact/include" -I"$KB/tier4/libutf/include" -c -o "$o" "$c" 2>/dev/null || continue
45 "$CC" -std=c99 -O2 -I"$KB/tier4/librpc/include" -I"$KB/tier5/libcompact/include" -I"$KB/tier4/libutf/include" -c -o "$o" "$c" 2>/dev/null || continue
3346 CLIBS="$CLIBS $o"
3447done
3548
3649echo "Building generated wire..."
37gcc -std=c99 -O2 $INC -c -o "$OBJ/swarmd_schema.o" schema/swarmd_schema.c
38gcc -std=c99 -O2 $INC -c -o "$OBJ/swarmd_hrpc.o" schema/swarmd_hrpc.c
50"$CC" -std=c99 -O2 $INC -c -o "$OBJ/swarmd_schema.o" schema/swarmd_schema.c
51"$CC" -std=c99 -O2 $INC -c -o "$OBJ/swarmd_hrpc.o" schema/swarmd_hrpc.c
3952
4053echo "Building the client library..."
41g++ -std=c++17 -O2 $INC -c -o "$OBJ/client.o" client/client.cpp
54"$CXX" -std=c++17 -O2 $INC -c -o "$OBJ/client.o" client/client.cpp
4255
4356echo "Building daemon sources..."
44g++ -std=c++17 -O2 $INC -c -o "$OBJ/uds_server.o" src/uds_server.cpp
45g++ -std=c++17 -O2 $INC -c -o "$OBJ/control.o" src/control.cpp
46g++ -std=c++17 -O2 $INC -c -o "$OBJ/content.o" src/content.cpp
57"$CXX" -std=c++17 -O2 $INC -c -o "$OBJ/uds_server.o" src/uds_server.cpp
58"$CXX" -std=c++17 -O2 $INC -c -o "$OBJ/control.o" src/control.cpp
59"$CXX" -std=c++17 -O2 $INC -c -o "$OBJ/content.o" src/content.cpp
4760
4861# The transport. Reuses hyperswarm-peer's object cache when test/build_tests.sh
4962# has populated it; otherwise builds what swarmd needs.
……@@ -60,7 +73,7 @@ PEERNEW=$(ls -t "$PEER"/src/*.h "$PEER"/src/*.cpp | head -1)
6073for n in $PEERSRC; do
6174 o="$OBJ/peer_$n.o"
6275 if [ ! -f "$o" ] || [ "$PEERNEW" -nt "$o" ]; then
63 g++ -std=c++17 -O2 -D_GNU_SOURCE -I$PEER/src -I$PEER/thirdparty/libudx/include \
76 "$CXX" -std=c++17 -O2 -D_GNU_SOURCE -I$PEER/src -I$PEER/thirdparty/libudx/include \
6477 -I$KB/tier5/libcompact/include -I$KB/tier4/libutf/include \
6578 -c -o "$o" "$PEER/src/$n.cpp"
6679 fi
……@@ -78,40 +91,40 @@ for c in "$PEER"/thirdparty/libudx/src/*.c; do
7891done
7992
8093echo "Building daemon..."
81g++ -std=c++17 -O2 $INC -c -o "$OBJ/daemon.o" src/daemon.cpp
82g++ -std=c++17 -O2 $INC -o swarmd src/main.cpp \
94"$CXX" -std=c++17 -O2 $INC -c -o "$OBJ/daemon.o" src/daemon.cpp
95"$CXX" -std=c++17 -O2 $INC -o swarmd src/main.cpp \
8396 "$OBJ/daemon.o" "$OBJ/uds_server.o" "$OBJ/control.o" "$OBJ/content.o" \
8497 "$OBJ/swarmd_schema.o" "$OBJ/swarmd_hrpc.o" $CLIBS $TLIBS \
8598 -lsodium -luv -lpthread
8699
87100echo "Building gates..."
88g++ -std=c++17 -O2 $INC -o test/test_uds_backpressure \
101"$CXX" -std=c++17 -O2 $INC -o test/test_uds_backpressure \
89102 test/test_uds_backpressure.cpp "$OBJ/uds_server.o"
90103
91g++ -std=c++17 -O2 $INC -o test/test_control \
104"$CXX" -std=c++17 -O2 $INC -o test/test_control \
92105 test/test_control.cpp "$OBJ/uds_server.o" "$OBJ/control.o" \
93106 "$OBJ/swarmd_schema.o" "$OBJ/swarmd_hrpc.o" $CLIBS
94107
95108# Drives the REAL Daemon (transport and all), so it links what swarmd links.
96g++ -std=c++17 -O2 $INC -o test/test_send_truth \
109"$CXX" -std=c++17 -O2 $INC -o test/test_send_truth \
97110 test/test_send_truth.cpp "$OBJ/daemon.o" "$OBJ/uds_server.o" "$OBJ/control.o" \
98111 "$OBJ/content.o" \
99112 "$OBJ/swarmd_schema.o" "$OBJ/swarmd_hrpc.o" $CLIBS $TLIBS \
100113 -lsodium -luv -lpthread
101114
102g++ -std=c++17 -O2 $INC -o test/test_client \
115"$CXX" -std=c++17 -O2 $INC -o test/test_client \
103116 test/test_client.cpp "$OBJ/client.o" "$OBJ/daemon.o" "$OBJ/uds_server.o" \
104117 "$OBJ/control.o" "$OBJ/content.o" \
105118 "$OBJ/swarmd_schema.o" "$OBJ/swarmd_hrpc.o" $CLIBS $TLIBS \
106119 -lsodium -luv -lpthread
107120
108121echo "Building tools..."
109g++ -std=c++17 -O2 $INC -o tools/swarmd-probe tools/swarmd_probe.cpp \
122"$CXX" -std=c++17 -O2 $INC -o tools/swarmd-probe tools/swarmd_probe.cpp \
110123 "$OBJ/client.o" "$OBJ/swarmd_schema.o" "$OBJ/swarmd_hrpc.o" $CLIBS
111124
112125# swarmd-session: session-daemon's socket, swarmd's insides. Links the daemon
113126# too, because it runs one.
114g++ -std=c++17 -O2 $INC -o tools/swarmd-session tools/session_shim.cpp \
127"$CXX" -std=c++17 -O2 $INC -o tools/swarmd-session tools/session_shim.cpp \
115128 "$OBJ/client.o" "$OBJ/daemon.o" "$OBJ/uds_server.o" "$OBJ/control.o" \
116129 "$OBJ/content.o" "$OBJ/swarmd_schema.o" "$OBJ/swarmd_hrpc.o" $CLIBS $TLIBS \
117130 -lsodium -luv -lpthread