From ccc377e778e56f9cf6c1149b4bfe877bd4dcf282 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sat, 2 Dec 2023 10:11:44 -0800 Subject: [PATCH] Log cuda build command to stderr See #19 --- llamafile/cuda.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/llamafile/cuda.c b/llamafile/cuda.c index 80ef4efcd5..2e84452864 100644 --- a/llamafile/cuda.c +++ b/llamafile/cuda.c @@ -131,11 +131,31 @@ static bool CreateTempPath(const char *path, char tmp[static PATH_MAX]) { } } +static void LogCommand(char *args[]) { + for (int i = 0; args[i]; ++i) { + if (i) { + tinyprint(2, " ", NULL); + } + // this quoting should be close enough to correct to be + // copy/pastable on both unix and windows command terms + bool need_quotes = !!strchr(args[i], ' '); + if (need_quotes) { + tinyprint(2, "\"", NULL); + } + tinyprint(2, args[i], NULL); + if (need_quotes) { + tinyprint(2, "\"", NULL); + } + } + tinyprint(2, "\n", NULL); +} + static bool Compile(const char *src, const char *tmp, const char *out, char *args[]) { int pid, ws; + LogCommand(args); errno_t err = posix_spawnp(&pid, args[0], NULL, NULL, args, environ); if (err) { perror(args[0]);