make build: auto-build libjerboa_native.so; link -lstdc++ for duckdb

ober

1e16db63363f7406a755e354a3cd4fc50665e09a

diff --git a/Makefile b/Makefile
index 8306dc0..885d3c5 100644
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,23 @@ sqlite-shim:
 	    vendor/chez-sqlite/chez_sqlite_shim.c -lsqlite3; \
 	fi
 
-gen: purge-stale sqlite-shim
+# ── libjerboa_native.so (Rust FFI) ──────────────────────────────────────────
+# secrets.ss + std/net/request + std/regex etc. all bind FFI symbols from
+# libjerboa_native at library load time, so the .so must exist in
+# $(NATIVE_LIB_DIR) (== $(JERBOA_HOME)/lib) before scheme starts.  Without
+# this, `make build` dies with "no entry for jerboa_last_error" the moment
+# any library importing (std crypto native-rust) is visited.
+#
+# Defer to jerboa's own `make native` so we don't need to know about the
+# cargo target dir or how the .so gets ad-hoc-signed on macOS.
+NATIVE_SO := $(NATIVE_LIB_DIR)/libjerboa_native.so
+native-so:
+	@if [ ! -f "$(NATIVE_SO)" ]; then \
+	  echo "=== libjerboa_native.so missing — building via $(JERBOA_HOME) ==="; \
+	  $(MAKE) -C $(JERBOA_HOME) native; \
+	fi
+
+gen: purge-stale sqlite-shim native-so
 	$(JERBUILD) src lib
 
 build: gen
diff --git a/build-binary.ss b/build-binary.ss
index f13d7c2..361bb3b 100644
--- a/build-binary.ss
+++ b/build-binary.ss
@@ -499,7 +499,10 @@
     (termux?
       "-lkernel -llz4 -lz -lm -ldl -lpthread -lncurses -liconv -lsqlite3")
     (else
-      "-lkernel -llz4 -lz -lm -ldl -lpthread -luuid -lncurses -lsqlite3")))
+      ;; -lstdc++ needed because libjerboa_native.a (built with --features full
+      ;; in jerboa's `make native`) bundles duckdb, which is a C++ codebase
+      ;; and references std::ostream / std::__cxx11::basic_string symbols.
+      "-lkernel -llz4 -lz -lm -ldl -lpthread -luuid -lncurses -lsqlite3 -lstdc++")))
 
 ;; Compile sqlite shim
 (define cc (or (getenv "CC") "cc"))