Fix linux amd64 static build
ober
318cd336d5064dec0896bfcca4a4d7cf78be76bf
--- a/Makefile +++ b/Makefile @@ -329,7 +329,7 @@ jcode-musl: docker # # Produces: jcode-linux-amd64 -XC_LIBDIRS = $(JERBOA_HOME)/lib:./lib:vendor/chez-sqlite/src:vendor/jerboa-websearch/src +XC_LIBDIRS = ./lib:vendor/chez-sqlite/src:vendor/jerboa-websearch/src:$(JH)/lib:$(JERBOA_HOME)/lib linux-amd64: gen @command -v x86_64-linux-musl-gcc >/dev/null 2>&1 || { \ --- a/build-jcode-cross.ss +++ b/build-jcode-cross.ss @@ -356,7 +356,9 @@ ;; env/misc — std/os/env, std/text/time "setenv" "unsetenv" "strerror" "localtime" "strftime" "sysconf" "getpagesize" "getrlimit" - "system" "getenv" "putenv" "_exit" "execvp" "execve" + "system" "getenv" "putenv" "_exit" "exit" "execvp" "execve" + ;; temporary files/directories — std/os/temp + "mkstemp" "mkdtemp" "unlink" "rmdir" ;; errno location "__errno_location" "fcntl")) @@ -388,14 +390,17 @@ (display "#include \"scheme_boot.h\"\n" out) (display "#include \"jcode_program.h\"\n\n" out) ;; dlopen/dlsym stubs — in a fully-static -static binary musl's dlopen - ;; always fails. Jerboa stdlib does (load-shared-object #f) at init; with - ;; these stubs that succeeds and Chez routes lookups through Sforeign_symbol. + ;; always fails. Jerboa stdlib does (load-shared-object #f) and, in some + ;; libc fallback modules, (load-shared-object "") to expose the main + ;; executable; with these stubs those succeed and Chez routes lookups + ;; through Sforeign_symbol. (display "/* dlopen stubs for static linking.\n" out) (display " * (load-shared-object #f) passes f=NULL — succeed (main exe).\n" out) + (display " * (load-shared-object \"\") passes f=\"\" — also succeed (main exe).\n" out) (display " * (load-shared-object \"libfoo\") passes f=\"libfoo\" — fail so the\n" out) (display " * Scheme guard falls back to a no-op stub and we never try to\n" out) (display " * dlsym a function that's not statically linked. */\n" out) - (display "void *dlopen(const char *f, int flags) { (void)flags; return f ? NULL : (void*)1; }\n" out) + (display "void *dlopen(const char *f, int flags) { (void)flags; return (!f || f[0] == '\\0') ? (void*)1 : NULL; }\n" out) (display "void *dlsym(void *h, const char *s) { (void)h; (void)s; return NULL; }\n" out) (display "int dlclose(void *h) { (void)h; return 0; }\n" out) ;; dlerror MUST return a non-NULL string — Chez's load-shared-object error --- a/build-jcode-musl.ss +++ b/build-jcode-musl.ss @@ -218,6 +218,8 @@ "setenv" "unsetenv" "strerror" "localtime" "strftime" "sysconf" "getpagesize" "getrlimit" "system" "getenv" "putenv" "_exit" "exit" "execvp" "execve" + ;; temporary files/directories — std/os/temp + "mkstemp" "mkdtemp" "unlink" "rmdir" ;; errno location (Linux glibc + musl convention) "__errno_location" "fcntl")) --- a/src/jcode/provider/provider.ss +++ b/src/jcode/provider/provider.ss @@ -1710,7 +1710,7 @@ (let ((extra (responses-collect-tool-calls out))) (when (pair? extra) (set-box! tool-calls-box - (append (unbox tool-calls-box) extra)))))))))))))))))))) + (append (unbox tool-calls-box) extra))))))))))))))))))) (unless (= http-status 200) (log-error logger "grok-responses-stream-http-error" `((status . ,http-status) (url . ,url)))))